Skip to content

Commit

Permalink
icons
Browse files Browse the repository at this point in the history
  • Loading branch information
smnandre committed Nov 21, 2024
1 parent 8912f98 commit 40932f3
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 45 deletions.
2 changes: 1 addition & 1 deletion src/Icons/src/IconRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
'<svg xmlns="http://www.w3.org/2000/svg" %s>%s</svg>',
$icon->htmlAttributes(),
Expand Down
27 changes: 9 additions & 18 deletions src/Icons/src/Twig/UXIconRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand All @@ -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;
}
}

Expand All @@ -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;
}
}

Expand Down
3 changes: 3 additions & 0 deletions ux.symfony.com/config/packages/ux_icons.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ ux_icons:
class: 'Icon'

icon_sets:

lu: # Lucide icons
alias: 'lucide'

# FeatureBox icons
feature:
Expand Down
86 changes: 60 additions & 26 deletions ux.symfony.com/templates/main/homepage.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@
</div>
</div>
</div>

{% set use_sprite = false %}

<div class="container-fluid container-xxl px-4 py-4 px-md-5 py-md-5">
<h2 class="ubuntu">Install it</h2>
<h2 class="ubuntu">Install it: {{ use_sprite ? 'SPRITE' : ' NO' }}</h2>

<div class="arrow mb-3 d-none d-md-block"></div>


<div class="row-cols-auto">

{% set use_sprite = true %}

{% if use_sprite %}
{{ ux_icon_sprite([
'lucide:circle-play',
Expand All @@ -52,31 +52,65 @@
}
</style>

{% for i in 0..50 %}
<div class="row row-cols-auto border border-black p-2">
<div>
{{ ux_icon('lucide:circle-play', {foo: use_sprite}) }}
</div>
<div>
{{ ux_icon('lucide:circle-pause', {foo: use_sprite}) }}
</div>
<div>
{{ ux_icon('solar:eye-outline', {foo: use_sprite}) }}
</div>
<div>
{{ ux_icon('fluent:share-48-regular', {foo: use_sprite}) }}
composer require symfony/stimulus-bundle
</div>
<div>
{{ ux_icon('arcticons:settings', {foo: use_sprite}) }}
symfony/asset-mapper

{% if use_sprite %}
{% for i in 0..50 %}
<div class="row row-cols-auto border border-black p-2">
<div>
{{ ux_icon('lucide:circle-play', {foo: use_sprite}) }}
</div>
<div>
{{ ux_icon('lucide:circle-pause', {foo: use_sprite}) }}
{{ ux_icon_symbol('lucide:circle-pause', {foo: use_sprite}) }}
{{ ux_icon_sprite([
'lu:square',
'lu:circle',
]) }}
</div>
<div>
{{ ux_icon('solar:eye-outline', {foo: use_sprite}) }}
</div>
<div>
{{ ux_icon('fluent:share-48-regular', {foo: use_sprite}) }}
composer require symfony/stimulus-bundle
</div>
<div>
{{ ux_icon('arcticons:settings', {foo: use_sprite}) }}
symfony/asset-mapper
</div>
<div>
{{ ux_icon('grommet-icons:validate', {foo: use_sprite}) }}
symfony/stimulus-bundle
</div>
</div>
<div>
{{ ux_icon('grommet-icons:validate', {foo: use_sprite}) }}
symfony/stimulus-bundle
{% endfor %}
{% else %}
{% for i in 0..50 %}
<div class="row row-cols-auto border border-black p-2">
<div>
{{ ux_icon('lucide:circle-play', {use: true}) }}
</div>
<div>
{{ ux_icon('lucide:circle-pause', {foo: use_sprite}) }}
</div>
<div>
{{ ux_icon('solar:eye-outline', {foo: use_sprite}) }}
</div>
<div>
{{ ux_icon('fluent:share-48-regular', {foo: use_sprite}) }}
composer require symfony/stimulus-bundle
</div>
<div>
{{ ux_icon('arcticons:settings', {foo: use_sprite}) }}
symfony/asset-mapper
</div>
<div>
{{ ux_icon('grommet-icons:validate', {foo: use_sprite}) }}
symfony/stimulus-bundle
</div>
</div>
</div>
{% endfor %}
{% endfor %}
{% endif %}


{# <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" visibility="hidden">#}
Expand Down

0 comments on commit 40932f3

Please sign in to comment.