Skip to content

Commit fed00e2

Browse files
committed
bug #1919 [Site] Fix package meta (smnandre)
This PR was squashed before being merged into the 2.x branch. Discussion ---------- [Site] Fix package meta Commits ------- 645d337 [Site] Fix package meta
2 parents 3b6a1dc + 645d337 commit fed00e2

File tree

9 files changed

+58
-38
lines changed

9 files changed

+58
-38
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace App\Controller\Icons;
1313

1414
use App\Service\Icon\IconSetRepository;
15+
use App\Service\UxPackageRepository;
1516
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
1617
use Symfony\Component\HttpFoundation\Response;
1718
use Symfony\Component\Routing\Attribute\Route;
@@ -22,8 +23,10 @@
2223
final class IconsController extends AbstractController
2324
{
2425
#[Route('/icons', name: 'app_icons')]
25-
public function index(IconSetRepository $iconSetRepository): Response
26-
{
26+
public function index(
27+
UxPackageRepository $packageRepository,
28+
IconSetRepository $iconSetRepository,
29+
): Response {
2730
// Homepage "Popular Icon Sets"
2831
// Hard-coded until we bring the IconSet's lists / views back
2932
$iconSets = [
@@ -40,6 +43,7 @@ public function index(IconSetRepository $iconSetRepository): Response
4043
$iconSets = array_map(fn ($iconSet) => $iconSetRepository->find($iconSet), $iconSets);
4144

4245
return $this->render('icons/index.html.twig', [
46+
'package' => $packageRepository->find('icons'),
4347
'iconSets' => $iconSets,
4448
]);
4549
}

ux.symfony.com/src/Model/UxPackage.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function getGradient(): string
5858

5959
public function getImageFilename(?string $format = null): string
6060
{
61-
return $this->imageFileName ?? ltrim($this->name, 'ux-').($format ? ('-'.$format) : '').'.png';
61+
return $this->imageFileName ?? $this->name.($format ? '-'.$format : '').'.png';
6262
}
6363

6464
public function getTagLine(): string
@@ -127,6 +127,11 @@ public function getCreateString(): string
127127
return $this->createString;
128128
}
129129

130+
public function getSocialImage(?string $format = null): string
131+
{
132+
return 'images/ux_packages/'.$this->name.($format ? ('-'.$format) : '').'.png';
133+
}
134+
130135
public function getImage(?string $format = null): string
131136
{
132137
return 'images/ux_packages/'.$this->getImageFilename($format);

ux.symfony.com/src/Service/UxPackageRepository.php

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,29 @@ public function findAll(?string $query = null): array
3434
->setDocsLink('https://turbo.hotwired.dev/handbook/introduction', 'Documentation specifically for the Turbo JavaScript library.')
3535
->setScreencastLink('https://symfonycasts.com/screencast/turbo', 'Go deep into all 3 parts of Turbo.'),
3636

37+
new UxPackage(
38+
'icons',
39+
'UX Icons',
40+
'app_icons',
41+
'#fff',
42+
'linear-gradient(to bottom right, cyan, purple)',
43+
'SVG icons made easy',
44+
'Render SVG icons seamlessly from your Twig templates.',
45+
'I need to render SVG icons.',
46+
'icons.svg',
47+
),
48+
49+
new UxPackage(
50+
'twig-component',
51+
'Twig Components',
52+
'app_twig_component',
53+
'#7FA020',
54+
'linear-gradient(95deg, #7FA020 -5%, #A1C94E 105%)',
55+
'Render Reusable UI Elements',
56+
'Create PHP classes that can render themselves',
57+
'I need to create PHP classes that render'
58+
),
59+
3760
new UxPackage(
3861
'live-component',
3962
'Live Components',
@@ -57,15 +80,15 @@ public function findAll(?string $query = null): array
5780
),
5881

5982
new UxPackage(
60-
'icons',
61-
'UX Icons',
62-
'app_icons',
63-
'#fff',
64-
'linear-gradient(to bottom right, cyan, purple)',
65-
'SVG icons made easy',
66-
'Render SVG icons seamlessly from your Twig templates.',
67-
'I need to render SVG icons.',
68-
'icons.svg',
83+
'translator',
84+
'Translator',
85+
'app_translator',
86+
'#2248D0',
87+
'linear-gradient(139deg, #2248D0 -20%, #00FFB2 113%)',
88+
'Symfony Translations in JavaScript',
89+
"Use Symfony's translations in JavaScript",
90+
'I need to translate strings in JavaScript',
91+
'translator.svg'
6992
),
7093

7194
(new UxPackage(
@@ -140,17 +163,6 @@ public function findAll(?string $query = null): array
140163
'I need to delay large image loading'
141164
),
142165

143-
new UxPackage(
144-
'twig-component',
145-
'Twig Components',
146-
'app_twig_component',
147-
'#7FA020',
148-
'linear-gradient(95deg, #7FA020 -5%, #A1C94E 105%)',
149-
'Render Reusable UI Elements',
150-
'Create PHP classes that can render themselves',
151-
'I need to create PHP classes that render'
152-
),
153-
154166
new UxPackage(
155167
'dropzone',
156168
'Stylized Dropzone',
@@ -207,18 +219,6 @@ public function findAll(?string $query = null): array
207219
'I need to type onto the screen... like this'
208220
))
209221
->setDocsLink('https://github.com/mattboldt/typed.js/', 'Typed.js documentation'),
210-
211-
new UxPackage(
212-
'translator',
213-
'Translator',
214-
'app_translator',
215-
'#2248D0',
216-
'linear-gradient(139deg, #2248D0 -20%, #00FFB2 113%)',
217-
'Symfony Translations in JavaScript',
218-
"Use Symfony's translations in JavaScript",
219-
'I need to translate strings in JavaScript',
220-
'translator.svg'
221-
),
222222
];
223223

224224
if (!$query) {

ux.symfony.com/templates/icons/index.html.twig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@
99
title: 'UX Icons - SVG icons made easy',
1010
description: 'Render SVG icons seamlessly from your Twig templates. Find the perfect icon among 200,000 choices from the most popular icon sets.',
1111
canonical: url('app_icons'),
12+
social: {
13+
title: 'Symfony UX Icons - SVG icons made easy',
14+
description: 'Render SVG icons seamlessly from your Twig templates. Find the perfect icon among 200,000 choices from the most popular icon sets.',
15+
image: {
16+
url: absolute_url(asset(package.getSocialImage('1200x675'))),
17+
type: 'image/png',
18+
width: 1200,
19+
height: 675,
20+
alt: package.humanName ~ ' - Component Icon',
21+
},
22+
}
1223
} %}
1324

1425
{% block content %}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
description: package.description,
66
canonical: url(package.route),
77
social: {
8-
title: package.tagline ~ ' - Symfony UX ' ~ package.humanName,
8+
title: package.tagline ~ ' - Symfony UX ' ~ package.humanName|u.trimStart('UX '),
99
description: package.description|striptags,
1010
image: {
11-
url: absolute_url(asset(package.imageFileName('1200x675'))),
11+
url: absolute_url(asset(package.getSocialImage('1200x675'))),
1212
type: 'image/png',
1313
width: 1200,
1414
height: 675,
15-
alt: package.name ~ ' - Component Icon',
15+
alt: package.humanName ~ ' - Component Icon',
1616
},
1717
}
1818
} %}

0 commit comments

Comments
 (0)