Skip to content

Commit

Permalink
Readme: updated
Browse files Browse the repository at this point in the history
  • Loading branch information
janpecha committed Dec 7, 2023
1 parent 106ee5c commit 205e60f
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,58 @@ Inteve\Icons requires PHP 7.4.0 or later.

This library is implementation of [PHIG's](https://github.com/phig-org/phig) `HtmlIcons` interface.


### InlineSvgIcons

``` php
$icons = new \Inteve\Icons\InlineSvgIcons($iconsDirectory)
$icons = new \Inteve\Icons\InlineSvgIcons($iconsDirectory);
echo $icons->get('my-icon'); // finds file "$iconsDirectory/my-icon.svg", prints <svg ...>...</svg>
```


### ImgIcons

``` php
$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

``` php
$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

``` php
$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

``` php
$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](license.md)
Expand Down

0 comments on commit 205e60f

Please sign in to comment.