USWDS - Banner: Allow banner to init without accordion requirement#5551
Merged
Conversation
mejiaj
commented
Oct 11, 2023
| const ACCORDION = `.${PREFIX}-accordion, .${PREFIX}-accordion--bordered`; | ||
| const BUTTON = `.${PREFIX}-accordion__button[aria-controls]`; | ||
| const BANNER_BUTTON = `.${PREFIX}-banner__button`; | ||
| const BUTTON = `.${PREFIX}-accordion__button[aria-controls]:not(${BANNER_BUTTON})`; |
Contributor
Author
There was a problem hiding this comment.
All accordion buttons, except when combined with banner. This helps avoid conflicts because we now initialize banner.
mejiaj
commented
Oct 11, 2023
Contributor
Author
There was a problem hiding this comment.
- Importing the toggle utility, similar to accordion.
- Add an init method to banner.
- Add functionality to toggle content in
toggleBanner()line 17-19.
Merged
5 tasks
mahoneycm
approved these changes
Oct 16, 2023
mahoneycm
left a comment
Contributor
There was a problem hiding this comment.
This is working well for me!
- Components working as expected in storybook previews
- Components work without error on
Testvariations - React examples work as expected
- Removing
banner.on()still allows accordion to initialize correctly - Removing
accordion.on()still allows banner to initialize correctly
amyleadem
approved these changes
Oct 27, 2023
amyleadem
left a comment
Contributor
There was a problem hiding this comment.
This looks good to me! I performed the following tests:
- Opened preview links:
- Confirmed Storybook components initialized and toggled as expected
- Removed accordion from
uswds/core/src/js/index.jsand confirmed that banner continues to work as expected
- Opened the jm-test-uswds-5179 branch in uswds-sandbox
- Confirmed the components initialize and work as expected
Merged
7 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
USA Banner now initializes by itself. Initialize banner with
banner.on()method.It's no longer necessary to import and call
accordion.on()to initialize banner.Breaking change
This is not a breaking change.
Related issue
Closes #5179.
Related pull requests
Changelog PR: uswds/uswds-site#2301.
Preview link
develop)All components should work without conflicts.
Problem statement
Banner didn't have an init method and relied on accordion to toggle content.
Solution
Banner and accordion JS are separated; with banner being able to initialize and toggle on its own.
Major changes
Toggle added to banner & accordion ignores banner button - 27181af.
Testing and review
Testvariants.Additionally
npm installhttp://localhost:8080/accordion-react/Checklist
uswds.js.