2017 © Pedro Peláez
 

yii2-extension yii2-icons

Set of icon frameworks for use in Yii Framework 2.0

image

kartik-v/yii2-icons

Set of icon frameworks for use in Yii Framework 2.0

  • Friday, March 9, 2018
  • by kartik-v
  • Repository
  • 8 Watchers
  • 58 Stars
  • 140,646 Installations
  • CSS
  • 57 Dependents
  • 0 Suggesters
  • 28 Forks
  • 2 Open issues
  • 14 Versions
  • 7 % Grown

The README.md

Krajee Logo
yii2-icons
Donate       kartikv

Latest Stable Version Latest Unstable Version License Total Downloads Monthly Downloads Daily Downloads, (*1)

This extension offers an easy method to setup various icon frameworks to work with Yii Framework 2.0. Most popular and free icon frameworks available are currently supported. This list may be extended in future based on demand and feedback., (*2)

  1. Bootstrap Glyphicons
  2. Font Awesome
  3. Unicode Icons: A collection of unicode symbols made available as CSS icons by Krajee
  4. Elusive Icons
  5. Typicons
  6. Web Hosting Hub Glyphs
  7. JQuery UI Icons
  8. Socicon Icons: Needs you to add attribution to the icon source.
  9. Octicons: The Github icons collection.
  10. Flag-Icons
  11. Open Iconic Icons
  12. IcoFont Icons

Demo

You can see a demonstration here and API Code Documentation on usage of this extension with documentation and examples., (*3)

Installation

The preferred way to install this extension is through composer., (*4)

Note: Check the composer.json for this extension's requirements and dependencies. Read this web tip /wiki on setting the minimum-stability settings for your application's composer.json., (*5)

Either run, (*6)

$ php composer.phar require kartik-v/yii2-icons "@dev"

or add, (*7)

"kartik-v/yii2-icons": "@dev"

to the require section of your composer.json file., (*8)

Usage

Global Setup

In case you wish to setup one Icon framework globally, set the parameter icon-framework in the params array of your Yii Configuration File., (*9)

'params' => [
  'icon-framework' => \kartik\icons\Icon::FAS,  // Font Awesome Icon framework
]

To initialize the globally setup framework in your view, call this code in your view or view layout file., (*10)

use kartik\icons\Icon;
Icon::map($this);  

Per View Setup

You can also call each icon-framework individually in your view or view layout like below. Map any icon framework within each view as in the example below., (*11)

use kartik\icons\Icon;
Icon::map($this, Icon::EL); // Maps the Elusive icon font framework

Displaying Icons

After mapping your icon framework with one of the options above, you can display icons using Icon::show method. Icons can be displayed using one of the options below:, (*12)

use kartik\icons\Icon;

// Option 1: Uses the `icon-framework` setup in Yii config params. 
echo Icon::show('user'); 

// Option 2: Specific Icon Call in a view. Additional options can also be passed to style the icon.
echo Icon::show('user', ['class'=>'fa-2x', 'framework' => Icon::FAS]); 

NOTE: The kartik\icons\Icon::show method outputs a HTML formatted text. So in order to display icons in Yii-2 components like Navbar or Nav, you must set encodeLabels to false., (*13)

$items = [
    ['label' => Icon::show('home') . 'Home', 'url' => ['/site/index']],
];

// Your other code

/* Note you must encodeLabels to false to display icons in labels */
echo \kartik\nav\NavX::widget([
    'items' => $items,
    'encodeLabels' => false
]);

// Your other code

Displaying Stacked Icons

You can also display stacked icons for frameworks like Font Awesome, where this is supported. For example:, (*14)

use kartik\icons\Icon;
// fa-twitter on fa-square
 Icon::showStack('twitter', 'square', ['class'=>'fa-lg'], ['framework' => Icon::FAB], ['framework' => Icon::FAR])

// fa-flag on fa-circle
 Icon::showStack('flag', 'circle', ['class'=>'fa-lg'], ['class'=>'fa-inverse']);

Add Custom Icons

You can add custom icon sets to the list of available frameworks., (*15)

use kartik\icons\Icon;
// add framework
Icon::addFramework('custom', [
    'class' => '\common\icons\CustomIconAsset',
    'prefix' => 'custom-icon',
]);

// map to view file
Icon::map($this, 'custom');

// show the icon
echo Icon::show('menu',['framework' => 'custom']);
namespace common\icons;
class CustomIconAsset extends \yii\web\AssetBundle
{
    public $sourcePath = '@common/icons/assets/custom';
    public $depends = array(
        'yii\web\YiiAsset',
        'yii\bootstrap4\BootstrapAsset'
    );
    public $css=[
        'css/animation.css',
        'css/custom-codes.css',
        'css/custom-embedded.css',
        'css/custom-ie7.css',
        'css/custom-ie7-codes.css',
        'css/custom.css',
    ];
}

The above asset bundle uses files genereted by http://fontello.com/., (*16)

License

yii2-icons is released under the BSD-3-Clause License. See the bundled LICENSE.md for details., (*17)

The Versions

09/03 2018

dev-master

9999999-dev https://github.com/kartik-v/yii2-icons

Set of icon frameworks for use in Yii Framework 2.0

  Sources   Download

BSD 3-Clause

The Requires

 

extension yii2 yii icon font

09/03 2018

v1.4.4

1.4.4.0 https://github.com/kartik-v/yii2-icons

Set of icon frameworks for use in Yii Framework 2.0

  Sources   Download

BSD 3-Clause

The Requires

 

extension yii2 yii icon font

10/11 2017

v1.4.3

1.4.3.0 https://github.com/kartik-v/yii2-icons

Set of icon frameworks for use in Yii Framework 2.0

  Sources   Download

BSD 3-Clause

The Requires

 

extension yii2 yii icon font

22/02 2017

v1.4.2

1.4.2.0 https://github.com/kartik-v/yii2-icons

Set of icon frameworks for use in Yii Framework 2.0

  Sources   Download

BSD 3-Clause

The Requires

 

extension yii2 yii icon font

13/12 2015

v1.4.1

1.4.1.0 https://github.com/kartik-v/yii2-icons

Set of icon frameworks for use in Yii Framework 2.0

  Sources   Download

BSD 3-Clause

The Requires

 

extension yii2 yii icon font

20/04 2015

v1.4.0

1.4.0.0 https://github.com/kartik-v/yii2-icons

Set of icon frameworks for use in Yii Framework 2.0

  Sources   Download

BSD 3-Clause

The Requires

 

extension yii2 yii icon font

18/12 2014

1.3.0.x-dev

1.3.0.9999999-dev https://github.com/kartik-v/yii2-icons

Set of icon frameworks for use in Yii Framework 2.0

  Sources   Download

BSD 3-Clause

The Requires

 

extension yii2 yii icon font

18/12 2014

v1.3.0

1.3.0.0 https://github.com/kartik-v/yii2-icons

Set of icon frameworks for use in Yii Framework 2.0

  Sources   Download

BSD 3-Clause

The Requires

 

extension yii2 yii icon font

08/12 2014

1.2.0.x-dev

1.2.0.9999999-dev https://github.com/kartik-v/yii2-icons

Set of icon frameworks for use in Yii Framework 2.0

  Sources   Download

BSD 3-Clause

The Requires

 

extension yii2 yii icon font

08/12 2014

v1.2.0

1.2.0.0 https://github.com/kartik-v/yii2-icons

Set of icon frameworks for use in Yii Framework 2.0

  Sources   Download

BSD 3-Clause

The Requires

 

extension yii2 yii icon font

10/11 2014

1.1.0.x-dev

1.1.0.9999999-dev https://github.com/kartik-v/yii2-icons

Set of icon frameworks for use in Yii Framework 2.0

  Sources   Download

BSD 3-Clause

The Requires

 

extension yii2 yii icon font

10/11 2014

v1.1.0

1.1.0.0 https://github.com/kartik-v/yii2-icons

Set of icon frameworks for use in Yii Framework 2.0

  Sources   Download

BSD 3-Clause

The Requires

 

extension yii2 yii icon font

05/10 2014

1.0.0.x-dev

1.0.0.9999999-dev https://github.com/kartik-v/yii2-icons

Set of icon frameworks for use in Yii Framework 2.0

  Sources   Download

BSD 3-Clause

The Requires

 

extension yii2 yii icon font

05/10 2014

v1.0.0

1.0.0.0 https://github.com/kartik-v/yii2-icons

Set of icon frameworks for use in Yii Framework 2.0

  Sources   Download

BSD 3-Clause

The Requires

 

extension yii2 yii icon font