├── bin ├── .gitignore └── convertNames.sh ├── tests └── unit │ ├── .gitignore │ ├── config │ ├── .gitignore │ └── main.php │ ├── runtime │ ├── assets │ │ └── .gitignore │ └── .gitignore │ ├── bootstrap.php │ ├── TestCase.php │ └── fontawesome │ └── MainTest.php ├── .gitignore ├── FAB.php ├── FAL.php ├── FAR.php ├── FAS.php ├── FA.php ├── AssetBundle.php ├── cdn └── AssetBundle.php ├── CdnFreeAssetBundle.php ├── CdnProAssetBundle.php ├── .scrutinizer.yml ├── NpmFreeAssetBundle.php ├── NpmProAssetBundle.php ├── .travis.yml ├── phpunit.xml.dist ├── LICENSE ├── composer.json ├── component ├── UnorderedList.php ├── Stack.php └── Icon.php ├── CHANGELOG.md ├── README.md ├── FontAwesome.php └── composer.lock /bin/.gitignore: -------------------------------------------------------------------------------- 1 | result.txt 2 | -------------------------------------------------------------------------------- /tests/unit/.gitignore: -------------------------------------------------------------------------------- 1 | runtime/cache/* -------------------------------------------------------------------------------- /tests/unit/config/.gitignore: -------------------------------------------------------------------------------- 1 | main-local.php -------------------------------------------------------------------------------- /tests/unit/runtime/assets/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /tests/unit/runtime/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | !assets -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | /vendor 3 | /coverage 4 | /node_modules 5 | /package.json 6 | /package.lock 7 | /yarn.lock 8 | -------------------------------------------------------------------------------- /FAB.php: -------------------------------------------------------------------------------- 1 | 'testapp', 11 | 'basePath' => $baseDir, 12 | 'aliases' => [ 13 | '@web' => '/', 14 | '@webroot' => $baseDir . '/runtime', 15 | '@vendor' => realpath($baseDir . '/../../vendor'), 16 | '@bower' => realpath($baseDir . '/../../vendor/bower'), 17 | ] 18 | ]; -------------------------------------------------------------------------------- /CdnFreeAssetBundle.php: -------------------------------------------------------------------------------- 1 | [ 24 | 'css/*', 25 | 'js/*', 26 | 'webfonts/*', 27 | 'sprites/*', 28 | 'svgs/*', 29 | ], 30 | ]; 31 | } 32 | -------------------------------------------------------------------------------- /NpmProAssetBundle.php: -------------------------------------------------------------------------------- 1 | [ 24 | 'css/*', 25 | 'js/*', 26 | 'webfonts/*', 27 | 'sprites/*', 28 | 'svgs/*', 29 | ], 30 | ]; 31 | } 32 | -------------------------------------------------------------------------------- /bin/convertNames.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 4 | 5 | VARIABLES_PATH="${DIR}/../vendor/fortawesome/font-awesome/scss/_variables.scss" 6 | 7 | RESULT_PATH="${DIR}/result.txt" 8 | 9 | echo '' > "${RESULT_PATH}" 10 | 11 | while IFS='' read -r line || [[ -n "$line" ]]; do 12 | if [[ ${line} =~ fa\-var\-([a-z0-9\-]+): ]] 13 | then 14 | iconName=${BASH_REMATCH[1]} 15 | upperIconName=`echo ${iconName} | tr /a-z/ /A-Z/` 16 | upperIconName=$(echo ${upperIconName} | sed 's/-/_/g') 17 | 18 | echo "const _${upperIconName} = '${iconName}';" >> "${RESULT_PATH}" 19 | fi 20 | done < "${VARIABLES_PATH}" 21 | 22 | echo "Done. See result in ${RESULT_PATH}"; 23 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | dist: trusty 2 | 3 | language: php 4 | 5 | php: 6 | - 7.1 7 | - 7.2 8 | - 7.3 9 | 10 | matrix: 11 | fast_finish: true 12 | 13 | sudo: false 14 | 15 | cache: 16 | directories: 17 | - vendor 18 | 19 | install: 20 | - travis_retry composer self-update && composer --version 21 | - travis_retry composer global require "fxp/composer-asset-plugin:~1.1" 22 | - export PATH="$HOME/.composer/vendor/bin:$PATH" 23 | - travis_retry composer install --prefer-dist --no-interaction 24 | 25 | script: 26 | - ./vendor/bin/phpunit --verbose --coverage-clover=coverage/coverage.clover 27 | 28 | after_script: 29 | - travis_retry wget https://scrutinizer-ci.com/ocular.phar 30 | - php ocular.phar code-coverage:upload --format=php-clover coverage/coverage.clover 31 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | ./ 11 | 12 | ./tests 13 | ./vendor 14 | 15 | 16 | 17 | 18 | 19 | ./tests/unit/fontawesome 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Revin Roman Borisovich 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rmrevin/yii2-fontawesome", 3 | "description": "Asset Bundle for Yii2 with Font Awesome", 4 | "keywords": [ 5 | "yii", 6 | "font", 7 | "awesome", 8 | "asset", 9 | "bundle" 10 | ], 11 | "type": "yii2-extension", 12 | "license": "MIT", 13 | "minimum-stability": "stable", 14 | "support": { 15 | "issues": "https://github.com/rmrevin/yii2-fontawesome/issues", 16 | "source": "https://github.com/rmrevin/yii2-fontawesome" 17 | }, 18 | "authors": [ 19 | { 20 | "name": "Revin Roman", 21 | "email": "roman@rmrevin.com", 22 | "homepage": "https://rmrevin.com/" 23 | } 24 | ], 25 | "require": { 26 | "php": ">=5.4.0", 27 | "fortawesome/font-awesome": "^5.15.0", 28 | "yiisoft/yii2": "^2.0.0" 29 | }, 30 | "require-dev": { 31 | "doctrine/instantiator": "1.0.*", 32 | "phpdocumentor/reflection-docblock": "~3.1.0", 33 | "phpunit/phpunit": "^6.0" 34 | }, 35 | "autoload": { 36 | "psr-4": { 37 | "rmrevin\\yii\\fontawesome\\": "" 38 | } 39 | }, 40 | "extra": { 41 | "asset-installer-paths": { 42 | "npm-asset-library": "vendor/npm", 43 | "bower-asset-library": "vendor/bower" 44 | } 45 | }, 46 | "repositories": [ 47 | { 48 | "type": "composer", 49 | "url": "https://asset-packagist.org" 50 | } 51 | ] 52 | } 53 | -------------------------------------------------------------------------------- /component/UnorderedList.php: -------------------------------------------------------------------------------- 1 | iconCssPrefix = $iconCssPrefix; 39 | 40 | Html::addCssClass($options, FontAwesome::$basePrefix . '-ul'); 41 | 42 | $options['item'] = function ($item, $index) { 43 | return call_user_func($item, $index); 44 | }; 45 | 46 | $this->options = $options; 47 | } 48 | 49 | /** 50 | * @return string 51 | */ 52 | public function __toString() 53 | { 54 | return Html::ul($this->items, $this->options); 55 | } 56 | 57 | /** 58 | * @param string $label 59 | * @param array $options 60 | * @return \rmrevin\yii\fontawesome\component\UnorderedList 61 | */ 62 | public function item($label, $options = []) 63 | { 64 | $this->items[] = function ($index) use ($label, $options) { 65 | $tag = ArrayHelper::remove($options, 'tag', 'li'); 66 | 67 | $icon = ArrayHelper::remove($options, 'icon'); 68 | $icon = empty($icon) 69 | ? null 70 | : (is_string($icon) ? (string)(new Icon($this->iconCssPrefix, $icon))->li() : $icon); 71 | 72 | $content = trim($icon . $label); 73 | 74 | return Html::tag($tag, $content, $options); 75 | }; 76 | 77 | return $this; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /tests/unit/TestCase.php: -------------------------------------------------------------------------------- 1 | mock_application(); 26 | } 27 | 28 | /** 29 | * Populates Yii::$app with a new application 30 | * The application will be destroyed on tearDown() automatically. 31 | * @param string $appClass 32 | */ 33 | protected function mock_application($appClass = '\yii\console\Application') 34 | { 35 | // for update self::$params 36 | $this->get_param('id'); 37 | 38 | /** @var \yii\console\Application $app */ 39 | new $appClass(self::$params); 40 | } 41 | 42 | /** 43 | * Returns a test configuration param from /data/config.php 44 | * @param string $name params name 45 | * @param mixed $default default value to use when param is not set. 46 | * @return mixed the value of the configuration param 47 | */ 48 | public function get_param($name, $default = null) 49 | { 50 | if (self::$params === null) { 51 | self::$params = require(__DIR__ . '/config/main.php'); 52 | $main_local = __DIR__ . '/config/main-local.php'; 53 | if (file_exists($main_local)) { 54 | self::$params = ArrayHelper::merge(self::$params, require($main_local)); 55 | } 56 | } 57 | 58 | return isset(self::$params[$name]) ? self::$params[$name] : $default; 59 | } 60 | 61 | protected function tearDown() 62 | { 63 | parent::tearDown(); 64 | } 65 | 66 | /** 67 | * Destroys application in Yii::$app by setting it to null. 68 | */ 69 | protected function destroy_application() 70 | { 71 | \Yii::$app = null; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /component/Stack.php: -------------------------------------------------------------------------------- 1 | iconCssPrefix = $iconCssPrefix; 52 | 53 | Html::addCssClass($options, FontAwesome::$basePrefix . '-stack'); 54 | 55 | $this->options = $options; 56 | } 57 | 58 | /** 59 | * @return string 60 | * @throws \yii\base\InvalidConfigException 61 | */ 62 | public function __toString() 63 | { 64 | $options = $this->options; 65 | 66 | $tag = ArrayHelper::remove($options, 'tag', 'span'); 67 | 68 | $template = ArrayHelper::remove($options, 'template', '{back}{front}'); 69 | 70 | $iconBack = $this->icon_back instanceof Icon 71 | ? $this->icon_back->addCssClass(FontAwesome::$basePrefix . '-stack-2x') 72 | : null; 73 | 74 | if ($this->text_front !== null) { 75 | $contentFront = $this->text_front; 76 | } else { 77 | $contentFront = $this->icon_front instanceof Icon 78 | ? $this->icon_front->addCssClass(FontAwesome::$basePrefix . '-stack-1x') 79 | : null; 80 | } 81 | 82 | $content = str_replace(['{back}', '{front}'], [$iconBack, $contentFront], $template); 83 | 84 | return Html::tag($tag, $content, $options); 85 | } 86 | 87 | /** 88 | * @param string|Icon $icon 89 | * @param array $options 90 | * @return \rmrevin\yii\fontawesome\component\Stack 91 | */ 92 | public function icon($icon, $options = []) 93 | { 94 | if (is_string($icon)) { 95 | $icon = new Icon($this->iconCssPrefix, $icon, $options); 96 | } 97 | 98 | $this->icon_front = $icon; 99 | 100 | return $this; 101 | } 102 | 103 | /** 104 | * @param string $text 105 | * @param array $options 106 | * @return \rmrevin\yii\fontawesome\component\Stack 107 | */ 108 | public function text($text = '', $options = []) 109 | { 110 | $tag = ArrayHelper::remove($options, 'tag', 'span'); 111 | 112 | Html::addCssClass($options, FontAwesome::$basePrefix . '-stack-1x'); 113 | 114 | $this->text_front = Html::tag($tag, $text, $options); 115 | 116 | return $this; 117 | } 118 | 119 | /** 120 | * @param string|Icon $icon 121 | * @param array $options 122 | * @return \rmrevin\yii\fontawesome\component\Stack 123 | */ 124 | public function on($icon, $options = []) 125 | { 126 | if (is_string($icon)) { 127 | $icon = new Icon($this->iconCssPrefix, $icon, $options); 128 | } 129 | 130 | $this->icon_back = $icon; 131 | 132 | return $this; 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /component/Icon.php: -------------------------------------------------------------------------------- 1 | options = $options; 40 | } 41 | 42 | /** 43 | * @return string 44 | */ 45 | public function __toString() 46 | { 47 | $options = $this->options; 48 | 49 | $tag = ArrayHelper::remove($options, 'tag', 'i'); 50 | 51 | return Html::tag($tag, null, $options); 52 | } 53 | 54 | /** 55 | * @return \rmrevin\yii\fontawesome\component\Icon 56 | * @throws \yii\base\InvalidConfigException 57 | */ 58 | public function inverse() 59 | { 60 | return $this->addCssClass(FontAwesome::$basePrefix . '-inverse'); 61 | } 62 | 63 | /** 64 | * @return \rmrevin\yii\fontawesome\component\Icon 65 | * @throws \yii\base\InvalidConfigException 66 | */ 67 | public function spin() 68 | { 69 | return $this->addCssClass(FontAwesome::$basePrefix . '-spin'); 70 | } 71 | 72 | /** 73 | * @return \rmrevin\yii\fontawesome\component\Icon 74 | * @throws \yii\base\InvalidConfigException 75 | */ 76 | public function pulse() 77 | { 78 | return $this->addCssClass(FontAwesome::$basePrefix . '-pulse'); 79 | } 80 | 81 | /** 82 | * @return \rmrevin\yii\fontawesome\component\Icon 83 | * @throws \yii\base\InvalidConfigException 84 | */ 85 | public function fixedWidth() 86 | { 87 | return $this->addCssClass(FontAwesome::$basePrefix . '-fw'); 88 | } 89 | 90 | /** 91 | * @return \rmrevin\yii\fontawesome\component\Icon 92 | * @throws \yii\base\InvalidConfigException 93 | */ 94 | public function li() 95 | { 96 | return $this->addCssClass(FontAwesome::$basePrefix . '-li'); 97 | } 98 | 99 | /** 100 | * @return \rmrevin\yii\fontawesome\component\Icon 101 | * @throws \yii\base\InvalidConfigException 102 | */ 103 | public function border() 104 | { 105 | return $this->addCssClass(FontAwesome::$basePrefix . '-border'); 106 | } 107 | 108 | /** 109 | * @return \rmrevin\yii\fontawesome\component\Icon 110 | * @throws \yii\base\InvalidConfigException 111 | */ 112 | public function pullLeft() 113 | { 114 | return $this->addCssClass(FontAwesome::$basePrefix . '-pull-left'); 115 | } 116 | 117 | /** 118 | * @return \rmrevin\yii\fontawesome\component\Icon 119 | * @throws \yii\base\InvalidConfigException 120 | */ 121 | public function pullRight() 122 | { 123 | return $this->addCssClass(FontAwesome::$basePrefix . '-pull-right'); 124 | } 125 | 126 | /** 127 | * @param string $value 128 | * @return \rmrevin\yii\fontawesome\component\Icon 129 | * @throws \yii\base\InvalidConfigException 130 | */ 131 | public function size($value) 132 | { 133 | $values = [ 134 | FontAwesome::SIZE_LG, 135 | FontAwesome::SIZE_SM, 136 | FontAwesome::SIZE_XS, 137 | FontAwesome::SIZE_2X, 138 | FontAwesome::SIZE_3X, 139 | FontAwesome::SIZE_4X, 140 | FontAwesome::SIZE_5X, 141 | FontAwesome::SIZE_6X, 142 | FontAwesome::SIZE_7X, 143 | FontAwesome::SIZE_8X, 144 | FontAwesome::SIZE_9X, 145 | FontAwesome::SIZE_10X, 146 | ]; 147 | 148 | return $this->addCssClass( 149 | FontAwesome::$basePrefix . '-' . $value, 150 | in_array((string)$value, $values, true), 151 | sprintf( 152 | '%s - invalid value. Use one of the constants: %s.', 153 | 'FontAwesome::size()', 154 | implode(', ', $values) 155 | ) 156 | ); 157 | } 158 | 159 | /** 160 | * @param string $value 161 | * @return \rmrevin\yii\fontawesome\component\Icon 162 | * @throws \yii\base\InvalidConfigException 163 | */ 164 | public function rotate($value) 165 | { 166 | $values = [FontAwesome::ROTATE_90, FontAwesome::ROTATE_180, FontAwesome::ROTATE_270]; 167 | 168 | return $this->addCssClass( 169 | FontAwesome::$basePrefix . '-rotate-' . $value, 170 | in_array((string)$value, $values, true), 171 | sprintf( 172 | '%s - invalid value. Use one of the constants: %s.', 173 | 'FontAwesome::rotate()', 174 | implode(', ', $values) 175 | ) 176 | ); 177 | } 178 | 179 | /** 180 | * @param string $value 181 | * @return \rmrevin\yii\fontawesome\component\Icon 182 | * @throws \yii\base\InvalidConfigException 183 | */ 184 | public function flip($value) 185 | { 186 | $values = [FontAwesome::FLIP_HORIZONTAL, FontAwesome::FLIP_VERTICAL]; 187 | 188 | return $this->addCssClass( 189 | FontAwesome::$basePrefix . '-flip-' . $value, 190 | in_array((string)$value, [FontAwesome::FLIP_HORIZONTAL, FontAwesome::FLIP_VERTICAL], true), 191 | sprintf( 192 | '%s - invalid value. Use one of the constants: %s.', 193 | 'FontAwesome::flip()', 194 | implode(', ', $values) 195 | ) 196 | ); 197 | } 198 | 199 | /** 200 | * @param string $class 201 | * @param bool $condition 202 | * @param string|bool $throw 203 | * @return \rmrevin\yii\fontawesome\component\Icon 204 | * @throws \yii\base\InvalidConfigException 205 | * @codeCoverageIgnore 206 | */ 207 | public function addCssClass($class, $condition = true, $throw = false) 208 | { 209 | if ($condition === false) { 210 | if (!empty($throw)) { 211 | $message = !is_string($throw) 212 | ? 'Condition is false' 213 | : $throw; 214 | 215 | throw new InvalidConfigException($message); 216 | } 217 | } else { 218 | Html::addCssClass($this->options, $class); 219 | } 220 | 221 | return $this; 222 | } 223 | } 224 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2021-01-13 - 3.7.0 2 | ------------------ 3 | * `Font Awesome` updated to version `5.15.1`. 4 | 5 | 2020-06-27 - 3.6.0 6 | ------------------ 7 | * `Font Awesome` updated to version `5.13.0`. 8 | 9 | 2019-09-20 - 3.5.0 10 | ------------------ 11 | * `Font Awesome` updated to version `5.11.0`. 12 | 13 | 2019-07-07 - 3.4.0 14 | ------------------ 15 | * `Font Awesome` updated to version `5.9.0`. 16 | 17 | 2019-02-12 - 3.3.1 18 | ------------------ 19 | * Update tests. 20 | 21 | 2019-02-12 - 3.3.0 22 | ------------------ 23 | * `Font Awesome` updated to version `5.7.1`. 24 | * Added new size constants. 25 | 26 | 2018-09-17 - 3.2.0 27 | ------------------ 28 | * `Font Awesome` updated to version `5.3.1`. 29 | * Add text stacking function. 30 | * Refactoring of asset bundles. 31 | * Remove bower-asset from `composer.json` 32 | * These classes are now deprecated: 33 | * `rmrevin\yii\fontawesome\AssetBundle` 34 | * `rmrevin\yii\fontawesome\cdn\AssetBundle` 35 | * Update readme. 36 | * Update tests. 37 | 38 | 2018-07-11 - 3.1.0 39 | ------------------ 40 | * Remove static font awesome bundle and add composer `bower-asset/font-awesome`. 41 | * `Font Awesome` updated to version `5.1`. 42 | 43 | 2018-04-01 - 3.0.0 44 | ------------------- 45 | * `Font Awesome` updated to version `5.0`. 46 | * These class are now deprecated: 47 | * `rmrevin\yii\fontawesome\FA` use `...\fontawesome\FAB`, `...\fontawesome\FAL`, `...\fontawesome\FAR`, `...\fontawesome\FAS`. 48 | * These deprecated properties and methods are now removed: 49 | * `rmrevin\yii\fontawesome\component\Icon::$defaultTag` 50 | * `rmrevin\yii\fontawesome\component\Icon::$tag` 51 | * `rmrevin\yii\fontawesome\component\Icon::tag()` 52 | * `rmrevin\yii\fontawesome\component\Icon::render()` 53 | * `rmrevin\yii\fontawesome\component\Stack::$defaultTag` 54 | * `rmrevin\yii\fontawesome\component\Stack::$tag` 55 | * `rmrevin\yii\fontawesome\component\Stack::tag()` 56 | * `rmrevin\yii\fontawesome\component\Stack::render()` 57 | * `rmrevin\yii\fontawesome\component\UnorderedList::$defaultTag` 58 | * `rmrevin\yii\fontawesome\component\UnorderedList::$tag` 59 | * `rmrevin\yii\fontawesome\component\UnorderedList::tag()` 60 | * `rmrevin\yii\fontawesome\component\UnorderedList::render()` 61 | * `rmrevin\yii\fontawesome\FA::getConstants()` 62 | 63 | 2017-01-11 - 2.17.1 64 | ------------------- 65 | * Downgrade minimum php to `5.4` 66 | 67 | 2016-10-25 - 2.17.0 68 | ------------------- 69 | * `Font Awesome` updated to version `4.7`. 70 | * Update minimum php to `5.5` 71 | * These deprecated classes are now removed: 72 | * `rmrevin\yii\fontawesome\CDNAssetBundle` 73 | * These deprecated methods are now removed: 74 | * `rmrevin\yii\fontawesome\component\Icon::ul` 75 | * `rmrevin\yii\fontawesome\component\Icon::fixed_width` 76 | * `rmrevin\yii\fontawesome\component\Icon::pull_left` 77 | * `rmrevin\yii\fontawesome\component\Icon::pull_right` 78 | * In method `rmrevin\yii\fontawesome\component\UnorderedList::item` changed interface (removed `$icon` param). 79 | * These directories are now deprecated: 80 | * `./assets` 81 | * These fields and methods are now deprecated: 82 | * `rmrevin\yii\fontawesome\component\Icon::$defaultTag` 83 | * `rmrevin\yii\fontawesome\component\Icon::$tag` 84 | * `rmrevin\yii\fontawesome\component\Icon::tag()` 85 | * `rmrevin\yii\fontawesome\component\Icon::render()` 86 | * `rmrevin\yii\fontawesome\component\Stack::$defaultTag` 87 | * `rmrevin\yii\fontawesome\component\Stack::$tag` 88 | * `rmrevin\yii\fontawesome\component\Stack::tag()` 89 | * `rmrevin\yii\fontawesome\component\Stack::render()` 90 | * `rmrevin\yii\fontawesome\component\UnorderedList::$defaultTag` 91 | * `rmrevin\yii\fontawesome\component\UnorderedList::$tag` 92 | * `rmrevin\yii\fontawesome\component\UnorderedList::tag()` 93 | * `rmrevin\yii\fontawesome\component\UnorderedList::render()` 94 | * Refactoring class `rmrevin\yii\fontawesome\component\UnorderedList`. 95 | 96 | 2016-08-31 - 2.16.1 97 | ------------------- 98 | * Fix options in li item. 99 | * Update readme. 100 | 101 | 2016-08-31 - 2.16.0 102 | ------------------- 103 | * Enh #22: Added FA:ul() method. 104 | * Refactoring. 105 | 106 | 2016-08-19 - 2.15.2 107 | ------------------- 108 | * Update icon name constants to version 4.6.3. 109 | 110 | 2016-05-29 - 2.15.1 111 | ------------------- 112 | * Added option to skip the icon. 113 | * Added option to change the order of icons in the stack. 114 | 115 | 2016-05-22 - 2.15.0 116 | ------------------- 117 | * Remove bower package. 118 | 119 | 2016-04-16 - 2.14.0 120 | ------------------- 121 | * `Font Awesome` updated to version `4.6`. 122 | 123 | 2015-11-26 - 2.13.0 124 | ------------------- 125 | * `Font Awesome` updated to version `4.5`. 126 | 127 | 2015-11-20 - 2.12.2 128 | ------------------- 129 | * Add shortcuts methods `i()` for `FA::icon()` and `FA::s()` for `FA::stack()` 130 | * Update readme 131 | 132 | 2015-11-09 - 2.12.1 133 | ------------------- 134 | * Variable `FA::$cssPrefix` transferred to the class `FontAwesome`. 135 | * Refactoring. 136 | * Update tests. 137 | 138 | 2015-08-15 - 2.12.0 139 | ------------------- 140 | * `Font Awesome` updated to version `4.4`. 141 | 142 | 2015-06-29 - 2.11.0 143 | ------------------- 144 | * Added the ability to change the tag for icons. 145 | 146 | 2015-06-23 - 2.10.3 147 | ------------------- 148 | * Change `cnd` url to cloudflare. 149 | 150 | 2015-06-19 - 2.10.2 151 | ------------------- 152 | * `CDNAssetBundle` is now deprecated. Use `rmrevin\yii\fontawesome\cdn\AssetBundle`. 153 | * Refactoring. 154 | 155 | 2015-05-09 - 2.10.1 156 | ------------------- 157 | * Fix bug in tests. 158 | 159 | 2015-05-09 - 2.10.0 160 | ------------------- 161 | * Add CDN asset bundle `CDNAssetBundle`. 162 | * Composer package `fortawesome/font-awesome` replaced on bower package `bower-asset/fontawesome`. 163 | * Adding warning messages in deprecated methods. 164 | * Add changelog. 165 | * Refactoring. 166 | * Update readme. 167 | 168 | 2015-04-28 - 2.9.2 169 | ------------------ 170 | * Method `icon()->fixed_width()` is deprecated. Use instead `icon()->fixedWidth()`. 171 | * Method `icon()->pull_left()` is deprecated. Use instead `icon()->pullLeft()`. 172 | * Method `icon()->pull_right()` is deprecated. Use instead `icon()->pullRight()`. 173 | * Updated tests. 174 | 175 | 2015-04-08 - 2.9.1 176 | ------------------ 177 | * Fix asset bundle publish bug on windows. 178 | 179 | 2015-03-31 - 2.9.0 180 | ------------------ 181 | * In asset bundle added `init` method for filtering publising assets. 182 | 183 | 2015-03-17 - 2.8.2 184 | ------------------ 185 | * Refactoring. 186 | 187 | 2015-03-16 - 2.8.1 188 | ------------------ 189 | * Update readme. 190 | 191 | 2015-03-16 - 2.8.0 192 | ------------------ 193 | * In class `FA` add static property `cssPrefix` for customizing css class. 194 | * Refactoring. 195 | * Update readme. 196 | 197 | 2015-02-08 - 2.7.1 198 | ------------------ 199 | * Update travisCI config. 200 | 201 | 2015-01-26 - 2.7.0 202 | ------------------ 203 | * `Font Awesome` updated to version `4.3`. 204 | * Update icons constants list. 205 | * Update readme. 206 | 207 | Until 2015-03-04 208 | ---------------- 209 | * Implementation of extension. 210 | -------------------------------------------------------------------------------- /tests/unit/fontawesome/MainTest.php: -------------------------------------------------------------------------------- 1 | assertInstanceOf('rmrevin\yii\fontawesome\FAR', new FAR()); 24 | $this->assertInstanceOf('rmrevin\yii\fontawesome\FontAwesome', new FAR()); 25 | 26 | $this->assertInstanceOf('rmrevin\yii\fontawesome\FontAwesome', new FontAwesome()); 27 | 28 | $Icon = FAR::icon('cog'); 29 | $this->assertInstanceOf('rmrevin\yii\fontawesome\component\Icon', $Icon); 30 | 31 | $Stack = FAR::stack(); 32 | $this->assertInstanceOf('rmrevin\yii\fontawesome\component\Stack', $Stack); 33 | } 34 | 35 | public function testStackOutput() 36 | { 37 | $this->assertEquals( 38 | (string)FAR::s(), 39 | '' 40 | ); 41 | 42 | $this->assertEquals( 43 | (string)FAR::stack(), 44 | '' 45 | ); 46 | 47 | $this->assertEquals( 48 | (string)FAR::stack(['tag' => 'div']), 49 | '
' 50 | ); 51 | 52 | $this->assertEquals( 53 | (string)FAR::stack() 54 | ->icon('cog'), 55 | '' 56 | ); 57 | 58 | $this->assertEquals( 59 | (string)FAR::stack() 60 | ->on('square-o'), 61 | '' 62 | ); 63 | 64 | $this->assertEquals( 65 | (string)FAR::stack() 66 | ->icon('cog') 67 | ->on('square-o'), 68 | '' 69 | ); 70 | 71 | $this->assertEquals( 72 | (string)FAR::stack(['data-role' => 'stack']) 73 | ->icon('cog', ['data-role' => 'icon',]) 74 | ->on('square-o', ['data-role' => 'background']), 75 | '' 76 | ); 77 | 78 | $this->assertEquals( 79 | (string)FAR::stack() 80 | ->icon(FAR::icon('cog')->spin()) 81 | ->on(FAR::icon('square-o')->size(FAR::SIZE_3X)), 82 | '' 83 | ); 84 | 85 | $this->assertEquals( 86 | (string)FAR::stack() 87 | ->icon(FAR::Icon('cog')->spin()) 88 | ->on(FAR::Icon('square-o')->size(FAR::SIZE_3X)), 89 | '' 90 | ); 91 | 92 | $this->assertNotEquals( 93 | (string)FAR::stack() 94 | ->icon((string)FAR::Icon('cog')->spin()) 95 | ->on((string)FAR::Icon('square-o')->size(FAR::SIZE_3X)), 96 | '' 97 | ); 98 | 99 | $this->assertEquals( 100 | (string)FAR::stack() 101 | ->text('hot') 102 | ->on('square-o'), 103 | 'hot' 104 | ); 105 | } 106 | 107 | public function testUlOutput() 108 | { 109 | $this->assertEquals( 110 | (string)FAR::ul(), 111 | '' 112 | ); 113 | 114 | $this->assertEquals( 115 | (string)FAR::ul() 116 | ->item('Gear'), 117 | "" 118 | ); 119 | 120 | $this->assertEquals( 121 | (string)FAR::ul() 122 | ->item('Gear', ['icon' => 'cog']), 123 | "" 124 | ); 125 | 126 | $this->assertEquals( 127 | (string)FAR::ul() 128 | ->item('Check', ['icon' => 'check']) 129 | ->item('Gear', ['icon' => 'cog']), 130 | "" 131 | ); 132 | 133 | $this->assertEquals( 134 | (string)FAR::ul(['tag' => 'ol']) 135 | ->item('Check', ['icon' => 'check']) 136 | ->item('Gear', ['icon' => 'cog']), 137 | "
    \n
  1. Check
  2. \n
  3. Gear
  4. \n
" 138 | ); 139 | 140 | $this->assertEquals( 141 | (string)FAR::ul() 142 | ->item('Check', ['icon' => 'check', 'class' => 'another-class']), 143 | "" 144 | ); 145 | } 146 | 147 | public function testAnotherPrefix() 148 | { 149 | FontAwesome::$basePrefix = 'fontawesome'; 150 | 151 | $this->assertEquals((string)FAR::icon('cog'), ''); 152 | $this->assertEquals((string)FAR::icon('cog', ['tag' => 'span']), ''); 153 | $this->assertEquals((string)FAR::icon('cog')->addCssClass('highlight'), ''); 154 | 155 | $this->assertEquals( 156 | (string)FAR::stack() 157 | ->icon(FAR::Icon('cog')->spin()) 158 | ->on(FAR::Icon('square-o')->size(FAR::SIZE_3X)), 159 | '' 160 | ); 161 | 162 | $this->assertEquals( 163 | (string)FAR::ul() 164 | ->item('Gear', ['icon' => 'cog']), 165 | "" 166 | ); 167 | 168 | FontAwesome::$basePrefix = 'fa'; 169 | } 170 | 171 | public function testIconOutput() 172 | { 173 | $this->assertEquals(FAR::i('cog'), ''); 174 | $this->assertEquals(FAR::icon('cog'), ''); 175 | $this->assertEquals(FAR::icon('cog', ['tag' => 'span']), ''); 176 | $this->assertEquals(FAR::icon('cog')->addCssClass('highlight'), ''); 177 | 178 | $this->assertEquals(FAR::icon('cog')->inverse(), ''); 179 | $this->assertEquals(FAR::icon('cog')->spin(), ''); 180 | $this->assertEquals(FAR::icon('cog')->pulse(), ''); 181 | $this->assertEquals(FAR::icon('cog')->fixedWidth(), ''); 182 | $this->assertEquals(FAR::icon('cog')->li(), ''); 183 | $this->assertEquals(FAR::icon('cog')->border(), ''); 184 | $this->assertEquals(FAR::icon('cog')->pullLeft(), ''); 185 | $this->assertEquals(FAR::icon('cog')->pullRight(), ''); 186 | 187 | $this->assertEquals(FAR::icon('cog')->size(FAR::SIZE_2X), ''); 188 | $this->assertEquals(FAR::icon('cog')->size(FAR::SIZE_3X), ''); 189 | $this->assertEquals(FAR::icon('cog')->size(FAR::SIZE_4X), ''); 190 | $this->assertEquals(FAR::icon('cog')->size(FAR::SIZE_5X), ''); 191 | $this->assertEquals(FAR::icon('cog')->size(FAR::SIZE_LARGE), ''); 192 | 193 | $this->assertEquals(FAR::icon('cog')->rotate(FAR::ROTATE_90), ''); 194 | $this->assertEquals(FAR::icon('cog')->rotate(FAR::ROTATE_180), ''); 195 | $this->assertEquals(FAR::icon('cog')->rotate(FAR::ROTATE_270), ''); 196 | 197 | $this->assertEquals(FAR::icon('cog')->flip(FAR::FLIP_HORIZONTAL), ''); 198 | $this->assertEquals(FAR::icon('cog')->flip(FAR::FLIP_VERTICAL), ''); 199 | } 200 | 201 | public function testIconSizeException() 202 | { 203 | $this->expectExceptionMessage( 204 | 'FontAwesome::size() - invalid value. Use one of the constants: lg, sm, xs, 2x, 3x, 4x, 5x, 6x, 7x, 8x, 9x, 10x.' 205 | ); 206 | 207 | FAR::icon('cog')->size('badvalue'); 208 | } 209 | 210 | public function testIconRotateException() 211 | { 212 | $this->expectExceptionMessage( 213 | 'FontAwesome::rotate() - invalid value. Use one of the constants: 90, 180, 270.' 214 | ); 215 | 216 | FAR::icon('cog')->rotate('badvalue'); 217 | } 218 | 219 | public function testIconFlipException() 220 | { 221 | $this->expectExceptionMessage( 222 | 'FontAwesome::flip() - invalid value. Use one of the constants: horizontal, vertical.' 223 | ); 224 | 225 | FAR::icon('cog')->flip('badvalue'); 226 | } 227 | 228 | public function testIconAddCssClassCondition() 229 | { 230 | $this->assertEquals(FAR::$cssPrefix, 'far'); 231 | $this->assertEquals((string)FAR::icon('cog')->addCssClass('highlight', true), ''); 232 | 233 | $this->expectExceptionMessage('Condition is false'); 234 | 235 | FAR::icon('cog')->addCssClass('highlight', false, true); 236 | } 237 | } 238 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Yii 2 [Font Awesome](http://fortawesome.github.io/Font-Awesome/) Asset Bundle 2 | =============================== 3 | 4 | This extension provides a assets bundle with [Font Awesome](https://fontawesome.com/) 5 | for [Yii framework 2.0](http://www.yiiframework.com/) applications and helper to use icons. 6 | 7 | For license information check the [LICENSE](https://github.com/rmrevin/yii2-fontawesome/blob/master/LICENSE)-file. 8 | 9 | [![License](https://poser.pugx.org/rmrevin/yii2-fontawesome/license.svg)](https://packagist.org/packages/rmrevin/yii2-fontawesome) 10 | [![Latest Stable Version](https://poser.pugx.org/rmrevin/yii2-fontawesome/v/stable.svg)](https://packagist.org/packages/rmrevin/yii2-fontawesome) 11 | [![Latest Unstable Version](https://poser.pugx.org/rmrevin/yii2-fontawesome/v/unstable.svg)](https://packagist.org/packages/rmrevin/yii2-fontawesome) 12 | [![Total Downloads](https://poser.pugx.org/rmrevin/yii2-fontawesome/downloads.svg)](https://packagist.org/packages/rmrevin/yii2-fontawesome) 13 | 14 | Code Status 15 | ----------- 16 | [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/rmrevin/yii2-fontawesome/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/rmrevin/yii2-fontawesome/?branch=master) 17 | [![Code Coverage](https://scrutinizer-ci.com/g/rmrevin/yii2-fontawesome/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/rmrevin/yii2-fontawesome/?branch=master) 18 | [![Travis CI Build Status](https://travis-ci.org/rmrevin/yii2-fontawesome.svg)](https://travis-ci.org/rmrevin/yii2-fontawesome) 19 | [![Dependency Status](https://www.versioneye.com/user/projects/54119b799e16229fe00000da/badge.svg)](https://www.versioneye.com/user/projects/54119b799e16229fe00000da) 20 | 21 | Support 22 | ------- 23 | * [GutHub issues](https://github.com/rmrevin/yii2-fontawesome/issues) 24 | * [Public chat](https://gitter.im/rmrevin/support) 25 | 26 | Fontawesome version 27 | ------------------- 28 | | Version of font-awesome | Version of extension | 29 | | ---:|:--- | 30 | | 4.* | ~2.17 | 31 | | 5.* | ~3.0 | 32 | 33 | Update to `3.2` 34 | --------------- 35 | 36 | Be careful in version 3.2 `rmrevin\yii\fontawesome\AssetBundle` package use cdn by default. More in the [changelog](https://github.com/rmrevin/yii2-fontawesome/blob/master/CHANGELOG.md). 37 | 38 | Update to `3.0` 39 | --------------- 40 | 41 | Be careful in version 3.0 deprecated methods were removed. More in the [changelog](https://github.com/rmrevin/yii2-fontawesome/blob/master/CHANGELOG.md). 42 | 43 | Update to `2.17` 44 | ---------------- 45 | 46 | Be careful in version 2.17 deprecated methods were removed. More in the [changelog](https://github.com/rmrevin/yii2-fontawesome/blob/2.x/CHANGELOG.md). 47 | 48 | Installation 49 | ------------ 50 | 51 | The preferred way to install this extension is through [composer](https://getcomposer.org/). 52 | 53 | Either run 54 | 55 | ```bash 56 | composer require "rmrevin/yii2-fontawesome:~3.5" 57 | ``` 58 | 59 | or add 60 | 61 | ``` 62 | "rmrevin/yii2-fontawesome": "~3.5", 63 | ``` 64 | 65 | to the `require` section of your `composer.json` file. 66 | 67 | Usage with fa pro version 68 | ------------------------- 69 | 70 | ### CDN 71 | Register your domain here - https://fontawesome.com/how-to-use/on-the-web/setup/getting-started 72 | 73 | Add `CdnProAssetBundle` as depends of your app asset bundle: 74 | ```php 75 | class AppAsset extends AssetBundle 76 | { 77 | // ... 78 | 79 | public $depends = [ 80 | // ... 81 | 'rmrevin\yii\fontawesome\CdnProAssetBundle' 82 | ]; 83 | } 84 | 85 | ``` 86 | 87 | Or inject `CdnProAssetBundle` in your view: 88 | 89 | ```php 90 | \rmrevin\yii\fontawesome\CdnProAssetBundle::register($this); 91 | ``` 92 | 93 | ### NPM 94 | Install npm package of font: 95 | ``` 96 | npm install @fortawesome/fontawesome-pro 97 | ``` 98 | or 99 | ``` 100 | yarn add @fortawesome/fontawesome-pro 101 | ``` 102 | 103 | And add `NpmProAssetBundle` as depends of your app asset bundle: 104 | ```php 105 | class AppAsset extends AssetBundle 106 | { 107 | // ... 108 | 109 | public $depends = [ 110 | // ... 111 | 'rmrevin\yii\fontawesome\NpmProAssetBundle' 112 | ]; 113 | } 114 | 115 | ``` 116 | 117 | Or inject `NpmProAssetBundle` in your view: 118 | 119 | ```php 120 | rmrevin\yii\fontawesome\NpmProAssetBundle::register($this); 121 | ``` 122 | 123 | ### Optional 124 | 125 | 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`. 126 | 127 | ``` 128 | "replace": { 129 | "fortawesome/font-awesome": "*" 130 | }, 131 | ``` 132 | 133 | Usage with fa free version 134 | ------------------------- 135 | 136 | ### CDN 137 | Add `CdnFreeAssetBundle` as depends of your app asset bundle: 138 | ```php 139 | class AppAsset extends AssetBundle 140 | { 141 | // ... 142 | 143 | public $depends = [ 144 | // ... 145 | 'rmrevin\yii\fontawesome\CdnFreeAssetBundle' 146 | ]; 147 | } 148 | 149 | ``` 150 | 151 | Or inject `CdnFreeAssetBundle` in your view: 152 | 153 | ```php 154 | rmrevin\yii\fontawesome\CdnFreeAssetBundle::register($this); 155 | ``` 156 | 157 | # Composer 158 | 159 | Free version of package `fortawesome/font-awesome` already installed in vendor. 160 | 161 | Add `NpmFreeAssetBundle` as depends of your app asset bundle: 162 | ```php 163 | class AppAsset extends AssetBundle 164 | { 165 | // ... 166 | 167 | public $depends = [ 168 | // ... 169 | 'rmrevin\yii\fontawesome\NpmFreeAssetBundle' 170 | ]; 171 | } 172 | 173 | ``` 174 | 175 | Or inject `NpmFreeAssetBundle` in your view: 176 | 177 | ```php 178 | rmrevin\yii\fontawesome\NpmFreeAssetBundle::register($this); 179 | ``` 180 | 181 | Class reference 182 | --------------- 183 | 184 | Namespace: `rmrevin\yii\fontawesome`; 185 | 186 | ### Class `FAB`, `FAL`, `FAR`, `FAS` or `FontAwesome` 187 | 188 | * `static FAR::icon($name, $options=[])` - Creates an [`component\Icon`](#class-componenticon) that can be used to FontAwesome html icon 189 | * `$name` - name of icon in font awesome set. 190 | * `$options` - additional attributes for `i.fa` html tag. 191 | * `static FAR::stack($name, $options=[])` - Creates an [`component\Stack`](#class-componentstack) that can be used to FontAwesome html icon 192 | * `$options` - additional attributes for `span.fa-stack` html tag. 193 | 194 | ### Class `component\Icon` 195 | 196 | * `(string)$Icon` - render icon 197 | * `$Icon->addCssClass($value)` - add to html tag css class in `$value` 198 | * `$value` - name of css class 199 | * `$Icon->inverse()` - add to html tag css class `fa-inverse` 200 | * `$Icon->spin()` - add to html tag css class `fa-spin` 201 | * `$Icon->fixedWidth()` - add to html tag css class `fa-fw` 202 | * `$Icon->ul()` - add to html tag css class `fa-ul` 203 | * `$Icon->li()` - add to html tag css class `fa-li` 204 | * `$Icon->border()` - add to html tag css class `fa-border` 205 | * `$Icon->pullLeft()` - add to html tag css class `pull-left` 206 | * `$Icon->pullRight()` - add to html tag css class `pull-right` 207 | * `$Icon->size($value)` - add to html tag css class with size 208 | * `$value` - size value (variants: `FA::SIZE_LARGE`, `FA::SIZE_2X`, `FA::SIZE_3X`, `FA::SIZE_4X`, `FA::SIZE_5X`) 209 | * `$Icon->rotate($value)` - add to html tag css class with rotate 210 | * `$value` - rotate value (variants: `FA::ROTATE_90`, `FA::ROTATE_180`, `FA::ROTATE_270`) 211 | * `$Icon->flip($value)` - add to html tag css class with rotate 212 | * `$value` - flip value (variants: `FA::FLIP_HORIZONTAL`, `FA::FLIP_VERTICAL`) 213 | 214 | ### Class `component\Stack` 215 | 216 | * `(string)$Stack` - render icon stack 217 | * `$Stack->icon($icon, $options=[])` - set icon for stack 218 | * `$icon` - name of icon or `component\Icon` object 219 | * `$options` - additional attributes for icon html tag. 220 | * `$Stack->icon($icon, $options=[])` - set background icon for stack 221 | * `$icon` - name of icon or `component\Icon` object 222 | * `$options` - additional attributes for icon html tag. 223 | 224 | Helper examples 225 | --------------- 226 | 227 | ```php 228 | use rmrevin\yii\fontawesome\FAS; 229 | // or (only in pro version https://fontawesome.com/pro) 230 | // use rmrevin\yii\fontawesome\FAR; 231 | // use rmrevin\yii\fontawesome\FAL; 232 | // use rmrevin\yii\fontawesome\FAB; 233 | 234 | // normal use 235 | echo FAS::icon('home'); // 236 | 237 | // shortcut 238 | echo FAS::i('home'); // 239 | 240 | // icon with additional attributes 241 | echo FAS::icon( 242 | 'arrow-left', 243 | ['class' => 'big', 'data-role' => 'arrow'] 244 | ); // 245 | 246 | // icon in button 247 | echo Html::submitButton( 248 | Yii::t('app', '{icon} Save', ['icon' => FAS::icon('check')]) 249 | ); // 250 | 251 | // icon with additional methods 252 | echo FAS::icon('cog')->inverse(); // 253 | echo FAS::icon('cog')->spin(); // 254 | echo FAS::icon('cog')->fixedWidth(); // 255 | echo FAS::icon('cog')->li(); // 256 | echo FAS::icon('cog')->border(); // 257 | echo FAS::icon('cog')->pullLeft(); // 258 | echo FAS::icon('cog')->pullRight(); // 259 | 260 | // icon size 261 | echo FAS::icon('cog')->size(FAS::SIZE_3X); 262 | // values: FAS::SIZE_LARGE, FAS::SIZE_2X, FAS::SIZE_3X, FAS::SIZE_4X, FAS::SIZE_5X 263 | // 264 | 265 | // icon rotate 266 | echo FAS::icon('cog')->rotate(FAS::ROTATE_90); 267 | // values: FAS::ROTATE_90, FAS::ROTATE_180, FAS::ROTATE_180 268 | // 269 | 270 | // icon flip 271 | echo FAS::icon('cog')->flip(FAS::FLIP_VERTICAL); 272 | // values: FAS::FLIP_HORIZONTAL, FAS::FLIP_VERTICAL 273 | // 274 | 275 | // icon with multiple methods 276 | echo FAS::icon('cog') 277 | ->spin() 278 | ->fixedWidth() 279 | ->pullLeft() 280 | ->size(FAS::SIZE_LARGE); 281 | // 282 | 283 | // icons stack 284 | echo FAS::stack() 285 | ->icon('twitter') 286 | ->on('square-o'); 287 | // 288 | // 289 | // 290 | // 291 | 292 | // icons stack with additional attributes 293 | echo FAS::stack(['data-role' => 'stacked-icon']) 294 | ->on(FAS::Icon('square')->inverse()) 295 | ->icon(FAS::Icon('cog')->spin()); 296 | // 297 | // 298 | // 299 | // 300 | 301 | // Stacking text and icons 302 | echo FAS::stack() 303 | ->on(FAS::Icon('square')) 304 | ->text('1'); 305 | // 306 | // 307 | // 1 308 | // 309 | 310 | // Stacking text and icons with options 311 | echo FAS::stack() 312 | ->on(FAS::Icon('square')) 313 | ->text('1', ['tag'=>'strong', 'class'=>'stacked-text']); 314 | // 315 | // 316 | // 1 317 | // 318 | // Now you can add some css for vertical text positioning: 319 | .stacked-text { margin-top: .3em; } 320 | 321 | // unordered list icons 322 | echo FAS::ul(['data-role' => 'unordered-list']) 323 | ->item('Bullet item', ['icon' => 'circle']) 324 | ->item('Checked item', ['icon' => 'check']); 325 | //