natewiebe13 / php-lucide
PHP库,用于Lucide图标
v1.0.85
2024-10-03 12:24 UTC
Requires
- php: >=7.4
Requires (Dev)
- ext-dom: *
- ext-json: *
- ext-libxml: *
- ext-simplexml: *
- phpunit/phpunit: ^9.5
- v1.0.x-dev
- v1.0.85
- v1.0.84
- v1.0.83
- v1.0.82
- v1.0.81
- v1.0.80
- v1.0.79
- v1.0.78
- v1.0.77
- v1.0.76
- v1.0.75
- v1.0.74
- v1.0.73
- v1.0.72
- v1.0.71
- v1.0.70
- v1.0.69
- v1.0.68
- v1.0.67
- v1.0.66
- v1.0.65
- v1.0.64
- v1.0.63
- v1.0.62
- v1.0.61
- v1.0.60
- v1.0.59
- v1.0.58
- v1.0.57
- v1.0.56
- v1.0.55
- v1.0.54
- v1.0.53
- v1.0.52
- v1.0.51
- v1.0.50
- v1.0.49
- v1.0.48
- v1.0.47
- v1.0.46
- v1.0.45
- v1.0.44
- v1.0.43
- v1.0.42
- v1.0.41
- v1.0.40
- v1.0.39
- v1.0.38
- v1.0.37
- v1.0.36
- v1.0.35
- v1.0.34
- v1.0.33
- v1.0.32
- v1.0.31
- v1.0.30
- v1.0.29
- v1.0.28
- v1.0.27
- v1.0.26
- v1.0.25
- v1.0.24
- v1.0.23
- v1.0.22
- v1.0.21
- v1.0.20
- v1.0.19
- v1.0.18
- v1.0.17
- v1.0.16
- v1.0.15
- v1.0.14
- v1.0.13
- v1.0.12
- v1.0.11
- v1.0.10
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-automated/lucide-update
This package is auto-updated.
Last update: 2024-10-03 12:25:10 UTC
README
PHP库,用于Lucide。
有关Lucide本身的更多信息,请参阅他们的README。
安装
使用Composer安装php-lucide
。
composer require natewiebe13/php-lucide
版本控制
此库使用语义版本控制作为版本控制策略。这涵盖了公共API,但不保证与Lucide(例如,图标名称更改)所做的破坏性更改的向后兼容性。Lucide可能做出的任何大型向后兼容性中断可能会导致此库的新主要版本,但将根据具体情况确定。如果发生图标名称更改,可以使用别名功能来协助迁移到新的图标名称。
使用方法
图标
图标
从IconManager
获取。
<?php $icons = new \Lucide\IconManager(); ?> <!-- Display the 'anchor' icon --> <?php echo $icons->getIcon('anchor'); ?> <!-- Get creative! --> <button class="icon-button"> Learn More <?= $icons->getIcon('arrow-right'); ?> </button>
Lucide\IconManager::getIcon()
返回一个Icon
对象。要渲染图标html本身,可以将Icon
强制转换为字符串或调用其render()
函数。
$icons->getIcon('anchor'); // Returns an Icon object $html = $icons->getIcon('anchor')->render(); // Returns the icon's html echo $icons->getIcon('anchor'); // Outputs the icon's html, since it is cast as a string
属性
可以在IconManager
和Icon
对象上修改属性。可以使用setAttribute(s)
函数直接修改属性,或使用辅助函数。
在IconManager
上的属性更改将影响由IconManager
创建的所有Icon
对象。对Icon
对象的更改将仅影响单个图标。
// Use on the IconManager instance to set default attributes for all icons $icons->setAttributes(['stroke' => '#fff', 'stroke-width' => 2]); $icons->setAttribute('stroke', '#fff'); $icons->setSize(24); $icons->setColor('#fff'); $icons->setWeight(2); $icons->addCssClass('foo'); // Or use on a single icon to only affect that one echo $icons->getIcon('alert-triangle')->setColor('red')->setAttribute('data-alert', 'true');
无障碍性
获取Icon
时,可以将alt文本作为参数传递,或稍后设置在Icon
上。
$icons->getIcon('anchor', [], 'Icon of an anchor'); $icon->setAltText('Icon of an anchor');
别名
可以设置别名,以便在主题中更容易进行较大范围的更改,例如替换特定用例实际使用的图标。例如,如果想要将关闭按钮图标从使用x
图标切换到x-circle
图标,而不是将图标名称硬编码,可以使用用例的别名并在一个地方更新值。别名在IconManager
上设置。
$icons->addAlias('close-button', 'x');
贡献
请随意提出问题和PR建议。
许可证
在MIT许可证下授权。