From 5f1404d77c52932e8b20b2e659f5b31ca59bca87 Mon Sep 17 00:00:00 2001 From: brabli <67018167+brabli@users.noreply.github.com> Date: Thu, 30 Apr 2026 12:22:50 +0100 Subject: [PATCH] Add showcase code --- dev/public/index.php | 17 ++++ dev/src/Controller/ShowcaseController.php | 76 ++++++++++++++++ dev/src/Kernel.php | 84 +++++++++++++++++ dev/templates/showcase.html.twig | 104 ++++++++++++++++++++++ 4 files changed, 281 insertions(+) create mode 100644 dev/public/index.php create mode 100644 dev/src/Controller/ShowcaseController.php create mode 100644 dev/src/Kernel.php create mode 100644 dev/templates/showcase.html.twig diff --git a/dev/public/index.php b/dev/public/index.php new file mode 100644 index 0000000..0a52bcc --- /dev/null +++ b/dev/public/index.php @@ -0,0 +1,17 @@ +handle($request); +$response->send(); +$kernel->terminate($request, $response); diff --git a/dev/src/Controller/ShowcaseController.php b/dev/src/Controller/ShowcaseController.php new file mode 100644 index 0000000..109480f --- /dev/null +++ b/dev/src/Controller/ShowcaseController.php @@ -0,0 +1,76 @@ + strtolower($c->name), BadgeColour::cases()); + + $samples = [ + new SampleBadgeable('Investigation', BadgeColour::BLUE), + new SampleBadgeable('Interrogation', BadgeColour::RED), + new SampleBadgeable('Shootout', BadgeColour::BLACK), + new SampleBadgeable('Sip Whiskey', BadgeColour::FOREST), + new SampleBadgeable('Unknown', BadgeColour::GREY), + ]; + + $iconSamples = [ + new SampleIconBadge('Investigation', BadgeColour::BLUE, 'mdi:magnify'), + new SampleIconBadge('Interrogation', BadgeColour::RED, 'bi:cassette-fill'), + new SampleIconBadge('Shootout', BadgeColour::BLACK, 'mdi:gun'), + new SampleIconBadge('Sip Whiskey', BadgeColour::FOREST, 'flowbite:whiskey-glass-outline'), + new SampleIconBadge('Unknown', BadgeColour::GREY, 'carbon:unknown'), + ]; + + return $this->render('showcase.html.twig', [ + 'colours' => $colours, + 'samples' => $samples, + 'icon_samples' => $iconSamples + ]); + } +} + +final readonly class SampleBadgeable implements BadgeableInterface +{ + public function __construct(public string $label, private BadgeColour $colour) + { + } + + public function getBadgeColour(): BadgeColour + { + return $this->colour; + } + + public function getBadgeIcon(): ?string + { + return null; + } +} + +final readonly class SampleIconBadge implements BadgeableInterface +{ + public function __construct(public string $label, private BadgeColour $colour, private string $icon) + { + } + + public function getBadgeColour(): BadgeColour + { + return $this->colour; + } + + public function getBadgeIcon(): ?string + { + return $this->icon; + } +} diff --git a/dev/src/Kernel.php b/dev/src/Kernel.php new file mode 100644 index 0000000..9238808 --- /dev/null +++ b/dev/src/Kernel.php @@ -0,0 +1,84 @@ +getProjectDir().'/var/cache/'.$this->environment; + } + + public function getLogDir(): string + { + return $this->getProjectDir().'/var/log'; + } + + private function configureContainer(ContainerConfigurator $container): void + { + $container->extension('framework', [ + 'secret' => 'dev', + 'router' => ['utf8' => true], + 'test' => false, + 'http_method_override' => false, + 'handle_all_throwables' => true, + 'php_errors' => ['log' => true], + ]); + + $container->extension('twig', [ + 'default_path' => $this->getProjectDir().'/templates', + ]); + + // Default config for the bundle. Tweak to preview different base classes. + $container->extension('pcm_badge', []); + + // Fetch icons on-demand from iconify.design so no JS toolchain is needed. + $container->extension('ux_icons', [ + 'icon_dir' => '%kernel.project_dir%/var/icons', + 'iconify' => ['enabled' => true, 'on_demand' => true], + ]); + + $container->services() + ->defaults() + ->autowire() + ->autoconfigure() + ->load(__NAMESPACE__.'\\Controller\\', __DIR__.'/Controller/') + ->public() + ; + } + + private function configureRoutes(RoutingConfigurator $routes): void + { + $routes->import(__DIR__.'/Controller/', 'attribute'); + } +} diff --git a/dev/templates/showcase.html.twig b/dev/templates/showcase.html.twig new file mode 100644 index 0000000..7cf2f6a --- /dev/null +++ b/dev/templates/showcase.html.twig @@ -0,0 +1,104 @@ + + +
+ +Local dev preview. Edit dev/templates/showcase.html.twig to add new variants.