Skip to content

Conversation

mejiaj
Copy link
Contributor

@mejiaj mejiaj commented Oct 10, 2023

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

Current (develop) Feature branch
Accordion Default Accordion Preview
Banner Default Banner Preview
Test Default Test Preview

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

  • Visit preview links
  • Components should work individually
  • Components should work without conflicts in the Test variants.

Additionally

Checklist

  • Components should initialize by themselves with import.
  • There should be no regressions in compiled scripts uswds.js.

@@ -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})`;
Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Importing the toggle utility, similar to accordion.
  2. Add an init method to banner.
  3. Add functionality to toggle content in toggleBanner() line 17-19.

Copy link
Contributor

@mahoneycm mahoneycm left a 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

Copy link
Contributor

@amyleadem amyleadem left a 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

Copy link
Contributor

@thisisdano thisisdano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

USWDS - Bug: Banner has issues with accordion initialization
4 participants