Skip to content

Commit 438fa01

Browse files
committed
[Site] Icons colors
* don't invert colored icons * add 3 icon set cards * re-add SVG code highlighting
1 parent d4e73c6 commit 438fa01

File tree

8 files changed

+34
-10
lines changed

8 files changed

+34
-10
lines changed

ux.symfony.com/assets/styles/components/_IconGrid.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@
153153
background: rgb(0 0 0 / 50%);
154154
}
155155

156-
.IconCard__icon {
156+
.IconCard__icon:not(.Icon__color) {
157157
filter: invert(1) hue-rotate(180deg);
158158
}
159159
}

ux.symfony.com/assets/styles/components/_IconModal.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@
121121
--invert: 0%;
122122
}
123123

124+
.IconModal__color > img {
125+
--invert: 0 !important;
126+
}
127+
124128
@keyframes icon-loading {
125129
0% {
126130
transform: scale(.95);

ux.symfony.com/src/Controller/Icons/IconsController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ public function index(IconSetRepository $iconSetRepository): Response
3333
'iconoir',
3434
'lucide',
3535
'tabler',
36+
'octicon',
37+
'ph',
38+
'heroicons',
3639
];
3740
$iconSets = array_map(fn ($iconSet) => $iconSetRepository->find($iconSet), $iconSets);
3841

ux.symfony.com/src/Twig/Components/Icon/IconSearch.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ public function icons(): array
7777
return $this->icons ??= $this->searchIcons();
7878
}
7979

80+
public function getIconSet(): ?IconSet
81+
{
82+
return $this->set ? $this->iconSetRepository->get($this->set) : null;
83+
}
84+
8085
private function searchIcons(): array
8186
{
8287
if (!$this->query) {

ux.symfony.com/src/Twig/Components/Icon/IconSetCard.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,18 @@ class IconSetCard
4848
'home', 'user', 'settings', 'search', 'arrow-down',
4949
'heart', 'star', 'sun-light', 'view-grid', 'media-image',
5050
],
51+
'octicon' => [
52+
'home', 'person', 'gear', 'search', 'arrow-down',
53+
'heart', 'star', 'sun-16', 'apps-24', 'image-16',
54+
],
55+
'ph' => [
56+
'house', 'user', 'gear', 'magnifying-glass', 'arrow-down',
57+
'heart', 'star', 'sun', 'squares-four', 'image',
58+
],
59+
'heroicons' => [
60+
'home', 'user', 'cog', 'magnifying-glass', 'arrow-down',
61+
'heart', 'star', 'sun', 'squares-2x2', 'photo',
62+
],
5163
];
5264

5365
public function getSampleIcons(): array

ux.symfony.com/templates/components/Icon/IconGrid.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% props icons = [] %}
1+
{% props icons = [], iconSet = null %}
22

33
<div {{ attributes }} class="IconGrid" data-controller="icon-grid">
44

@@ -9,7 +9,7 @@
99
{% if iconSet is not defined %}
1010
<span class="IconCard__prefix">{{ icon.prefix }}</span>
1111
{% endif %}
12-
<img class="IconCard__icon" width="32" height="32" src="{{ icon.imageUrl }}" alt="Icon {{ icon.prefix }} {{ icon.name|humanize }}">
12+
<img class="IconCard__icon {{ iconSet.palette|default ? 'Icon__color' }}" width="32" height="32" src="{{ icon.imageUrl }}" alt="Icon {{ icon.prefix }} {{ icon.name|humanize }}">
1313
<span class="IconCard__name">{{ icon.name }}</span>
1414
</button>
1515
</div>

ux.symfony.com/templates/components/Icon/IconModal.html.twig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@
2727

2828
<div class="IconModal__body">
2929
<div class="IconModal__media">
30-
<div class="IconModal__icon IconModal__icon--grid">
30+
<div class="IconModal__icon IconModal__icon--grid {{ icon_set.palette ? 'IconModal__color' }}">
3131
<img src="{{ icon.imageUrl }}" alt="Icon {{ icon.prefix }} {{ icon.name|humanize }}">
3232
</div>
3333
<div class="IconModal__icons">
34-
<div class="IconModal__icon">
34+
<div class="IconModal__icon {{ icon_set.palette ? 'IconModal__color' }}">
3535
<img src="{{ icon.imageUrl }}" alt="Icon {{ icon.prefix }} {{ icon.name|humanize }}">
3636
</div>
37-
<div class="IconModal__icon IconModal__icon--check">
37+
<div class="IconModal__icon IconModal__icon--check {{ icon_set.palette ? 'IconModal__color' }}">
3838
<img src="{{ icon.imageUrl }}" alt="Icon {{ icon.prefix }} {{ icon.name|humanize }}">
3939
</div>
40-
<div class="IconModal__icon">
40+
<div class="IconModal__icon {{ icon_set.palette ? 'IconModal__color' }}">
4141
<img src="{{ icon.imageUrl }}" alt="Icon {{ icon.prefix }} {{ icon.name|humanize }}">
4242
</div>
4343
</div>
@@ -88,10 +88,10 @@
8888
<div class="TabPanel" data-tabs-target="tab" id="IconModal-Tab-Svg" data-tab="svg">
8989
{% set _svg = this.svg() %}
9090
{% if _svg %}
91-
<div data-live-ignore id="IconModal-Tab-Svg--{{ icon }}">
91+
<div data-live-ignore id="IconModal-Tab-Svg--{{ icon }}">
9292
<h3>SVG Icon</h3>
9393
<twig:Code:CodeLine class="IconModal__code" height="12rem">
94-
{{ _svg }}
94+
{{ _svg|highlight('xml') }}
9595
</twig:Code:CodeLine>
9696
</div>
9797
{% endif %}

ux.symfony.com/templates/components/Icon/IconSearch.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464

6565
<div id="IconSearchResults" class="mt-5">
6666
{% if this.icons|length > 0 %}
67-
<twig:Icon:IconGrid icons="{{ this.icons }}" id="IconGrid-{{ this.hash }}" />
67+
<twig:Icon:IconGrid icons="{{ this.icons }}" id="IconGrid-{{ this.hash }}" iconSet="{{ this.iconSet ?? null }}" />
6868
{% elseif this.query %}
6969
<p class="pt-3 text-center">No icons found matching "{{ query }}".</p>
7070
{% endif %}

0 commit comments

Comments
 (0)