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
[breakpoint] Down properties are now inclusive #9632
[breakpoint] Down properties are now inclusive #9632
Conversation
xsDown, smDown, mdDown, lgDown, and xlDown match the behavior of their *Up* counterparts and are now inclusive of the specified breakpoint. This is consistent between the CSS and JS implementation of this component. Additionally, `theme.breakpoints.down` has been altered to match this behavior. This function is now consistent with its `up` and `only` counterparts. Documentation has been updated, as well as internal dependence on the `down` function. The implementation of isWidthDown has been altered so that its default behavior is to be inclusive (this was hinted in an associated comment, but was not the case). The decision to move forward with this PR was made following a conversation with @oliviertassinari and @rosskevin, which resulted in a conclusion that it would be better to deal with this inconsistency and the breaking changes its solution would require while we are in beta. These are the following breaking changes: - 'createBreakpoints.down' is now inclusive of the specified breakpoint - `isWidthDown` is now inclusive of the specified breakpoint by default - `Hidden` will include the breakpoints associated with its *Down* properties regardless of whether CSS or JS is used.
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.
It's a very good start :).
Don't forget to update this section too https://material-ui.com/layout/hidden/#how-it-works
@@ -136,7 +135,7 @@ describe('<HiddenJs />', () => { | |||
}); | |||
|
|||
describe('down', () => { | |||
isVisible(['xs', 'sm', 'md', 'lg', 'xl'], 'Down', 'xl'); |
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.
Missing isHidden
with xl
.
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.
This has been dealt with
src/styles/createBreakpoints.js
Outdated
|
||
if (endIndex === keys.length) { | ||
// xl down applies to all sizes | ||
return up('xs'); |
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.
Humm, maybe we should just warn. What's the point of using?
root: {
color: 'red',
[theme.breakpoints.down('xl')]: {
color: 'blue',
},
},
Isn't it equivalent to?
root: {
color: 'blue',
},
Aside of the warning. I have my doubt about this new logic.
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.
The same could be said for xsUp
, which applies to all sizes (min-width: 0px), which is why I did it this way.
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.
Ok, let's not add a warning as someone might want to do it this way to beat specificity. The logic is correct 👍
src/styles/createBreakpoints.spec.js
Outdated
}); | ||
|
||
it('should apply to no sizes if unknown size is specified', () => { | ||
assert.strictEqual(breakpoints.down('xxl'), '@media (max-width:-0.05px)'); |
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.
Humm. Do we have a test with a number as first argument? I'm not sure we want to test xxl
😁 .
src/styles/createBreakpoints.spec.js
Outdated
@@ -21,8 +21,20 @@ describe('createBreakpoints', () => { | |||
}); | |||
|
|||
describe('down', () => { | |||
it('should work', () => { | |||
assert.strictEqual(breakpoints.down('md'), '@media (max-width:959.95px)'); | |||
it('should work for xs', () => { |
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.
Using sm
instead of xs
would have allowed showing that the assertion don't change.
TL;DRThis pull-request is about the intuitiveness of the API. Always using an inclusive behavior instead of having to remember what's inclusive and what's exclusive. |
- Updated hidden doc - Added an isHidden test - createBreakpoints down will use the key if it is an unspecified breakpoint - cleaned up createBreakpoints tests
Thanks for the review @oliviertassinari, let me know if there's anything further on this one! |
@kgregory You ganna need to run |
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.
Let's cross our fingers and wait for people feedback 👌🏻 once it's released.
- AppDrawer and ResponsiveDrawer were using *Down properties that needed to be shifted down one breakpoint due to the changes in this PR - ResponsiveDrawer was reported in Argos - AppDrawer was not reported in Argos - BreakpointDown was reported as a regression, but the current behavior is as expected
…regory/material-ui into feature/inclusive-breakpoints
|
@oliviertassinari The argos difference in |
@kgregory You need to login and accept the build. I'm doing it now :). |
Let's go. I hope it won't affect people too much 🎲 . @kgregory Good job! :) |
xsDown
,smDown
,mdDown
,lgDown
, andxlDown
match the behavior of their Up counterparts and are now inclusive of the specified breakpoint. This is consistent between the CSS and JS implementation of this component.Additionally,
theme.breakpoints.down
has been altered to match this behavior. This function is now consistent with itsup
andonly
counterparts.The implementation of isWidthDown has been altered so that its default behavior is to be inclusive (this was hinted in an associated comment, but was not the case).
Documentation has been updated, as well as internal dependence on the
down
orisWidthDown
functions.The decision to move forward with this PR was made following a conversation with @oliviertassinari and @rosskevin, which resulted in a conclusion that it would be better to deal with this inconsistency and the breaking changes its solution would require while we are in beta.
Breaking changes
createBreakpoints.down()
is now inclusive of the specified breakpointisWidthDown()
is now inclusive of the specified breakpoint by default<Hidden />
will include the breakpoints associated with its Down properties regardless of whether CSS or JS is used.