Work on badge logic
This commit is contained in:
@@ -10,15 +10,19 @@ use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;
|
||||
#[AsTwigComponent(name: 'Pcm:Badge', template: "@PcmBadge/components/Badge.html.twig")]
|
||||
final class Badge
|
||||
{
|
||||
public string $baseClasses = 'rounded text-xs px-2 py-1 border min-w-max';
|
||||
public string $baseClasses = 'rounded max-w-max text-xs px-2 py-1 border min-w-max';
|
||||
|
||||
public string $finalClasses = '';
|
||||
|
||||
public function mount(BadgeableInterface $object): void
|
||||
/**
|
||||
* @param BadgeableInterface $object The object to be converted into a badge
|
||||
* @param string $class Extra classes you want to add to the badge template
|
||||
*/
|
||||
public function mount(BadgeableInterface $object, string $class = ''): void
|
||||
{
|
||||
$palette = $object->getBadgeColour()->getPalette();
|
||||
|
||||
$this->finalClasses = sprintf('text-white %s %s %s', $palette->borderColourClass, $palette->backgroundColourClass, $this->baseClasses);
|
||||
$this->finalClasses = sprintf('text-white %s %s %s %s', $palette->borderColourClass, $palette->backgroundColourClass, $this->baseClasses, $class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user