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 '@'. diff --git a/components/icon/icon.twig b/components/icon/icon.twig index 47c0a431..64ae4880 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|default('includes/icons') }}/{{ 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 %}