定制 viget/craft-classnames 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

viget/craft-classnames

最新稳定版本:3.0.0

Composer 安装命令:

composer require viget/craft-classnames

包简介

Classnames plugin for Craft CMS

README 文档

README

Classnames plugin for Craft CMS 5.x

Classnames is a simple Twig function for conditionally joining css class names together in Twig templates, in a way that makes them much more readable. It's like Jed Watson's Classnames but for Twig in Craft.

This plugin is especially useful with Tailwind CSS projects.

Requirements

This plugin requires Craft CMS 5.0.0 or later.

For Craft 4 users, view the v2 branch.

Installation

To install the plugin, follow these instructions.

  1. Open your terminal and go to your Craft project:

     cd /path/to/project
    
  2. Then tell Composer to load the plugin:

     composer require viget/craft-classnames
    
  3. Install the plugin either via the CLI with ./craft plugin/install classnames, or in the Control Panel by going to Settings → Plugins and clicking the “Install” button for Classnames.

Using Classnames

A real world example:

<button
  class="{{ classNames({
    'group relative z-0 hover:z-1': true,
    'px-24 py-12': true,
    'font-bold text-14 text-dark-gray': true,
    'inline-flex items-center justify-between': props.arrow,
    'inline-block': not props.arrow,
    'w-full text-center': props.full
  }) }}"
>
  {{ props.text }}
</button>

Other examples:

{{ classNames('foo', 'bar') }} {# 'foo bar' #}
{{ classNames('foo', { 'bar': true }) }} {# 'foo bar' #}
{{ classNames({ 'foo-bar': true }) }} {# 'foo-bar' #}
{{ classNames({ 'foo-bar': false }) }} {# '' #}
{{ classNames({ 'foo': true }, { 'bar': true }) }} {# 'foo bar' #}
{{ classNames({ 'foo': true, 'bar': true }) }} {# 'foo bar' #}

There is even a shorthand cx version available:

{{ cx('foo', { 'bar': true }) }} {# 'foo bar' #}
Code At Viget

Visit code.viget.com to see more projects from Viget.

统计信息

  • 总下载量: 15.5k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 11
  • 点击次数: 4
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 11
  • Watchers: 14
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-09-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固