feature-ninja/cva
最新稳定版本:0.3.1
Composer 安装命令:
composer require feature-ninja/cva
包简介
Class variance authority implementation in php
README 文档
README
Class Variance Authority implementation in PHP
Installation
You can install the package via composer:
composer require feature-ninja/cva
Usage
use FeatureNinja\Cva\ClassVarianceAuthority; $button = ClassVarianceAuthority::new( ['font-semibold', 'border', 'rounded'], [ 'variants' => [ 'intent' => [ 'primary' => ['bg-blue-500', 'text-white', 'border-transparent', 'hover:bg-blue-600'], 'secondary' => 'bg-white text-gray-800 border-gray-400 hover:bg-gray-100', ], 'size' => [ 'small' => ['text-sm', 'py-1', 'px-2'], 'medium' => 'text-base py-2 px-4', ], ], 'compoundVariants' => [ [ 'intent' => 'primary', 'size' => 'medium', 'class' => 'uppercase', ], ], 'defaultVariants' => [ 'intent' => 'primary', 'size' => 'medium', ], ], ); # Or by using the cva helper function $button = fn\cva( ['font-semibold', 'border', 'rounded'], [ 'variants' => [ 'intent' => [ 'primary' => ['bg-blue-500', 'text-white', 'border-transparent', 'hover:bg-blue-600'], 'secondary' => 'bg-white text-gray-800 border-gray-400 hover:bg-gray-100', ], 'size' => [ 'small' => ['text-sm', 'py-1', 'px-2'], 'medium' => 'text-base py-2 px-4', ], ], 'compoundVariants' => [ [ 'intent' => 'primary', 'size' => 'medium', 'class' => 'uppercase', ], ], 'defaultVariants' => [ 'intent' => 'primary', 'size' => 'medium', ], ], );
<button class="<?= $button(); ?>">Submit</button> <button class="<?= $button(['intent' => 'secondary', 'size' => 'small']); ?>">Submit</button>
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 12.4k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 16
- 点击次数: 1
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-11-17