yii2-icofont Asset Bundle for Yii2 with IcoFont http://icofont.com

Yii 2 IcoFont Asset Bundle

  1. Installation
  2. Usage
  3. FontIcoHelper (FI) examples
  4. Resources

This extension provides a assets bundle with IcoFont for Yii framework 2.0 applications and helper to use icons.

Installation

The preferred way to install this extension is through composer.

Either run

composer require "loveorigami/yii2-icofont:*"

or add

"loveorigami/yii2-icofont": "*",

to the require section of your composer.json file.

Usage

In view

lo\icofont\IcoFontAsset::register($this);

or as dependency in your main application asset bundle

class AppAsset extends AssetBundle
{
    // ...

    public $depends = [
        // ...
        'lo\icofont\IcoFontAsset'
    ];
}

FontIcoHelper (FI) examples

use lo\icofont\FI;

// normal use
echo FI::icon('home'); // <i class="icofont icofont-home"></i>

// shortcut
echo FI::i('home'); // <i class="icofont icofont-home"></i>

// icon with additional attributes
echo FI::icon(
    'arrow-left', 
    ['class' => 'big', 'data-role' => 'arrow']
); // <i class="big icofont icofont-arrow-left" data-role="arrow"></i>

// icon in button
echo Html::submitButton(
    Yii::t('app', '{icon} Save', ['icon' => FI::icon('check')])
); // <button type="submit"><i class="icofont icofont-check"></i> Save</button>

// icon with additional methods
echo FI::icon('arrow-right')->pullLeft();   // <i class="icofont icofont-arrow-right pull-left"></i>
echo FI::icon('arrow-right')->pullRight();  // <i class="icofont icofont-arrow-right pull-right"></i>

// autocomplete icons name in IDE
echo FI::icon(FI::_MAGIC);
echo FI::icon(FI::_ARROW_RIGHT);

Resources

0 0
1 follower
0 downloads
Yii Version: 2.0
License: MIT
Category: Web Service
Developed by: loveorigami
Created on: Aug 30, 2016
Last updated: 7 years ago

Related Extensions