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

Add Modal component #631

Merged
merged 54 commits into from
Nov 21, 2022
Merged

Add Modal component #631

merged 54 commits into from
Nov 21, 2022

Conversation

alex-ju
Copy link
Member

@alex-ju alex-ju commented Oct 13, 2022

πŸ“Œ Summary

Add modal Dialog Modal component

πŸ› οΈ Detailed description

Raising this early for feedback on the direction of travel
In this modal dialog implementation, we try to leverage the <dialog> element as much as possible and kept the codebase to a minimum.

πŸ‘‰ Preview Hds::Modal component

Functionality

  • provide a name for the modal dialog (generate id and set aria-labelledby to the title)
  • inform users that it is a modal dialog (role="dialog" aria-modal="true") [dialog]
  • on ESC key the modal dialog is closed [dialog]
  • on 'dismiss' button the modal dialog is closed
  • on click outside the modal dialog is closed (review, consider ember-focus-trap or ember-click-outside)
  • prevent tabbing to outside the modal dialogue while open (review, consider ember-focus-trap)
  • on close: allow callback function
  • on close: return focus to the element that invoked the modal dialog [dialog]
  • on open: set initial focus on the first focusable element [dialog]
  • manage overflowing content (scroll only the body container)

Variations

  • size variation (small/medium/large)
  • type color variation (neutral/warning/critical)
  • header (title, tagline, icon)
  • footer (primary, secondary, tertiary action)

Documentation

  • Overview
  • API
  • How to use
  • Design guidelines
  • Accessibility
  • Showcase

πŸ“Έ Screenshots

The current implementation of Hds::Modal component in Safari 14 (tested via BrowserStack) which does not have native support for <dialog>. In this instances, where there is no native support, we use Google Chrome's polyfill.
dialog-polyfill on Safari14

πŸ”— External links

Jira issue


πŸ‘€ How to review

πŸ‘‰ Review commit-by-commit (for the 'evolution' of the component and a more digestible review)
πŸ‘‰ Review by files changed (for an overall review)

Reviewer's checklist:

  • +1 Percy if applicable
  • Confirm that PR has a changelog update via Changesets if needed

πŸ’¬ Please consider using conventional comments when reviewing this PR.

@changeset-bot
Copy link

changeset-bot bot commented Oct 13, 2022

πŸ¦‹ Changeset detected

Latest commit: 9129e59

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@hashicorp/design-system-components Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Oct 13, 2022

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated
hds-components βœ… Ready (Inspect) Visit Preview πŸ’¬ Add your feedback Nov 21, 2022 at 7:00PM (UTC)
hds-flight-website βœ… Ready (Inspect) Visit Preview πŸ’¬ Add your feedback Nov 21, 2022 at 7:00PM (UTC)
hds-website βœ… Ready (Inspect) Visit Preview πŸ’¬ Add your feedback Nov 21, 2022 at 7:00PM (UTC)

@alex-ju alex-ju force-pushed the alex-ju/add-dialog-component branch from 9eb657e to 70281b4 Compare October 13, 2022 08:23
@vercel vercel bot temporarily deployed to Preview – hds-flight-website October 13, 2022 08:25 Inactive
@vercel vercel bot temporarily deployed to Preview – hds-components October 13, 2022 08:26 Inactive
@vercel vercel bot temporarily deployed to Preview – hds-flight-website October 13, 2022 10:25 Inactive
@vercel vercel bot temporarily deployed to Preview – hds-components October 13, 2022 10:25 Inactive
@alex-ju alex-ju force-pushed the alex-ju/add-dialog-component branch from 0a9387d to 5e19579 Compare October 17, 2022 11:04
@vercel vercel bot temporarily deployed to Preview – hds-components October 17, 2022 11:06 Inactive
@vercel vercel bot temporarily deployed to Preview – hds-flight-website October 17, 2022 11:06 Inactive
@vercel vercel bot temporarily deployed to Preview – hds-components October 17, 2022 11:10 Inactive
@vercel vercel bot temporarily deployed to Preview – hds-flight-website October 17, 2022 11:10 Inactive
Copy link
Contributor

@didoo didoo left a comment

Choose a reason for hiding this comment

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

@alex-ju I did a first pass on the code and added a few comments. more than happy to discuss them in a call/chat

packages/components/addon/components/hds/dialog/header.hbs Outdated Show resolved Hide resolved
packages/components/addon/components/hds/dialog/header.hbs Outdated Show resolved Hide resolved
packages/components/addon/components/hds/dialog/header.hbs Outdated Show resolved Hide resolved
packages/components/addon/components/hds/dialog/index.js Outdated Show resolved Hide resolved
packages/components/addon/components/hds/dialog/index.hbs Outdated Show resolved Hide resolved
packages/components/addon/components/hds/dialog/index.js Outdated Show resolved Hide resolved
packages/components/addon/components/hds/dialog/index.js Outdated Show resolved Hide resolved
packages/components/app/styles/components/dialog.scss Outdated Show resolved Hide resolved
packages/components/app/styles/components/dialog.scss Outdated Show resolved Hide resolved
packages/components/app/styles/components/dialog.scss Outdated Show resolved Hide resolved
@alex-ju alex-ju force-pushed the alex-ju/add-dialog-component branch from 173f551 to 9a7a6bf Compare October 21, 2022 13:42
@vercel vercel bot temporarily deployed to Preview – hds-flight-website October 21, 2022 13:44 Inactive
@vercel vercel bot temporarily deployed to Preview – hds-components October 21, 2022 13:44 Inactive
@alex-ju alex-ju force-pushed the alex-ju/add-dialog-component branch from 9a7a6bf to e2694e4 Compare October 21, 2022 13:49
@vercel vercel bot temporarily deployed to Preview – hds-flight-website October 21, 2022 13:51 Inactive
@vercel vercel bot temporarily deployed to Preview – hds-components October 21, 2022 13:51 Inactive
@alex-ju alex-ju force-pushed the alex-ju/add-dialog-component branch from e2694e4 to 850af9e Compare October 21, 2022 13:52
@vercel vercel bot temporarily deployed to Preview – hds-flight-website October 21, 2022 13:54 Inactive
@vercel vercel bot temporarily deployed to Preview – hds-components October 21, 2022 13:54 Inactive
@alex-ju alex-ju force-pushed the alex-ju/add-dialog-component branch from 850af9e to 34e1375 Compare October 21, 2022 14:00
alex-ju and others added 18 commits November 21, 2022 18:11
This should prevent the scroll from being displayed on the `hds-modal__body` element if the content does not overflow.
Updated to test that any additional attribute passed is rendered – not just the `class`
We do this so that viewers don't accidentally remove an example from the showcase while checking out the examples.
If the callback function returns `false` we keep the modal dialog open
To facilitate the implementation of dismiss actions
Copy link
Contributor

@didoo didoo left a comment

Choose a reason for hiding this comment

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

Added a couple of super minor comments.

It's good to go! 🚒

.changeset/tough-emus-drop.md Outdated Show resolved Hide resolved
Switch from checking the callback function return to checking a `isDismissDisabled` property before dismissing a modal dialog
@alex-ju alex-ju force-pushed the alex-ju/add-dialog-component branch from e6d88d5 to 9129e59 Compare November 21, 2022 18:57
@vercel vercel bot temporarily deployed to Preview – hds-flight-website November 21, 2022 18:59 Inactive
@vercel vercel bot temporarily deployed to Preview – hds-components November 21, 2022 19:00 Inactive
@alex-ju alex-ju merged commit 5b3fa44 into main Nov 21, 2022
@alex-ju alex-ju deleted the alex-ju/add-dialog-component branch November 21, 2022 19:09
@hashibot-hds hashibot-hds mentioned this pull request Nov 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants