inteve / icons
Icons loader for web-apps
Fund package maintenance!
Other
Requires
- php: 7.4 - 8.2
- nette/utils: ^2.4 || ^3.0 || ^4.0
- phig/phig: ^1.0
Requires (Dev)
- nette/tester: ^2.4
This package is auto-updated.
Last update: 2024-10-19 08:59:13 UTC
README
Icons loader for web-apps.
Installation
Download a latest package or use Composer:
composer require inteve/icons
Inteve\Icons requires PHP 7.4.0 or later.
Usage
This library is implementation of PHIG's HtmlIcons
interface.
InlineSvgIcons
$icons = new \Inteve\Icons\InlineSvgIcons($iconsDirectory); echo $icons->get('my-icon'); // finds file "$iconsDirectory/my-icon.svg", prints <svg ...>...</svg>
ImgIcons
$icons = new \Inteve\Icons\ImgIcons($publicUrlPath, $fileExtension, $htmlClass = 'icon'); echo $icons->get('my-icon'); // prints <img src="/path/to/my-icon.ext" class="icon" alt=""> echo $icons->get('my-icon@small'); // prints <img src="/path/to/my-icon.ext" class="icon icon--small" alt="">
InlineStyleIcons
$icons = new \Inteve\Icons\InlineStyleIcons($publicUrlPath, $fileExtension, $htmlClass = 'icon', $tagName = 'i'); echo $icons->get('my-icon'); // prints <i class="icon" style="background-image:url(/path/to/my-icon.ext)"></i> echo $icons->get('my-icon@small'); // prints <i class="icon icon--small" style="background-image:url(/path/to/my-icon.ext)"></i>
WrappedIcons
$svgIcons = new \Inteve\Icons\InlineSvgIcons($iconsDirectory); $icons = new \Inteve\Icons\WrappedIcons($svgIcons, $className = 'icon', $tagName = 'i'); echo $icons->get('my-icon'); // prints <i class="icon"><svg ...>...</svg></i> echo $icons->get('my-icon@small'); // prints <i class="icon icon-small"><svg ...>...</svg></i>
PrefixedIcons
$icons = new \Inteve\Icons\PrefixedIcons( icons: [ 'legacy' => new ImgIcons($publicUrlPath, $fileExtension), 'bootstrap' => new \Inteve\Icons\InlineSvgIcons($bootstrapIconsDirectory), ], defaultIcons: new \Inteve\Icons\InlineSvgIcons($iconsDirectory) ); echo $icons->get('my-icon'); // prints <svg ...>...</svg> echo $icons->get('legacy/my-icon'); // prints <img src="/path/to/my-icon.ext" class="icon" alt=""> echo $icons->get('bootstrap/my-icon'); // prints <svg ...>...</svg>
License: New BSD License
Author: Jan Pecha, https://www.janpecha.cz/