Add constant, adjust text
This commit is contained in:
@@ -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
|
||||
* '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.
|
||||
* Use with caution as this can potentially
|
||||
* cause Tailwind class conflicts!
|
||||
* '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']);
|
||||
|
||||
Reference in New Issue
Block a user