yii2 html ul,GitHub - rmrevin/yii2-fontawesome: Asset Bundle for Yii2 with Font Awesome http://forta...

Yii 2 Font Awesome Asset Bundle

This extension provides a assets bundle with Font Awesome

for Yii framework 2.0 applications and helper to use icons.

For license information check the LICENSE-file.

68747470733a2f2f706f7365722e707567782e6f72672f726d726576696e2f796969322d666f6e74617765736f6d652f6c6963656e73652e737667

68747470733a2f2f706f7365722e707567782e6f72672f726d726576696e2f796969322d666f6e74617765736f6d652f762f737461626c652e737667

68747470733a2f2f706f7365722e707567782e6f72672f726d726576696e2f796969322d666f6e74617765736f6d652f762f756e737461626c652e737667

68747470733a2f2f706f7365722e707567782e6f72672f726d726576696e2f796969322d666f6e74617765736f6d652f646f776e6c6f6164732e737667

Code Status

68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f726d726576696e2f796969322d666f6e74617765736f6d652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572

68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f726d726576696e2f796969322d666f6e74617765736f6d652f6261646765732f636f7665726167652e706e673f623d6d6173746572

68747470733a2f2f7472617669732d63692e6f72672f726d726576696e2f796969322d666f6e74617765736f6d652e737667

68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3534313139623739396531363232396665303030303064612f62616467652e737667

Support

Fontawesome version

Version of font-awesome

Version of extension

4.*

~2.17

5.*

~3.0

Update to 3.2

Be careful in version 3.2 rmrevin\yii\fontawesome\AssetBundle package use cdn by default. More in the changelog.

Update to 3.0

Be careful in version 3.0 deprecated methods were removed. More in the changelog.

Update to 2.17

Be careful in version 2.17 deprecated methods were removed. More in the changelog.

Installation

The preferred way to install this extension is through composer.

Either run

composer require "rmrevin/yii2-fontawesome:~3.5"

or add

"rmrevin/yii2-fontawesome": "~3.5",

to the require section of your composer.json file.

Usage with fa pro version

CDN

Add CdnProAssetBundle as depends of your app asset bundle:

class AppAsset extends AssetBundle

{

// ...

public $depends = [

// ...

'rmrevin\yii\fontawesome\CdnProAssetBundle'

];

}

Or inject CdnProAssetBundle in your view:

\rmrevin\yii\fontawesome\CdnProAssetBundle::register($this);

NPM

Install npm package of font:

npm install @fortawesome/fontawesome-pro

or

yarn add @fortawesome/fontawesome-pro

And add NpmProAssetBundle as depends of your app asset bundle:

class AppAsset extends AssetBundle

{

// ...

public $depends = [

// ...

'rmrevin\yii\fontawesome\NpmProAssetBundle'

];

}

Or inject NpmProAssetBundle in your view:

rmrevin\yii\fontawesome\NpmProAssetBundle::register($this);

Optional

In order for do not install the free version of the font-awesome package, you can add it to the replace section of composer.json.

"replace": {

"fortawesome/font-awesome": "*"

},

Usage with fa free version

CDN

Add CdnFreeAssetBundle as depends of your app asset bundle:

class AppAsset extends AssetBundle

{

// ...

public $depends = [

// ...

'rmrevin\yii\fontawesome\CdnFreeAssetBundle'

];

}

Or inject CdnFreeAssetBundle in your view:

rmrevin\yii\fontawesome\CdnFreeAssetBundle::register($this);

Composer

Free version of package fortawesome/font-awesome already installed in vendor.

Add NpmFreeAssetBundle as depends of your app asset bundle:

class AppAsset extends AssetBundle

{

// ...

public $depends = [

// ...

'rmrevin\yii\fontawesome\NpmFreeAssetBundle'

];

}

Or inject NpmFreeAssetBundle in your view:

rmrevin\yii\fontawesome\NpmFreeAssetBundle::register($this);

Class reference

Namespace: rmrevin\yii\fontawesome;

Class FAB, FAL, FAR, FAS or FontAwesome

static FAR::icon($name, $options=[]) - Creates an component\Icon that can be used to FontAwesome html icon

$name - name of icon in font awesome set.

$options - additional attributes for i.fa html tag.

static FAR::stack($name, $options=[]) - Creates an component\Stack that can be used to FontAwesome html icon

$options - additional attributes for span.fa-stack html tag.

Class component\Icon

(string)$Icon - render icon

$Icon->addCssClass($value) - add to html tag css class in $value

$value - name of css class

$Icon->inverse() - add to html tag css class fa-inverse

$Icon->spin() - add to html tag css class fa-spin

$Icon->fixedWidth() - add to html tag css class fa-fw

$Icon->ul() - add to html tag css class fa-ul

$Icon->li() - add to html tag css class fa-li

$Icon->border() - add to html tag css class fa-border

$Icon->pullLeft() - add to html tag css class pull-left

$Icon->pullRight() - add to html tag css class pull-right

$Icon->size($value) - add to html tag css class with size

$value - size value (variants: FA::SIZE_LARGE, FA::SIZE_2X, FA::SIZE_3X, FA::SIZE_4X, FA::SIZE_5X)

$Icon->rotate($value) - add to html tag css class with rotate

$value - rotate value (variants: FA::ROTATE_90, FA::ROTATE_180, FA::ROTATE_270)

$Icon->flip($value) - add to html tag css class with rotate

$value - flip value (variants: FA::FLIP_HORIZONTAL, FA::FLIP_VERTICAL)

Class component\Stack

(string)$Stack - render icon stack

$Stack->icon($icon, $options=[]) - set icon for stack

$icon - name of icon or component\Icon object

$options - additional attributes for icon html tag.

$Stack->icon($icon, $options=[]) - set background icon for stack

$icon - name of icon or component\Icon object

$options - additional attributes for icon html tag.

Helper examples

use rmrevin\yii\fontawesome\FAS;

// or (only in pro version https://fontawesome.com/pro)

// use rmrevin\yii\fontawesome\FAR;

// use rmrevin\yii\fontawesome\FAL;

// use rmrevin\yii\fontawesome\FAB;

// normal use

echo FAS::icon('home'); //

// shortcut

echo FAS::i('home'); //

// icon with additional attributes

echo FAS::icon(

'arrow-left',

['class' => 'big', 'data-role' => 'arrow']

); //

// icon in button

echo Html::submitButton(

Yii::t('app', '{icon} Save', ['icon' => FAS::icon('check')])

); // Save

// icon with additional methods

echo FAS::icon('cog')->inverse(); //

echo FAS::icon('cog')->spin(); //

echo FAS::icon('cog')->fixedWidth(); //

echo FAS::icon('cog')->li(); //

echo FAS::icon('cog')->border(); //

echo FAS::icon('cog')->pullLeft(); //

echo FAS::icon('cog')->pullRight(); //

// icon size

echo FAS::icon('cog')->size(FAS::SIZE_3X);

// values: FAS::SIZE_LARGE, FAS::SIZE_2X, FAS::SIZE_3X, FAS::SIZE_4X, FAS::SIZE_5X

//

// icon rotate

echo FAS::icon('cog')->rotate(FAS::ROTATE_90);

// values: FAS::ROTATE_90, FAS::ROTATE_180, FAS::ROTATE_180

//

// icon flip

echo FAS::icon('cog')->flip(FAS::FLIP_VERTICAL);

// values: FAS::FLIP_HORIZONTAL, FAS::FLIP_VERTICAL

//

// icon with multiple methods

echo FAS::icon('cog')

->spin()

->fixedWidth()

->pullLeft()

->size(FAS::SIZE_LARGE);

//

// icons stack

echo FAS::stack()

->icon('twitter')

->on('square-o');

//

//

//

//

// icons stack with additional attributes

echo FAS::stack(['data-role' => 'stacked-icon'])

->on(FAS::Icon('square')->inverse())

->icon(FAS::Icon('cog')->spin());

//

//

//

//

// Stacking text and icons

echo FAS::stack()

->on(FAS::Icon('square'))

->text('1');

//

//

// 1

//

// Stacking text and icons with options

echo FAS::stack()

->on(FAS::Icon('square'))

->text('1', ['tag'=>'strong', 'class'=>'stacked-text']);

//

//

// 1

//

// Now you can add some css for vertical text positioning:

.stacked-text { margin-top: .3em; }

// unordered list icons

echo FAS::ul(['data-role' => 'unordered-list'])

->item('Bullet item', ['icon' => 'circle'])

->item('Checked item', ['icon' => 'check']);

//

//

Bullet item

//

Checked Item

//

// autocomplete icons name in IDE

echo FAS::icon(FAS::_COG);

echo FAS::icon(FAS::_DESKTOP);

echo FAS::stack()

->on(FAS::_CIRCLE_O)

->icon(FAS::_TWITTER);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值