Add icon param

This commit is contained in:
brabli
2026-04-29 17:05:12 +01:00
parent 4ecf0f2feb
commit c84f2b0973
+10 -4
View File
@@ -14,20 +14,22 @@ final class Badge
{ {
public string $finalClasses; public string $finalClasses;
public ?string $label = null; public ?string $label = null;
public ?string $icon = null;
public function __construct(private string $baseClasses) public function __construct(private string $baseClasses)
{ {
} }
/** /**
* @param ?BadgeableInterface $obj the object to be converted into a badge * @param ?BadgeableInterface $obj The object to be converted into a badge
* @param ?string $class Extra classes to add to the badge element. * @param ?string $class Extra classes to add to the badge element.
* These will override the base classes in case * These will override the base classes in case
* of conflicts. * of conflicts.
* @param ?string $colour specify the colour of an objectless badge * @param ?string $colour Manually specify the colour of a badge
* @param bool $outline if the badge should be rendered as an outline * @param bool $outline Whether the badge should be rendered with an outline
* @param ?string $icon
*/ */
public function mount(?BadgeableInterface $obj = null, ?string $class = null, ?string $colour = null, ?string $label = null, bool $outline = false): void public function mount(?BadgeableInterface $obj = null, ?string $class = null, ?string $colour = null, ?string $label = null, bool $outline = false, ?string $icon = null): void
{ {
$this->label = $label; $this->label = $label;
@@ -43,6 +45,10 @@ final class Badge
$palette = $obj->getBadgeColour()->getPalette(); $palette = $obj->getBadgeColour()->getPalette();
} }
if ($icon) {
dump($icon);
}
if ($colour) { if ($colour) {
$cases = array_map(fn (BadgeColour $b) => strtolower($b->name), BadgeColour::cases()); $cases = array_map(fn (BadgeColour $b) => strtolower($b->name), BadgeColour::cases());