Skip to content

Commit f0ede85

Browse files
committed
[Site] Display deprecated packages separately
1 parent ea8f5c1 commit f0ede85

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

ux.symfony.com/src/Controller/UxPackagesController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ class UxPackagesController extends AbstractController
2222
#[Route('/packages', name: 'app_packages')]
2323
public function __invoke(UxPackageRepository $packageRepository): Response
2424
{
25-
$packages = $packageRepository->findAll();
25+
$packages = $packageRepository->findAll(deprecated: false);
26+
$deprecatedPackages = $packageRepository->findAll(deprecated: true);
2627

2728
return $this->render('main/packages.html.twig', [
2829
'packages' => $packages,
30+
'deprecated_packages' => $deprecatedPackages,
2931
]);
3032
}
3133

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class UxPackageRepository
1818
/**
1919
* @return array<UxPackage>
2020
*/
21-
public function findAll(?string $query = null): array
21+
public function findAll(?string $query = null, ?bool $deprecated = null): array
2222
{
2323
$packages = [
2424
new UxPackage(
@@ -258,13 +258,15 @@ public function findAll(?string $query = null): array
258258
->setDocsLink('https://github.com/mattboldt/typed.js/', 'Typed.js documentation'),
259259
];
260260

261-
if (!$query) {
262-
return $packages;
261+
if ($query) {
262+
$packages = array_filter($packages, fn(UxPackage $package) => str_contains($package->getName(), $query) || str_contains($package->getHumanName(), $query));
263263
}
264264

265-
return array_filter($packages, function (UxPackage $package) use ($query) {
266-
return str_contains($package->getName(), $query) || str_contains($package->getHumanName(), $query);
267-
});
265+
if (null !== $deprecated) {
266+
$packages = array_filter($packages, fn(UxPackage $package) => $package->isDeprecated() === $deprecated);
267+
}
268+
269+
return $packages;
268270
}
269271

270272
public function find(string $name): UxPackage

ux.symfony.com/templates/main/packages.html.twig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@
2121
<twig:Package:PackageBox package="{{ package }}" titleTag="h2" />
2222
{% endfor %}
2323
</div>
24+
25+
<h2 class="text-center mt-5">Deprecated packages</h2>
26+
<p class="text-center mt-2 mb-5">Packages that are still available but will be removed in future versions</p>
27+
28+
<div style="display: grid; gap: 3rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));">
29+
{% for package in deprecated_packages %}
30+
<twig:Package:PackageBox package="{{ package }}" titleTag="h3" />
31+
{% endfor %}
32+
</div>
2433
{% endblock %}
2534
</div>
2635
{% endblock %}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
<div class="">
2323
<p class="deprecated-badge">Deprecated Package</p>
2424
<h1 class="mb-4">UX Swup 2.x</h1>
25-
<p>This component is <strong>deprecated</strong> and will not receive further updates. Please consider
26-
using <a href="/turbo" class="link">Symfony UX Turbo</a> for modern page
25+
<p>This component is <strong>deprecated</strong> and will not receive further updates.<br>
26+
Please consider using <a href="{{ path('app_turbo') }}" class="link">Symfony UX Turbo</a> for modern page
2727
transitions.</p>
2828
</div>
2929
</main>

0 commit comments

Comments
 (0)