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