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 prop to Dialog #907

Merged
merged 3 commits into from
Mar 9, 2023
Merged

Add modal prop to Dialog #907

merged 3 commits into from
Mar 9, 2023

Conversation

lyzadanger
Copy link
Contributor

This PR starts the division of Dialog into modal and non-modal sub-variants. It is possible that one day we will peel this into two components, but for now, one component that can have modal or non-modal behaviors.

More behavior differentiation will be applied to modal vs. non-modal Dialogs, but for now, modal Dialogs get a full-screen backdrop Overlay, sizing and positioning, while non-modal Dialogs do not. A modal example has been added to the Dialog page.

I've also added some next-step TODOs here on Dialog's pattern-library page to sketch out where this is going next.

Next step: some hooks to handle events that should close modal Dialogs.

Part of #77

@@ -14,16 +15,23 @@ import type { PanelProps } from '../layout/Panel';
type ComponentProps = {
/**
* Dialog _should_ be provided with a close handler. We have a few edge use
* cases, however, in which we need to render a "non-closeable" modal.
* cases, however, in which we need to render a "non-closeable" modal dialog.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fix requested in last PR.

Comment on lines +30 to +33
/**
* Make this Dialog modal. Modal dialogs are:
* - Rendered with a full-screen overlay backdrop
*/
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 comment list will get longer and be adjusted as more implementation is done...

Comment on lines +135 to +150
{
// Maximum width and height should not exceed 90vw/h
'max-w-[90vw] max-h-[90vh]': modal,
// Overlay sets up a flex layout centered on both axes. For taller
// viewports, remove this modal container from the flex flow with
// fixed positioning and position it 10vh from the top of the
// viewport. This feels more balanced on taller screens. Ensure an
// equal 10vh gap at the bottom of the screen by adjusting max-height
// to `80vh`.
'tall:fixed tall:max-h-[80vh] tall:top-[10vh]': modal,
},
{
// Max-width rules will ensure actual width never exceeds 90vw
'w-[30rem]': width === 'sm',
'w-[36rem]': width === 'md', // default
'w-[42rem]': width === 'lg',
'w-[30rem]': modal && width === 'sm',
'w-[36rem]': modal && width === 'md', // default
'w-[42rem]': modal && width === 'lg',
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 application of sizing styles will be refined as implementation continues, with the introduction of some of the customization controls presented last week. But for now: Only assert size and positioning for modal Dialogs.

Copy link
Contributor

@acelaya acelaya left a comment

Choose a reason for hiding this comment

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

👍🏼

@lyzadanger lyzadanger merged commit 2435895 into main Mar 9, 2023
@lyzadanger lyzadanger deleted the dialog-modal-support branch March 9, 2023 14: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.

2 participants