-
Notifications
You must be signed in to change notification settings - Fork 1.1k
USWDS - Banner: Allow banner to init without accordion requirement #5551
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
Conversation
@@ -6,7 +6,8 @@ const { CLICK } = require("../../uswds-core/src/js/events"); | |||
const { prefix: PREFIX } = require("../../uswds-core/src/js/config"); | |||
|
|||
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})`; |
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.
All accordion buttons, except when combined with banner. This helps avoid conflicts because we now initialize banner.
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.
- Importing the toggle utility, similar to accordion.
- Add an init method to banner.
- Add functionality to toggle content in
toggleBanner()
line 17-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 is working well for me!
- Components working as expected in storybook previews
- Components work without error on
Test
variations - React examples work as expected
- Removing
banner.on()
still allows accordion to initialize correctly - Removing
accordion.on()
still allows banner to initialize correctly
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 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.js
and 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
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!
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
Test
variants.Additionally
npm install
http://localhost:8080/accordion-react/
Checklist
uswds.js
.