2021-09-15 15:58:21 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace App\Views\Components;
|
|
|
|
|
2022-10-14 14:37:03 +00:00
|
|
|
class IconButton extends Button
|
2021-09-15 15:58:21 +00:00
|
|
|
{
|
2024-05-09 17:55:41 +00:00
|
|
|
public string $glyph;
|
|
|
|
|
|
|
|
protected array $props = ['glyph'];
|
2021-09-15 15:58:21 +00:00
|
|
|
|
2022-10-14 14:37:03 +00:00
|
|
|
public function __construct(array $attributes)
|
2021-09-15 15:58:21 +00:00
|
|
|
{
|
2022-10-14 14:37:03 +00:00
|
|
|
$iconButtonAttributes = [
|
2023-06-12 14:47:38 +00:00
|
|
|
'isSquared' => 'true',
|
|
|
|
'title' => $attributes['slot'],
|
2021-11-05 14:36:34 +00:00
|
|
|
'data-tooltip' => 'bottom',
|
2021-09-20 15:45:38 +00:00
|
|
|
];
|
2021-09-15 15:58:21 +00:00
|
|
|
|
2023-11-15 16:17:43 +00:00
|
|
|
$allAttributes = [...$attributes, ...$iconButtonAttributes];
|
2021-09-20 15:45:38 +00:00
|
|
|
|
2022-10-14 14:37:03 +00:00
|
|
|
parent::__construct($allAttributes);
|
2021-09-20 15:45:38 +00:00
|
|
|
|
2024-05-09 17:55:41 +00:00
|
|
|
$glyphSizeClass = match ($this->size) {
|
|
|
|
'small' => 'text-sm',
|
|
|
|
'large' => 'text-2xl',
|
|
|
|
default => 'text-lg',
|
|
|
|
};
|
|
|
|
|
2024-04-26 17:57:25 +00:00
|
|
|
$this->slot = icon($this->glyph, [
|
2024-05-09 17:55:41 +00:00
|
|
|
'class' => $glyphSizeClass,
|
2024-04-26 17:57:25 +00:00
|
|
|
]);
|
2021-09-15 15:58:21 +00:00
|
|
|
}
|
|
|
|
}
|