-
Notifications
You must be signed in to change notification settings - Fork 1k
Make Calendar able to scale down responsively #7583
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
Conversation
const responsiveDaySizeStyle = (props) => { | ||
const breakpoint = props.theme.global.size[props.sizeProp]; | ||
const data = props.theme.calendar[props.sizeProp]; | ||
// try width: 100%; max-width: data.daySize |
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.
// try width: 100%; max-width: data.daySize |
This is implemented, can we remove?
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.
Done
|
||
const responsiveSizeStyle = (props) => { | ||
const breakpoint = props.theme.global.size[props.sizeProp]; | ||
// try width: 100%; max-width: width |
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.
// try width: 100%; max-width: width |
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.
Done
{ value: breakpoint }, | ||
` | ||
height: auto; | ||
aspect-ratio: 7/6; |
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.
Remind me why 7/6? Could we add a comment for future reference?
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.
Answered via slack but replying here also for others benefit. 7 days per week, 6 weeks shown. Pre-existing code does 14.6% width (100%/7) and 6*daySize height.
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.
Good to know, agree adding a comment in the code would be helpful for future
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.
Done
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.
Behavior and styling looks great. Just added a few small comments. Nice find with aspect-ratio
.
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.
Code looks 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.
Looks 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.
Thanks, Mike!
Replaces #7581
What does this PR do?
This PR makes Calendar able to scale down if the specified size is smaller than the viewport.
This is to meet WCAG 1.4.10 Reflow. See #7557 .
Calendar accepts a
size
property that defaults tomedium
(384px). WCAG 1.4.10 requires that certain chunks of information be able to reflow and only require scrolling in 1 direction to see them down to 320px wide. 320px is basically equivalent to a 400% zoom of a 1280 display.The change adds a
@media
query at thesize
of the Calendar. If the viewport width is smaller than this size this adjusts the styles of the Calendar to narrow. This can be disabled by settingresponsive={false}
or by usingfill
.Only the width squishes and not the height so the result can be cells that are non-square. Currently I feel like this is acceptable since it would be a lot more work to scale the height also (although ideas are more than welcome.)UPDATE: Now the Calendar maintains aspect ratio as it shrinks,
Here's an example using the Input/DateInput/Simple story:

Normal size:
At 320px screen width:

At 320px screen width with a highlighted/button date:

Where should the reviewer start?
StyledCalendar.js
What testing has been done on this PR?
Jest and Storybook
How should this be manually tested?
Any of the Calendar or DateInput storys in storybook
Do Jest tests follow these best practices?
screen
is used for querying.asFragment()
is used for snapshot testing.Any background context you want to provide?
What are the relevant issues?
Fixes #7557
Screenshots (if appropriate)
Do the grommet docs need to be updated?
Yes
Should this PR be mentioned in the release notes?
Yes
Is this change backwards compatible or is it a breaking change?
Backwards compatible