Skip to content

Commit 5a0241f

Browse files
committed
minor #2116 [Site] Fix icon on Twig Component (smnandre)
This PR was merged into the 2.x branch. Discussion ---------- [Site] Fix icon on Twig Component * missing icon class * invert code block and result * now use symfony/ux-icons Fix #2115 Commits ------- 8367a29 [Site] Fix icon on Twig Component
2 parents 83340c3 + 8367a29 commit 5a0241f

File tree

3 files changed

+17
-27
lines changed

3 files changed

+17
-27
lines changed

ux.symfony.com/src/Twig/Alert.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace App\Twig;
1313

14-
use App\Service\UxPackageRepository;
1514
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;
1615

1716
#[AsTwigComponent]
@@ -20,20 +19,11 @@ class Alert
2019
public string $type = 'success';
2120
public string $message;
2221

23-
public function __construct(private UxPackageRepository $packageRepository)
24-
{
25-
}
26-
2722
public function getIcon(): string
2823
{
2924
return match ($this->type) {
30-
'success' => 'circle-check',
31-
'danger' => 'circle-exclamation',
25+
'success' => 'bi:check-circle',
26+
'danger' => 'bi:exclamation-circle',
3227
};
3328
}
34-
35-
public function getPackageCount(): int
36-
{
37-
return $this->packageRepository->count();
38-
}
3929
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<div class="alert alert-{{ type }} alert-dismissible" role="alert">
2-
<twig:Icon name="{{ this.icon }}" class="me-2" />
2+
<twig:ux:icon name="{{ this.icon }}" class="Icon bi" />
33
{{ message }}
44
</div>

ux.symfony.com/templates/ux_packages/twig_component.html.twig

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,7 @@
2626
{% block demo_title %}UX Twig Components{% endblock %}
2727

2828
{% block demo_content %}
29-
<div class="row align-items-center">
30-
<div class="col-6">
31-
{% block alert_success_example %}
32-
<twig:Alert message="I am a success alert!" />
33-
{% endblock %}
34-
</div>
29+
<div class="row">
3530
<div class="col-6">
3631
<twig:CodeBlock
3732
filename="templates/ux_packages/twig_component.html.twig"
@@ -41,17 +36,14 @@
4136
height="auto"
4237
/>
4338
</div>
44-
</div>
45-
46-
<div class="row my-2 align-items-center">
4739
<div class="col-6">
48-
{% block alert_danger_example %}
49-
<twig:Alert
50-
type="danger"
51-
message="Oh no! The dinos escaped!"
52-
/>
40+
{% block alert_success_example %}
41+
<twig:Alert message="I am a success alert!" />
5342
{% endblock %}
5443
</div>
44+
</div>
45+
46+
<div class="row my-2">
5547
<div class="col-6">
5648
<twig:CodeBlock
5749
filename="templates/ux_packages/twig_component.html.twig"
@@ -61,5 +53,13 @@
6153
height="auto"
6254
/>
6355
</div>
56+
<div class="col-6">
57+
{% block alert_danger_example %}
58+
<twig:Alert
59+
type="danger"
60+
message="Oh no! The dinos escaped!"
61+
/>
62+
{% endblock %}
63+
</div>
6464
</div>
6565
{% endblock %}

0 commit comments

Comments
 (0)