efureev / yii2-fontawesome
此包已被废弃,不再维护。未建议替代包。
为 Yii2 应用程序提供 Font Awesome 资产包
2.18.0
2016-09-12 10:29 UTC
Requires
- php: >=5.4.0
- bower-asset/components-font-awesome: *
- yiisoft/yii2: ~2
- dev-master
- 2.18.0
- 2.16.1
- 2.16.0
- 2.15.2
- 2.15.1
- 2.15.0
- 2.14.0
- 2.13.0
- 2.12.2
- 2.12.1
- 2.12.0
- 2.11.0
- 2.10.3
- 2.10.2
- 2.10.1
- 2.10.0
- 2.9.2
- 2.9.1
- 2.9.0
- 2.8.2
- 2.8.1
- 2.8.0
- 2.7.1
- 2.7.0
- 2.6.2
- 2.6.1
- 2.6.0
- 2.5.0
- 2.4.2
- 2.4.1
- 2.4.0
- 2.3.0
- 2.2.2
- 2.2.1
- v2.2
- 2.1.1
- 2.1.0
- 2.0.2
- 2.0.1
- 2.0.0
- 1.2.1
- 1.2.0
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-preview
This package is auto-updated.
Last update: 2024-04-29 03:10:15 UTC
README
此扩展为 Yii2 应用程序提供包含 Font Awesome 的资产包,并提供用于使用图标的辅助工具。
有关许可信息,请查看 LICENSE 文件。
代码状态
支持
安装
安装此扩展的首选方法是使用 composer。
运行以下命令
composer require "efureev/yii2-fontawesome:~2"
或在您的 composer.json
文件的 require
部分中添加
"efureev/yii2-fontawesome": "~2",
到
使用
在视图中
efureev\fontawesome\AssetBundle::register($this);
或作为主应用程序资产包的依赖项
class AppAsset extends AssetBundle { // ... public $depends = [ // ... '\efureev\fontawesome\AssetBundle' ]; }
类参考
命名空间: efureev\fontawesome
;
###类 FA
或 FontAwesome
static FA::icon($name, $options=[])
- 创建一个可用于 FontAwesome html 图标的components\Icon
$name
- Font Awesome 集中图标的名称。$options
- 为i.fa
html 标签添加的额外属性。
static FA::stack($name, $options=[])
- 创建一个可用于 FontAwesome html 图标的components\Stack
$options
- 为span.fa-stack
html 标签添加的额外属性。
###类 components\Icon
($Icon
)
(string)$Icon
- 渲染图标$Icon->render()
- 渲染图标$Icon->tag($value)
- 为图标设置另一个 html 标签(默认i
)$value
- 标签名称
$Icon->addCssClass($value)
- 在$value
中添加 html 标签的 css 类$value
- css 类名称
$Icon->inverse()
- 在 html 标签的 css 类中添加fa-inverse
$Icon->spin()
- 在 html 标签的 css 类中添加fa-spin
$Icon->fixedWidth()
- 在 html 标签的 css 类中添加fa-fw
$Icon->ul()
- 在 html 标签的 css 类中添加fa-ul
$Icon->li()
- 在 html 标签的 css 类中添加fa-li
$Icon->border()
- 在 html 标签的 css 类中添加fa-border
$Icon->pullLeft()
- 在 html 标签的 css 类中添加pull-left
$Icon->pullRight()
- 在 html 标签的 css 类中添加pull-right
$Icon->size($value)
- 添加具有大小属性的 html 标签的 css 类$value
- 大小值(变体:FA::SIZE_LARGE
、FA::SIZE_2X
、FA::SIZE_3X
、FA::SIZE_4X
、FA::SIZE_5X
)
$Icon->rotate($value)
- 添加具有旋转值的 html 标签的 css 类$value
- 旋转值(变体:FA::ROTATE_90
、FA::ROTATE_180
、FA::ROTATE_270
)
$Icon->flip($value)
- 添加具有翻转值的 html 标签的 css 类$value
- 翻转值(变体:FA::FLIP_HORIZONTAL
、FA::FLIP_VERTICAL
)
###类 components\Stack
($Stack
)
(string)$Stack
- 渲染图标堆栈$Stack->render()
- 渲染图标堆栈$Stack->tag($value)
- 为图标堆栈设置另一个 html 标签(默认span
)$Stack->icon($icon, $options=[])
- 设置堆栈的图标$icon
- 图标名称或component\Icon
对象$options
- 为图标 html 标签添加的额外属性。
$Stack->icon($icon, $options=[])
- 设置堆栈的背景图标$icon
- 图标名称或component\Icon
对象$options
- 为图标 html 标签添加的额外属性。
辅助函数示例
use efureev\fontawesome\FA; // normal use echo FA::icon('home'); // <i class="fa fa-home"></i> // shortcut echo FA::i('home'); // <i class="fa fa-home"></i> // icon with additional attributes echo FA::icon( 'arrow-left', ['class' => 'big', 'data-role' => 'arrow'] ); // <i class="big fa fa-arrow-left" data-role="arrow"></i> // icon in button echo Html::submitButton( Yii::t('app', '{icon} Save', ['icon' => FA::icon('check')]) ); // <button type="submit"><i class="fa fa-check"></i> Save</button> // icon with additional methods echo FA::icon('cog')->inverse(); // <i class="fa fa-cog fa-inverse"></i> echo FA::icon('cog')->spin(); // <i class="fa fa-cog fa-spin"></i> echo FA::icon('cog')->fixedWidth(); // <i class="fa fa-cog fa-fw"></i> echo FA::icon('cog')->ul(); // <i class="fa fa-cog fa-ul"></i> echo FA::icon('cog')->li(); // <i class="fa fa-cog fa-li"></i> echo FA::icon('cog')->border(); // <i class="fa fa-cog fa-border"></i> echo FA::icon('cog')->pullLeft(); // <i class="fa fa-cog pull-left"></i> echo FA::icon('cog')->pullRight(); // <i class="fa fa-cog pull-right"></i> // icon size echo FA::icon('cog')->size(FA::SIZE_3X); // values: FA::SIZE_LARGE, FA::SIZE_2X, FA::SIZE_3X, FA::SIZE_4X, FA::SIZE_5X // <i class="fa fa-cog fa-size-3x"></i> // icon rotate echo FA::icon('cog')->rotate(FA::ROTATE_90); // values: FA::ROTATE_90, FA::ROTATE_180, FA::ROTATE_180 // <i class="fa fa-cog fa-rotate-90"></i> // icon flip echo FA::icon('cog')->flip(FA::FLIP_VERTICAL); // values: FA::FLIP_HORIZONTAL, FA::FLIP_VERTICAL // <i class="fa fa-cog fa-flip-vertical"></i> // icon with multiple methods echo FA::icon('cog') ->spin() ->fixedWidth() ->pullLeft() ->size(FA::SIZE_LARGE); // <i class="fa fa-cog fa-spin fa-fw pull-left fa-size-lg"></i> // icons stack echo FA::stack() ->icon('twitter') ->on('square-o'); // <span class="fa-stack"> // <i class="fa fa-square-o fa-stack-2x"></i> // <i class="fa fa-twitter fa-stack-1x"></i> // </span> // icons stack with additional attributes echo FA::stack(['data-role' => 'stacked-icon']) ->on(FA::Icon('square')->inverse()) ->icon(FA::Icon('cog')->spin()); // <span class="fa-stack" data-role="stacked-icon"> // <i class="fa fa-square-o fa-inverse fa-stack-2x"></i> // <i class="fa fa-cog fa-spin fa-stack-1x"></i> // </span> // unordered list icons echo FA::ul(['data-role' => 'unordered-list']) ->item('circle', 'Bullet item') ->item('check', 'Checked item'); // <ul class="fa-ul" data-role="unordered-list"> // <li><i class="fa fa-circle fa-li"></i>Bullet item</li> // <li><i class="fa fa-check fa-li"></i>Checked Item</li> // </span> // autocomplete icons name in IDE echo FA::icon(FA::_COG); echo FA::icon(FA::_DESKTOP); echo FA::stack() ->on(FA::_CIRCLE_O) ->icon(FA::_TWITTER);
设置另一个前缀
FA::$cssPrefix = 'awf'; echo FA::icon('home'); // <i class="awf awf-home"></i> echo FA::icon('cog')->inverse(); // <i class="awf awf-cog awf-inverse"></i>