-
Notifications
You must be signed in to change notification settings - Fork 17
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
base: 1.x
Are you sure you want to change the base?
Fix/1.x/705 lgd icon doesnt use theme variable #706
Conversation
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.
Variable was present but unused, and undocumented outside of code comments.
This is the path that's used in localgov_base.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. I've added a small suggestion that we can accept or reject, it won't make much of a difference either way.
@@ -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 |
There was a problem hiding this comment.
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.
{% 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 %} |
There was a problem hiding this comment.
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 }}>
There was a problem hiding this comment.
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.
@ctorgalson I think if you merge 1.x back to your forked branch, the eslint checks will pass. |
What does this change?
The PR adds the following to
localgov_base:icon
:theme
variable to namespace the path to the icon file ificon_path
does not begin with@
,theme
variable exists inicon.component.yml
(it was already documented in code),|default('includes/icons')
to theicon_path
variable to make the SDC behave as described in commentsHow to test
lgdtest
,web/themes/custom/lgdtest/assets/icons/someIcon.svg
(preferably different from any icon inlocalgov_base
),localgov_base:icon
component in the new child theme in each of the following ways:How can we measure success?
localgov_base:icon
(i.e.localgov_base:prev-next
)work as expectedHave we considered potential risks?
localgov_base:icon
SDC, so testing matters :)Images
n/a
Accessibility
n/a