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

[breakpoint] Down properties are now inclusive #9632

Merged
merged 8 commits into from Dec 28, 2017
Merged

[breakpoint] Down properties are now inclusive #9632

merged 8 commits into from Dec 28, 2017

Conversation

kgregory
Copy link
Member

@kgregory kgregory commented Dec 27, 2017

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.

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 or isWidthDown 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 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.

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.
Copy link
Member

@oliviertassinari oliviertassinari left a 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');
Copy link
Member

Choose a reason for hiding this comment

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

Missing isHidden with xl.

Copy link
Member Author

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


if (endIndex === keys.length) {
// xl down applies to all sizes
return up('xs');
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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 👍

});

it('should apply to no sizes if unknown size is specified', () => {
assert.strictEqual(breakpoints.down('xxl'), '@media (max-width:-0.05px)');
Copy link
Member

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 😁 .

@@ -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', () => {
Copy link
Member

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.

@oliviertassinari
Copy link
Member

oliviertassinari commented Dec 27, 2017

TL;DR

This 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. It's the same approach used by Bootstrap.

@oliviertassinari oliviertassinari modified the milestones: v1.0.0, v1.0.0-prerelease Dec 27, 2017
@oliviertassinari oliviertassinari added the PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI label Dec 27, 2017
- Updated hidden doc
- Added an isHidden test
- createBreakpoints down will use the key if it is an unspecified breakpoint
- cleaned up createBreakpoints tests
@kgregory
Copy link
Member Author

Thanks for the review @oliviertassinari, let me know if there's anything further on this one!

@oliviertassinari
Copy link
Member

@kgregory You ganna need to run yarn docs:api to fix the CI.

Copy link
Member

@oliviertassinari oliviertassinari left a 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.

@oliviertassinari oliviertassinari removed the PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI label Dec 28, 2017
@oliviertassinari oliviertassinari changed the title [Hidden] down properties are now inclusive [breakpoint] Down properties are now inclusive Dec 28, 2017
@oliviertassinari
Copy link
Member

capture d ecran 2017-12-28 a 14 55 33

- 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
@kgregory
Copy link
Member Author

  • 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, but AppDrawer was not
  • BreakpointDown was reported as a regression, but the current behavior is as expected

@kgregory
Copy link
Member Author

@oliviertassinari The argos difference in BreakpointDown is the expected behavior, given this change. mdDown will hide the children for a medium viewport. How can I get this test to pass?

@oliviertassinari
Copy link
Member

How can I get this test to pass?

@kgregory You need to login and accept the build. I'm doing it now :).

@oliviertassinari oliviertassinari merged commit b72e771 into mui:v1-beta Dec 28, 2017
@oliviertassinari
Copy link
Member

oliviertassinari commented Dec 28, 2017

Let's go. I hope it won't affect people too much 🎲 . @kgregory Good job! :)

@kgregory kgregory deleted the feature/inclusive-breakpoints branch December 28, 2017 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants