From 850ba765a2964ca92ad787e8b37ff37cf53224d3 Mon Sep 17 00:00:00 2001 From: Brabli <67018167+Brabli@users.noreply.github.com> Date: Wed, 31 May 2023 11:56:46 +0100 Subject: [PATCH] Add constant, adjust text --- src/Twig/Runtime/IconRuntime.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Twig/Runtime/IconRuntime.php b/src/Twig/Runtime/IconRuntime.php index d3006e8..170bacf 100644 --- a/src/Twig/Runtime/IconRuntime.php +++ b/src/Twig/Runtime/IconRuntime.php @@ -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']);