Skip to content

Commit

Permalink
feat: breakpoints js and scss media variables exported
Browse files Browse the repository at this point in the history
  • Loading branch information
juliaam committed Mar 1, 2024
1 parent 3d720ca commit 421437c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/styles/breakpoints.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@import 'breakpoints';

:export {
extraSmallSize: $extraSmallDeviceSizeMin;
smallSize: $smallDeviceSizeMin;
mediumSize: $mediumDeviceSizeMin;
largeSize: $largeDeviceSizeMin;
largestSize: $largestDeviceSizeMin;
}
27 changes: 27 additions & 0 deletions src/utils/breakpoints.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import variables from '../styles/breakpoints.module.scss';

const { extraSmallSize, smallSize, mediumSize, largeSize, largestSize } =
variables;

export default function breakpointJs() {
const obj = {
from320: false,
from360: false,
from667: false,
from1024: false,
from1280: false,
};

if (window.matchMedia(`(min-width: ${largestSize})`).matches) {
obj.from1280 = true;
} else if (window.matchMedia(`(min-width: ${largeSize})`).matches) {
obj.from1024 = true;
} else if (window.matchMedia(`(min-width: ${mediumSize})`).matches) {
obj.from667 = true;
} else if (window.matchMedia(`(min-width:${smallSize})`).matches) {
obj.from360 = true;
} else if (window.matchMedia(`(min-width: ${extraSmallSize})`).matches) {
obj.from320 = true;
}
return obj;
}

0 comments on commit 421437c

Please sign in to comment.