Skip to content

Commit 61d3b02

Browse files
committed
minor #2164 [Site] Complete migration to UX Icons (smnandre)
This PR was squashed before being merged into the 2.x branch. Discussion ---------- [Site] Complete migration to UX Icons Remove last usage of the custom Twig icon component. When the PR about iconset config is merged, we can remove the hard-coded "Icon" and the decorating renderer Commits ------- d3000fb [Site] Complete migration to UX Icons
2 parents 7674015 + d3000fb commit 61d3b02

33 files changed

+101
-70
lines changed

ux.symfony.com/cookbook/component_architecture.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ In Symfony, you can have an `Alert` component, for example, with the following t
3333

3434
```twig
3535
<div class="alert alert-{{ type }}">
36-
<twig:Icon name="{{ icon }}" />
36+
<twig:ux:icon name="{{ icon }}" />
3737
{{ message }}
3838
</div>
3939
```
@@ -43,9 +43,9 @@ Or you can compose with the following syntax:
4343

4444
```twig
4545
<twig:Card>
46-
<twig:Icon name="info"/>
46+
<twig:ux:icon name="info"/>
4747
<twig:Button>
48-
<twig:Icon name="close" />
48+
<twig:ux:icon name="close" />
4949
</twig:Button>
5050
</twig:Card>
5151
```
@@ -79,7 +79,7 @@ We have the following template:
7979
{% props type, icon, message %}
8080
8181
<div class="alert alert-{{ type }}">
82-
<twig:Icon name="{{ icon }}" />
82+
<twig:ux:icon name="{{ icon }}" />
8383
{{ message }}
8484
</div>
8585
```
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace App\UX;
13+
14+
use Symfony\Component\DependencyInjection\Attribute\AsDecorator;
15+
use Symfony\Component\DependencyInjection\Attribute\AutowireDecorated;
16+
use Symfony\UX\Icons\IconRendererInterface;
17+
18+
#[AsDecorator(decorates: '.ux_icons.icon_renderer')]
19+
class IconRenderer implements IconRendererInterface
20+
{
21+
public function __construct(
22+
#[AutowireDecorated]
23+
private IconRendererInterface $inner,
24+
) {
25+
}
26+
27+
public function renderIcon(string $name, array $attributes = []): string
28+
{
29+
return $this->inner->renderIcon($name, [
30+
...$attributes,
31+
'class' => \sprintf('%s %s', 'Icon', $attributes['class'] ?? ''),
32+
]);
33+
}
34+
}

ux.symfony.com/templates/_banner.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</div>
99
<div class="BannerAction">
1010
<a href="https://gofund.me/44ecdba2" class="BannerButton" rel="external">
11-
<twig:Icon name="heart" aria-hidden="true"/>
11+
<twig:ux:icon name="heart" aria-hidden="true"/>
1212
Donate
1313
</a>
1414
</div>

ux.symfony.com/templates/_footer.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
aria-label="Symfony UX on GitHub"
99
class="order-lg-1"
1010
>
11-
<twig:Icon name="github"/>
11+
<twig:ux:icon name="github"/>
1212
</a>
1313
<a href="{{ url('app_documentation') }}" style="font-size: 11px; text-transform: uppercase;" class="order-lg-0">Docs</a>
1414
<a href="{{ url('app_changelog') }}" style="font-size: 11px; text-transform: uppercase;" class="order-lg-0">Changelog</a>
@@ -17,7 +17,7 @@
1717
style="font-size: 1.5rem;"
1818
aria-label="Symfony website"
1919
>
20-
<twig:Icon name="symfony"/>
20+
<twig:ux:icon name="symfony"/>
2121
</a>
2222
</p>
2323
</div>

ux.symfony.com/templates/_header.html.twig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
data-action="ux-header#toggleMenu"
1414
aria-label="Toggle menu"
1515
>
16-
<twig:Icon name="menu"/>
16+
<twig:ux:icon name="menu"/>
1717
</button>
1818
<twig:ThemeSwitcher class="AppNav_item AppNav_item--icon" aria-label="Switch dark/light mode"/>
1919
<a
@@ -22,15 +22,15 @@
2222
rel="external me"
2323
title="Symfony UX on X (Twitter)"
2424
>
25-
<twig:Icon name="x-twitter"/>
25+
<twig:ux:icon name="x-twitter"/>
2626
</a>
2727
<a
2828
class="AppNav_item AppNav_item--icon d-none d-sm-grid"
2929
href="https://github.com/symfony/ux"
3030
rel="external me"
3131
title="Symfony UX on GitHub"
3232
>
33-
<twig:Icon name="github" />
33+
<twig:ux:icon name="github" />
3434
</a>
3535
</div>
3636

ux.symfony.com/templates/components/Browser.html.twig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,23 @@
1515
</button>
1616
</div>
1717
<div class="Browser__url">
18-
<twig:Icon name="lock" />
18+
<twig:ux:icon name="lock" />
1919
<span>
2020
<span hidden>https://</span><em>ux.symfony.com</em><span hidden>{{ url }}</span>
2121
</span>
2222
<button class="Browser__action">
23-
<twig:Icon name="refresh" />
23+
<twig:ux:icon name="refresh" />
2424
</button>
2525
</div>
2626
<div class="Browser__actions">
2727
{% if false %}
2828
<button class="Browser__action" data-bs-toggle="tooltip" title="Feedback">
29-
<twig:Icon name="circle-help" />
29+
<twig:ux:icon name="circle-help" />
3030
</button>
3131
{% endif %}
3232
{% if githubUrl|default %}
3333
<a class="Browser__action" data-bs-toggle="tooltip" title="View on Github" href="{{ githubUrl }}">
34-
<twig:Icon name="github" />
34+
<twig:ux:icon name="github" />
3535
</a>
3636
{% endif %}
3737
</div>

ux.symfony.com/templates/components/ChangelogItem.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<details {{ isOpen|default ? 'open' }}>
1515
<summary class="ChangelogItem__Head">
1616
<h2 class="ChangelogItem__Title">{{ item.name|default(item.version) }}</h2>
17-
<twig:Icon name="arrow-down" class="ChangelogItem__Toggle" />
17+
<twig:ux:icon name="arrow-down" class="ChangelogItem__Toggle" />
1818
</summary>
1919
<div class="ChangelogItem__Text">
2020
{{ this.getContent()|markdown_to_html }}

ux.symfony.com/templates/components/Code/CodeBlock.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
data-code-expander-target="expandCodeButton"
4747
data-action="code-expander#expandCode"
4848
>
49-
<twig:Icon name="arrow-down"/>
49+
<twig:ux:icon name="arrow-down"/>
5050
<span>Expand code</span>
5151
</button>
5252
{% endblock %}

ux.symfony.com/templates/components/Code/CodeBlockButtons.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
data-bs-placement="bottom"
1212
title="View on GitHub"
1313
>
14-
<twig:Icon name="github"/>
14+
<twig:ux:icon name="github"/>
1515
</a>
1616
{% endset %}
1717

@@ -32,7 +32,7 @@
3232
data-action="clipboarder#copy"
3333
data-clipboarder-target="button"
3434
>
35-
<twig:Icon name="copy"/>
35+
<twig:ux:icon name="copy"/>
3636
</button>
3737
</div>
3838

ux.symfony.com/templates/components/Code/CodeLine.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
><code>{{ _code ? _code|trim|raw : code }}</code></pre>
1717

1818
<button class="btn btn-sm IconModalcopy" data-action="clipboarder#copy" data-clipboarder-target="button">
19-
<twig:Icon name="copy" />
19+
<twig:ux:icon name="copy" />
2020
</button>
2121
</div>

0 commit comments

Comments
 (0)