Skip to content
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

feat: Modal component #1622

Merged
merged 42 commits into from
Oct 7, 2021
Merged

feat: Modal component #1622

merged 42 commits into from
Oct 7, 2021

Conversation

suzubara
Copy link
Contributor

@suzubara suzubara commented Oct 1, 2021

Summary

This PR adds the USWDS Modal component and adds all USWDS examples to Storybook, as well as some documentation around how to use the component.

I also added focus-trap-react for managing focus inside of modals (USWDS handles this in a util and it seemed like something better implemented with an existing lib).

I also added two components to use for toggling the modal that implement the guidelines suggested by USWDS for convenience: ModalToggleButton and ModalOpenLink. Consumers can also call the exposed ref toggleModal method directly, so they are not restricted to these components.

Related Issues or PRs

How To Test

  • View the Modal component in Storybook
  • Verify the unit test cases are reproducible manually in the browser
  • Try using the component in an application
  • Note: Some of the unit tests output some warnings because they require rendering the component directly into the document.body. This is expected.

Screenshots (optional)

modal_default

modal_forced

SirenaBorracha and others added 29 commits May 12, 2021 17:56
@suzubara suzubara changed the title [WIP] feat: Modal component feat: Modal component Oct 6, 2021
@suzubara suzubara added this to the USWDS 2.11.x milestone Oct 6, 2021
@suzubara suzubara added the type: feature New feature or request label Oct 6, 2021
return <Link<FCProps> {...linkProps} />
}

const definitelyLinkProps = linkProps as DefaultLinkProps
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems to fix the Typescript error that we started seeing in this update - I'm not sure why the overload isn't correctly narrowing this type after the isCustomProps check but I think that is a separate issue to resolve.

brandonlenz
brandonlenz previously approved these changes Oct 6, 2021
Copy link
Contributor

@brandonlenz brandonlenz left a comment

Choose a reason for hiding this comment

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

Couple of small things, but looks great and works nicely from my testing!

src/components/Modal/utils.ts Outdated Show resolved Hide resolved
src/components/Modal/Modal.stories.tsx Show resolved Hide resolved
Co-authored-by: Brandon Lenz <brandonalenz@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feat] New Component: Modal
4 participants