Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/1.x/705 lgd icon doesnt use theme variable #706

Open
wants to merge 3 commits into
base: 1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions components/icon/icon.component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 '@'.
6 changes: 5 additions & 1 deletion components/icon/icon.twig
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,16 @@
{% 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove the {% set ... %} here then replace line 49 later with line 39 from here.

{%- endset -%}

{% set attributes = create_attribute()
.setAttribute('aria-hidden', decoration|default('true'))
.addClass('lgd-icon')
.addClass(icon_classes)
%}

<{{ icon_wrapper_element }}{{ attributes }}>
{% include icon_path ~ '/' ~ icon_name ~ '.svg' %}
{% include icon_fullpath %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's change this line to
{% if icon_path|first != '@' %}@{{ theme }}/{% endif %}{{ icon_path|default('includes/icons') }}/{{ icon_name }}.svg

after we remove the set from above, like so:

<{{ icon_wrapper_element }}{{ attributes }}>
  {% if icon_path|first != '@' %}@{{ theme }}/{% endif %}{{ icon_path|default('includes/icons') }}/{{ icon_name }}.svg
</{{ icon_wrapper_element }}>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That will be nicer. I'll do that this afternoon.

</{{ icon_wrapper_element }}>
Loading