Skip to content

Commit

Permalink
Icon 2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Awilum committed Jan 7, 2021
1 parent deab68b commit 01ce6a7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<a name="2.0.1"></a>
# [2.0.1](https://github.com/flextype-plugins/icon/compare/v2.0.0...v2.0.1) (2021-01-07)

### Bug Fixes

* **core** fix possible issue with null icon name.

<a name="2.0.0"></a>
# [2.0.0](https://github.com/flextype-plugins/icon/compare/v1.7.0...v2.0.0) (2021-01-03)
# [2.0.0](https://github.com/flextype-plugins/icon/compare/v1.7.0...v2.0.0) (2021-01-07)

### Features

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Global function `icon()`
/**
* Get SVG icon from specific icons set.
*
* @param string $name Icon name.
* @param string|null $name Icon name.
* @param string|null $set Icon set:
* - tabler
* - bootstrap
Expand All @@ -54,7 +54,7 @@ Global function `icon()`
*
* @return string
*/
function icon(string $name, ?string $set = 'fontawesome|solid', ?string $class = null): string
function icon(?string $name = null, ?string $set = 'fontawesome|solid', ?string $class = null): string
```

### Usage
Expand Down
8 changes: 4 additions & 4 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* Get SVG icon from specific icons set.
*
* @param string $name Icon name.
* @param string|null $name Icon name.
* @param string|null $set Icon set:
* - tabler
* - bootstrap
Expand All @@ -28,7 +28,7 @@
*
* @return string
*/
function icon(string $name, ?string $set = 'fontawesome|solid', ?string $class = null): string
function icon(?string $name = null, ?string $set = 'fontawesome|solid', ?string $class = null): string
{
switch ($set) {
case 'tabler':
Expand Down Expand Up @@ -64,12 +64,12 @@ function icon(string $name, ?string $set = 'fontawesome|solid', ?string $class =

// Shortcode: [icon name="apple" set="fontawesome|brands" class=""]
flextype('parsers')->shortcode()->addHandler('icon', function (ShortcodeInterface $s) {
return icon($s->getParameter('name'),
return icon(! is_null($s->getParameter('name')) ? $s->getParameter('name') : null,
! is_null($s->getParameter('set')) ? $s->getParameter('set') : null,
! is_null($s->getParameter('class')) ? $s->getParameter('class') : '');
});

// Twig: {{ icon('apple', 'fontawesome|brands', '') }}
flextype('twig')->addFunction(new TwigFunction('icon', function (string $name, ?string $set = 'fontawesome|solid', ?string $class = null) {
flextype('twig')->addFunction(new TwigFunction('icon', function (?string $name = null, ?string $set = 'fontawesome|solid', ?string $class = null) {
return icon($name, $set, $class);
}, ['is_safe' => ['html']]));

0 comments on commit 01ce6a7

Please sign in to comment.