Skip to content

Commit

Permalink
fix(DeviceSize): Update xsmall display handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Oscar Martinez authored and ooHmartY committed Jul 2, 2018
1 parent a7eff3d commit 7541815
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 0 additions & 4 deletions src/components/DeviceSize/Provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ export default class DeviceSizeProvider extends React.Component {
return;
}

this.xSmallMedia = window.matchMedia(constants.breakpoints.xSmall);
this.smallMedia = window.matchMedia(constants.breakpoints.small);
this.mediumMedia = window.matchMedia(constants.breakpoints.medium);
this.largeMedia = window.matchMedia(constants.breakpoints.large);
this.xLargeMedia = window.matchMedia(constants.breakpoints.xLarge);
this.xSmallMedia.addListener(this.setSize);
this.smallMedia.addListener(this.setSize);
this.mediumMedia.addListener(this.setSize);
this.largeMedia.addListener(this.setSize);
Expand All @@ -60,7 +58,6 @@ export default class DeviceSizeProvider extends React.Component {
}

this.setState(() => ({
isXSmall: this.xSmallMedia.matches && !this.smallMedia.matches,
isSmall: this.smallMedia.matches && !this.mediumMedia.matches,
isMedium: this.mediumMedia.matches && !this.largeMedia.matches,
isLarge: this.largeMedia.matches && !this.xLargeMedia.matches,
Expand All @@ -70,7 +67,6 @@ export default class DeviceSizeProvider extends React.Component {
};

unsubscribe = () => {
if (this.xSmallMedia) this.xSmallMedia.removeListener(this.setSize);
if (this.smallMedia) this.smallMedia.removeListener(this.setSize);
if (this.mediumMedia) this.mediumMedia.removeListener(this.setSize);
if (this.largeMedia) this.largeMedia.removeListener(this.setSize);
Expand Down
4 changes: 2 additions & 2 deletions src/theme/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const constants = {
large: "4px"
},
breakpoints: {
xSmall: "(min-width: 1px)",
small: "(min-width: 321px)",
small: "(max-width: 767px)",
medium: "(min-width: 768px)",
large: "(min-width: 1024px)",
xLarge: "(min-width: 1440px)",
xSmallAndDown: "(max-width: 320px)",
mediumAndUp: "(min-width: 481px)",
largeAndUp: "(min-width: 769px)",
xLargeAndUp: "(min-width: 1025px)"
Expand Down
6 changes: 6 additions & 0 deletions src/theme/mediaQueries.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import { css } from "styled-components";

import constants from "./constants";

export const xSmallAndDown = (...args) => css`
@media screen and ${constants.breakpoints.xSmallAndDown} {
${css(...args)};
}
`;

export const mediumAndUp = (...args) => css`
@media screen and ${constants.breakpoints.mediumAndUp} {
${css(...args)};
Expand Down

0 comments on commit 7541815

Please sign in to comment.