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
LR-217 Modal content size updates (Slight API change) #116
Conversation
cd33396
to
c8af0b9
Compare
I will update the documentation / README in the story if we think this API change is good. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like the discussion went well? Please don't merge with my approval alone, just wanting to show support as this LGTM!
@@ -82,6 +89,12 @@ export const useStyles = makeStyles( | |||
maxHeight: 'unset', | |||
}, | |||
}, | |||
contentSize2: { | |||
maxHeight: 'calc(100vh - 9rem)', | |||
'@media screen and (max-width: 480px)': { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does 480 come from? Should it be based off of one of the breakpoints? If so, should we be using a breakpoint function here so it gets the sizes from the theme?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. This PR was my attempt to make as few changes as possible to give us what we needed. 480 was previously hard-coded. We got together yesterday and decided to do a more extensive, non-backward compatible upgrade on this component with new prop names as well as themed breakpoints.
Yes, I was being a bit conservative in trying not to make breaking changes. We have come a long way since this was originally created and want to move forward with prop changes that make more sense. |
I'm going to close this for now since I don't have time to work on it. Will reopen when I get back to it. |
Changes
size={2}
option to allow vertical size increase of Modal up to screen size minus marginfullWidth
option to allow horizontal size increase of Modal up to screen size minus marginPurpose
PHC and other products have fairly complicated UI's that require more flexibility than two Modal sizes. The existing solution is to use the full-screen option. However, there are a couple reasons the full-screen option is not adequate for some use cases.
Currently the width and height of the Modal are controlled by the values of
fullWidth
andsize
.fullWidth={false}
causes the modelwidth
to be set to a hard480px
fullWidth={true}
causes the modelwidth
to be set to a hard600px
size={0}
causes the modelheight
to be able to expand with the content up to256px
size={1}
causes the modelheight
to be able to expand with the content up to480px
Content larger than the above values becomes scrollable within the Modal. This is sometimes okay for vertical scrolling but horizontal scrolling is almost always suboptimal.
BEFORE
modal-updates-before.mp4
Non-breaking change
The first change this PR proposes is an additional
size
value of2
. When set tosize={2}
theheight
is allowed to expand with the content up to the size of the screen minus a significant margin of 3rem (48px) on the top and bottom. This won't affect any existing apps.Breaking change
The second change is with
fullWidth={true}
. Previously this produced a hard width of600px
. Now thewidth
starts at a minimum of600px
, but allows the content to expand the Modal up to the width of the screen minus a margin of 3rem (48px) on the left and right.Technically a breaking change in the API, but in practice, I'm unaware of any use of the Modal that relies on horizontal scrolling of it's content. As mentioned, a slightly wider Modal is almost always better than horizontal scrolling.
Near full-screen
If required by the design, the PR allows for the creation of near full screen Modals that allow for a lot of UI real estate, yet retain a significant border of 48px, enough to provide a visual reminder of the main task a user is involved with.
AFTER
modal-updates-after.mp4
Consistency
We don't want a Modal that only expands to whatever size it's content happens to be. This could produce an app with an handful of randomly sized Modals over time. This PR attempts to keep existing defaults and several good presized options, while at the same time providing the ability create a new size.
When a specific design calls for a bunch of Modals opening at
400x750
to accommodate the UI, this makes that possible. It is easy to limit the size of the content itself, allowing the Modal to constantly enclose itself around that content.PHC BEFORE:
modal-update-phc-before.mp4
PHC AFTER
modal-update-phc-after.mp4