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
|
|
|
{
|
|
|
|
public string $glyph = '';
|
|
|
|
|
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
|
|
|
|
2022-10-14 14:37:03 +00:00
|
|
|
$glyphSize = [
|
|
|
|
'small' => 'text-sm',
|
2023-06-12 14:47:38 +00:00
|
|
|
'base' => 'text-lg',
|
2022-10-14 14:37:03 +00:00
|
|
|
'large' => 'text-2xl',
|
|
|
|
];
|
2021-09-20 15:45:38 +00:00
|
|
|
|
2022-10-14 14:37:03 +00:00
|
|
|
$allAttributes = array_merge($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
|
|
|
|
2022-10-14 14:37:03 +00:00
|
|
|
$this->slot = icon($this->glyph, $glyphSize[$this->size]);
|
2021-09-15 15:58:21 +00:00
|
|
|
}
|
|
|
|
}
|