Add constant, adjust text

This commit is contained in:
Brabli
2023-05-31 11:56:46 +01:00
parent 493f0c275b
commit 850ba765a2

View File

@@ -11,12 +11,13 @@ use Twig\Extension\RuntimeExtensionInterface;
final class IconRuntime implements RuntimeExtensionInterface
{
public const DEFAULT_SIZE = 32;
public const DEFAULT_COLOUR = 'primary';
private const DEFAULT_OPTIONS = [
'icon' => null,
'title' => null,
'size' => self::DEFAULT_SIZE,
'colour' => 'primary',
'colour' => self::DEFAULT_COLOUR,
'hover' => null,
'classes' => [],
];
@@ -27,20 +28,19 @@ final class IconRuntime implements RuntimeExtensionInterface
* @param array $options
* ```
* $options = [
* 'icon' => (string) REQUIRED Which icon to use
* 'title' => (?string) Text to appear on mouse hover
* 'size' => (int) Height and width in px
* 'colour' => (string) Main colour
* 'hover' => (?string) Hover colour
* 'classes' => (array) Additional classes to add to the icon.
* Use with caution as this can potentially
* cause Tailwind class conflicts!
* 'icon' => (string) REQUIRED Icon name without trailing `.svg`
* 'title' => (?string) Title text to appear on mouse hover
* 'size' => (int) Height and width in px
* 'colour' => (string) Main colour
* 'hover' => (?string) Hover colour
* 'classes' => (array) Additional classes to add to the icon. Not recommended.
* ]
* ```
*/
public function renderIcon(array $userOptions): string
{
$options = $this->getMergedOptions($userOptions);
$svg = $this->getSanitisedIconSvg($options['icon']);
$colourClasses = $this->getColourClasses($options['colour'], $options['hover']);