Add showcase code
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Pcm\BadgeBundle\Dev\Controller;
|
||||
|
||||
use Pcm\BadgeBundle\Enum\BadgeColour;
|
||||
use Pcm\BadgeBundle\Interface\BadgeableInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
final class ShowcaseController extends AbstractController
|
||||
{
|
||||
#[Route('/', name: 'showcase')]
|
||||
public function __invoke(): Response
|
||||
{
|
||||
$colours = array_map(fn (BadgeColour $c) => 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user