From 29ecb55dd9613629c6e8a0b027a0584e96b69448 Mon Sep 17 00:00:00 2001 From: Christopher Torgalson Date: Thu, 23 Jan 2025 11:49:30 -0500 Subject: [PATCH 1/3] feat: adds, uses new variable icon_fullpath The new variable uses icon_path alone if it begins with '@' (i.e. if it's Twig-namespaced), but will use the value of theme (defaulting to 'localgov_base') in other circumstances. --- components/icon/icon.twig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/icon/icon.twig b/components/icon/icon.twig index 47c0a431..0c0824fb 100644 --- a/components/icon/icon.twig +++ b/components/icon/icon.twig @@ -35,6 +35,10 @@ {% set theme = theme|default('localgov_base') %} {% set icon_wrapper_element = icon_wrapper_element|default('div') %} +{%- set icon_fullpath -%} + {% if icon_path|first != '@' %}@{{ theme }}/{% endif %}{{ icon_path }}/{{ icon_name }}.svg +{%- endset -%} + {% set attributes = create_attribute() .setAttribute('aria-hidden', decoration|default('true')) .addClass('lgd-icon') @@ -42,5 +46,5 @@ %} <{{ icon_wrapper_element }}{{ attributes }}> - {% include icon_path ~ '/' ~ icon_name ~ '.svg' %} + {% include icon_fullpath %} From daaf84e5a6dbf34aca7dc431bc199a68c1952e73 Mon Sep 17 00:00:00 2001 From: Christopher Torgalson Date: Thu, 23 Jan 2025 11:51:41 -0500 Subject: [PATCH 2/3] feat: adds documentation for the 'theme' variable Variable was present but unused, and undocumented outside of code comments. --- components/icon/icon.component.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/components/icon/icon.component.yml b/components/icon/icon.component.yml index 26649506..f985ebdb 100644 --- a/components/icon/icon.component.yml +++ b/components/icon/icon.component.yml @@ -29,3 +29,10 @@ props: description: > A space-separated string of one or more icon classes to be added to the defaults. + theme: + type: string + title: Theme + description: > + The machine name of the theme containing the icon path. Defaults to + 'localgov_base', but will be ignored if icon_path already begins + with '@'. From da3116f7abeffa31c155928c88e9e0882f4d668b Mon Sep 17 00:00:00 2001 From: Christopher Torgalson Date: Thu, 23 Jan 2025 12:16:02 -0500 Subject: [PATCH 3/3] feat: adds default value for undefined icon_path variable This is the path that's used in localgov_base. --- components/icon/icon.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/icon/icon.twig b/components/icon/icon.twig index 0c0824fb..64ae4880 100644 --- a/components/icon/icon.twig +++ b/components/icon/icon.twig @@ -36,7 +36,7 @@ {% set icon_wrapper_element = icon_wrapper_element|default('div') %} {%- set icon_fullpath -%} - {% if icon_path|first != '@' %}@{{ theme }}/{% endif %}{{ icon_path }}/{{ icon_name }}.svg + {% if icon_path|first != '@' %}@{{ theme }}/{% endif %}{{ icon_path|default('includes/icons') }}/{{ icon_name }}.svg {%- endset -%} {% set attributes = create_attribute()