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

Modal, ConfirmModal components and design patterns #88

Merged
merged 3 commits into from
Jun 7, 2021

Conversation

lyzadanger
Copy link
Contributor

@lyzadanger lyzadanger commented Jun 3, 2021

This (initially draft) PR contains new Modal and ConfirmModal components and their corresponding supporting design patterns and pattern-library content.

Modal wraps a Dialog and adds a background overlay and a close-on-outside-click functionality. Modal + Dialog here = the Dialog component in the client. ConfirmModal is analogous to ConfirmDialog in the client and doesn't deviate too much from it.

I've added some responsiveness to the modal positioning and sizing in this variant. See implementation and comments for details (a test to see if the source is self-documenting and commented enough).

In draft until...

  • Feedback gathered about general approach, design
  • Tests added (after that)

To try it out

Check out this branch, run make dev and visit the new Dialogs pattern library page in your browser. The modal examples are last on the page.

Screenshots

Note that the pattern-library examples include all supported Dialog bells and whistles, including an icon in the header, which may not be applicable to modals. But it's helpful to see everything in the mix...

Modal, narrow viewport (with initial-focus input):

The same Modal, wider viewport:

image

ConfirmModal, narrow viewport:

ConfirmModal, narrow viewport, with excessively long content (NB, this example is not included in source):

ConfirmModal, wider viewport:

C1268CBD-4F24-4A0E-A10F-037E7E8C80EA

Fixes #86

The newer `Example` layout for pattern-library examples is more
conducive to responsive-ness than the older `PatternExamples` and
`PatternExample` styling. Make it columnar on narrower screens.

`Example` is still a prototype layout, but may supersede/replace the
table-based `PatternExample(s)` styling in the future.

The `Example` layout is used on the `Dialogs` component pattern library
page, and it needs to be responsive so one can view the responsive
modal patterns in a responsive setting.
@lyzadanger lyzadanger requested a review from robertknight June 3, 2021 14:00
// of viewport.
// - sizing: Set a min-width to make sure the modal isn't too dinky. Set
// a max-width to make sure it isn't too ginormously wide on wide screens.
@media screen and (min-width: 48rem) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bah, I had it in an earlier comment here but then deleted it and neglected to re-add: this 48rem magic is a rem-translation of the 768px tablet breakpoint from the client. I will make sure to add commenting.

@robertknight
Copy link
Member

Some feedback on the pattern library unrelated to the changes in this PR: The different font sizes for the component description and example description looks a bit odd, possibly because they are visually part of the same region (that is to say, there is no border or background separating the two paragraphs):

Pattern library typography

@lyzadanger
Copy link
Contributor Author

Some feedback on the pattern library unrelated to the changes in this PR: The different font sizes for the component description and example description looks a bit odd, possibly because they are visually part of the same region (that is to say, there is no border or background separating the two paragraphs):

Noted! There is work to do here, for sure.

@robertknight
Copy link
Member

I noticed that the vertical positioning of modals is sensitive to the width of the dialog as well as the height. Wide viewport:

Narrow viewport

Same viewport height but narrower:

Wide viewport

To me it would make more sense if the vertical position depended only on the height.

Copy link
Member

@robertknight robertknight left a comment

Choose a reason for hiding this comment

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

Overall this looks great. I didn't have a lot of comments to add. What use cases did you have in mind for Dialogs that are not Modals?


// For wider viewports:
// - positioning: keep horizontal centering but bring top nearer to top
// of viewport.
Copy link
Member

Choose a reason for hiding this comment

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

I noted this in another comment, but I think we might want to make the vertical centering behavior dependent on the height rather than the width of the viewport.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's good feedback. I'm working on splitting the media-query-based differentiation out into two now:

  • Screens that are wide enough: set a reasonable min- and max-width so that the modal isn't too dinky but also doesn't stretch way out
  • Screens that are tall enough: position the modal nearer to the top of the viewport

e.g. Narrow, but tall screen:

image

@lyzadanger
Copy link
Contributor Author

lyzadanger commented Jun 4, 2021

I didn't have a lot of comments to add. What use cases did you have in mind for Dialogs that are not Modals?

I wanted to evaluate replacing a couple of what are now Panel elements in the client with Dialog—the salient difference being that Dialog can route focus. We had an organization raise an a11y flag on a couple of the Panel elements in the client (e.g. the one that alerts you that you need to log in before you can annotate) because of focus issues.

@lyzadanger lyzadanger changed the title For draft review: Modal, ConfirmModal components and design patterns Modal, ConfirmModal components and design patterns Jun 4, 2021
@lyzadanger lyzadanger marked this pull request as ready for review June 4, 2021 16:20
@codecov
Copy link

codecov bot commented Jun 4, 2021

Codecov Report

Merging #88 (6a35284) into main (27f98fa) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main       #88   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            7         8    +1     
  Lines          115       123    +8     
  Branches        38        39    +1     
=========================================
+ Hits           115       123    +8     
Impacted Files Coverage Δ
src/components/Modal.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 27f98fa...6a35284. Read the comment docs.

Copy link
Member

@robertknight robertknight left a comment

Choose a reason for hiding this comment

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

I had some minor queries but overall this looks good. Please have a look through and make changes as you see fit.


// This sizing applies to smaller viewports
width: 90vw;
max-width: 90vw;
Copy link
Member

Choose a reason for hiding this comment

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

I noticed a jump as the dialog shrinks in size when going from a width that is less than the min-width media query below to one that is greater.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What would your preferred behavior be? I'm never sure how best to optimize for the "but it isn't animated/smooth when resizing a screen" issue...

@lyzadanger lyzadanger merged commit b394593 into main Jun 7, 2021
@lyzadanger lyzadanger deleted the Modal-component branch June 7, 2021 17:49
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.

Implement needed Modal components
2 participants