From 40932f3d22f6dfc675fea39bb8665db2239163ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Andr=C3=A9?= Date: Thu, 21 Nov 2024 03:00:47 +0100 Subject: [PATCH] icons --- src/Icons/src/IconRenderer.php | 2 +- src/Icons/src/Twig/UXIconRuntime.php | 27 ++---- ux.symfony.com/config/packages/ux_icons.yaml | 3 + .../templates/main/homepage.html.twig | 86 +++++++++++++------ 4 files changed, 73 insertions(+), 45 deletions(-) diff --git a/src/Icons/src/IconRenderer.php b/src/Icons/src/IconRenderer.php index c455fbf5948..11d9d03e74e 100644 --- a/src/Icons/src/IconRenderer.php +++ b/src/Icons/src/IconRenderer.php @@ -57,7 +57,7 @@ public function renderIcon(string $name, array $attributes = []): string $icon = $preRenderer($icon); } - if ($attributes['foo'] ?? false) { + if ($attributes['use'] ?? false) { return \sprintf( '%s', $icon->htmlAttributes(), diff --git a/src/Icons/src/Twig/UXIconRuntime.php b/src/Icons/src/Twig/UXIconRuntime.php index 46a0c21af7c..841a66cd6b0 100644 --- a/src/Icons/src/Twig/UXIconRuntime.php +++ b/src/Icons/src/Twig/UXIconRuntime.php @@ -38,13 +38,10 @@ public function renderIcon(string $name, array $attributes = []): string try { return $this->iconRenderer->renderIcon($name, $attributes); } catch (IconNotFoundException $e) { - if ($this->ignoreNotFound) { - $this->logger?->warning($e->getMessage()); - - return ''; + $this->logger?->warning($e->getMessage()); + if (!$this->ignoreNotFound) { + throw $e; } - - throw $e; } } @@ -53,13 +50,10 @@ public function renderSprite(array $names): string try { return $this->iconRenderer->renderSprite($names); } catch (IconNotFoundException $e) { - if ($this->ignoreNotFound) { - $this->logger?->warning($e->getMessage()); - - return ''; + $this->logger?->warning($e->getMessage()); + if (!$this->ignoreNotFound) { + throw $e; } - - throw $e; } } @@ -68,13 +62,10 @@ public function renderSymbol(string $name): string try { return $this->iconRenderer->renderSymbol($name); } catch (IconNotFoundException $e) { - if ($this->ignoreNotFound) { - $this->logger?->warning($e->getMessage()); - - return ''; + $this->logger?->warning($e->getMessage()); + if (!$this->ignoreNotFound) { + throw $e; } - - throw $e; } } diff --git a/ux.symfony.com/config/packages/ux_icons.yaml b/ux.symfony.com/config/packages/ux_icons.yaml index 43ecf5c476d..764ff37494d 100644 --- a/ux.symfony.com/config/packages/ux_icons.yaml +++ b/ux.symfony.com/config/packages/ux_icons.yaml @@ -3,6 +3,9 @@ ux_icons: class: 'Icon' icon_sets: + + lu: # Lucide icons + alias: 'lucide' # FeatureBox icons feature: diff --git a/ux.symfony.com/templates/main/homepage.html.twig b/ux.symfony.com/templates/main/homepage.html.twig index 70b3c289be5..a553eb1d967 100644 --- a/ux.symfony.com/templates/main/homepage.html.twig +++ b/ux.symfony.com/templates/main/homepage.html.twig @@ -23,17 +23,17 @@ + +{% set use_sprite = false %}
-

Install it

+

Install it: {{ use_sprite ? 'SPRITE' : ' NO' }}

- {% set use_sprite = true %} - {% if use_sprite %} {{ ux_icon_sprite([ 'lucide:circle-play', @@ -52,31 +52,65 @@ } - {% for i in 0..50 %} -
-
- {{ ux_icon('lucide:circle-play', {foo: use_sprite}) }} -
-
- {{ ux_icon('lucide:circle-pause', {foo: use_sprite}) }} -
-
- {{ ux_icon('solar:eye-outline', {foo: use_sprite}) }} -
-
- {{ ux_icon('fluent:share-48-regular', {foo: use_sprite}) }} - composer require symfony/stimulus-bundle -
-
- {{ ux_icon('arcticons:settings', {foo: use_sprite}) }} - symfony/asset-mapper + + {% if use_sprite %} + {% for i in 0..50 %} +
+
+ {{ ux_icon('lucide:circle-play', {foo: use_sprite}) }} +
+
+ {{ ux_icon('lucide:circle-pause', {foo: use_sprite}) }} + {{ ux_icon_symbol('lucide:circle-pause', {foo: use_sprite}) }} + {{ ux_icon_sprite([ + 'lu:square', + 'lu:circle', + ]) }} +
+
+ {{ ux_icon('solar:eye-outline', {foo: use_sprite}) }} +
+
+ {{ ux_icon('fluent:share-48-regular', {foo: use_sprite}) }} + composer require symfony/stimulus-bundle +
+
+ {{ ux_icon('arcticons:settings', {foo: use_sprite}) }} + symfony/asset-mapper +
+
+ {{ ux_icon('grommet-icons:validate', {foo: use_sprite}) }} + symfony/stimulus-bundle +
-
- {{ ux_icon('grommet-icons:validate', {foo: use_sprite}) }} - symfony/stimulus-bundle + {% endfor %} + {% else %} + {% for i in 0..50 %} +
+
+ {{ ux_icon('lucide:circle-play', {use: true}) }} +
+
+ {{ ux_icon('lucide:circle-pause', {foo: use_sprite}) }} +
+
+ {{ ux_icon('solar:eye-outline', {foo: use_sprite}) }} +
+
+ {{ ux_icon('fluent:share-48-regular', {foo: use_sprite}) }} + composer require symfony/stimulus-bundle +
+
+ {{ ux_icon('arcticons:settings', {foo: use_sprite}) }} + symfony/asset-mapper +
+
+ {{ ux_icon('grommet-icons:validate', {foo: use_sprite}) }} + symfony/stimulus-bundle +
-
- {% endfor %} + {% endfor %} + {% endif %} {# #}