USWDS - Button: define default type in JSON #5247
Merged
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
type
inusa-button.json
to 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-button
would display an emptytype
attribute forusa-button
Expected:
Solution
Add the default type attribute to the
usa-button
json 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
defaultValue
field within the storybook controls.If you change
defaultValue
withinusa-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
defaultValue
is 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 test
and confirm that all tests pass.