USWDS - Button: define default type in JSON#5247
Merged
Merged
Conversation
mejiaj
approved these changes
Apr 21, 2023
Contributor
mejiaj
left a comment
There was a problem hiding this comment.
Thanks for fixing this! Alternatively we can use the | default() filter in twig.
amyleadem
approved these changes
Apr 21, 2023
Contributor
amyleadem
left a comment
There was a problem hiding this comment.
This looks good! Confirmed that type now appears in usa-button.html and that there are no empty button types in html-templates.
thisisdano
approved these changes
May 8, 2023
24 tasks
Merged
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Specifies
typeinusa-button.jsonto fix html component codeBreaking change
This is not a breaking change.
Change log PR
uswds/uswds-site#2093
Related issue
Closes #5246
Preview link
Button: storybook →
Demo USWDS site with correct button type showing →
Problem statement
Our html component code for
usa-buttonwould display an emptytypeattribute forusa-buttonExpected:
Solution
Add the default type attribute to the
usa-buttonjson file so that webpack correctly fills the variable in the twig file.Before, this value was being set by storybook controls, which do not seem to make their way to the html templates once they're built.
Testing and review
View change on site
Note
This seems to be the most direct way to populate this field, but it does override the
defaultValuefield within the storybook controls.If you change
defaultValuewithinusa-button.stories.js, the default button story will always default totype="button"while the other variants will change to the set value. This can still be changed using the radio buttons though!Currently, the
defaultValueis button so the desired preview is still maintained. I just wanted to flag it in case!Before opening this PR, make sure you’ve done whichever of these applies to you:
git pull origin [base branch]to pull in the most recent updates from your base and check for merge conflicts. (Often, the base branch isdevelop).npm testand confirm that all tests pass.