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
USWDS-Site - Spacing token - Repair converted tokens #1949
Conversation
…acing-token-05
@mejiaj This PR creates a workaround for the confusion that happens with the leading zero and quotes between files. I tried to prevent the confusion with different methods of making |
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 can see the benefit of having the ability to override a conversion. We could also approach this from another angle.
The issue seems to be is_number.html
and how it treats the 05
value:
https://github.com/uswds/uswds-site/blob/aa4c540b646af56c01250e1dc5f3ef8fb2191446/_includes/tokens/is_number.html#L22-L30
We could add an additional check that would give us the number or the converted value, instead of both (because we're already checking in the template):
{% if is_number %}
{% assign converted = false %}
{% else %}
{% assign conversion =
site.data.tokens.conversion
| where: 'token', item.token %}
{% if conversion[0].number %}
{% assign converted = conversion[0].number %}
{% endif %}
{% endif %}
This resulted in a table that no longer has 0.5
as a value of 5
:
What do you think @amyleadem @thisisdano?
@mejiaj I attempted to implement your suggested solution. It fixed the false association with the |
I think that's what It looks like
|
{% if is_number %} | ||
{% assign converted = false %} | ||
{% else %} |
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.
Checking if the item is a number first prevents the 5
token from incorrectly receiving a converted value.
@@ -7,6 +7,7 @@ positive: | |||
small: | |||
- token: '05' | |||
value: 4px | |||
conversion: 0.5 |
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.
Created an explicit equivalent number value here because it could not recognize the '05'
token when assigning converted
in is_number.html
_data/changelogs/tokens-spacing.yml
Outdated
@@ -2,6 +2,19 @@ title: Spacing tokens | |||
type: token | |||
changelogURL: | |||
items: | |||
- date: 2022-12-19 |
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.
Need to update this date prior to merge
@mejiaj I was not able to get Also - the checks are currently failing because snyk ignore needs to be updated. The forthcoming snyk fix is in this PR: #2013 |
…acing-token-05
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.
Nice work fixing this issue! The output table on the spacing units page looks good.
Just a minor question on the PR date in changelog. Otherwise LGTM!
_data/changelogs/tokens-spacing.yml
Outdated
@@ -2,6 +2,19 @@ title: Spacing tokens | |||
type: token | |||
changelogURL: | |||
items: | |||
- date: 2022-12-19 |
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.
This should be merge date right?
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.
Updated in ed3e647
@@ -56,6 +56,8 @@ Any spacing value in utilities or component CSS should use the following spacing | |||
<span class="text-no-wrap padding-right-4"> | |||
{% if converted %} | |||
<code>{{ converted }}</code>, | |||
{% elsif item.conversion %} |
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 would just suggest we add a note for what this means. That way we can understand the logic flow in the future.
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.
Added comments in b4b7ad7
Summary
Related issue
Closes #1934
Preview links
Problem statement
On the spacing tokens page, the token
5
is incorrectly linked to the0.5
number equivalent.0.5
should instead be linked to token'05'
. This appears to happen because of confusion with the leading zero and quotes in'05'
– something is getting lost in translation between the files that prevents'05'
from receiving anyconverted
value.5
receives the converted value instead.On the spacing unit page, we need to both:
5
token from receiving the0.5
number equivalent AND'05'
token with the0.5
number equivalentAdditionally, the following pages also need to break the association between the
5
token and the0.5
conversion:Solution
The
converted
assignment inis_number.html
consistently ignored the leading zero in the'05'
token and would assign theconverted
value to5
instead. Attempts to explicitly declare'05'
as a string to force the leading zero were not successful.As a workaround, this PR creates an explicit
conversion
value for'05'
inspacing.yml
. Declaring an explicit value here removes the confusion that is currently happening between files.The spacing unit page appears to be the only instance of
'05'
token that is problematic.Screenshots
Final result:
Testing and review
To review:
5
token does not have the0.5
number equivalent on any of the preview pages.'05'
has the0.5
equivalent on the spacing tokens page.{{ converted }}
display correct values.