1 | import { css } from 'styled-components'
|
2 |
|
3 | const sizes = {
|
4 | phone: 321,
|
5 | phoneMax: 414,
|
6 | tablet: 768,
|
7 | mobileNav: 889,
|
8 | tabletMax: 960,
|
9 | laptop: 1024,
|
10 | desktop: 1440
|
11 | }
|
12 |
|
13 | const breakpoints = {
|
14 | landscape: '(orientation: landscape)',
|
15 | portrait: '(orientation: portrait)'
|
16 | }
|
17 |
|
18 | Object.keys(sizes).forEach((label) => {
|
19 | breakpoints[`below${label.charAt(0).toUpperCase()}${label.substr(1)}`] =
|
20 | `(max-width: ${sizes[label] - 1}px)`
|
21 | breakpoints[`above${label.charAt(0).toUpperCase()}${label.substr(1)}`] =
|
22 | `(min-width: ${sizes[label]}px)`
|
23 | })
|
24 |
|
25 | export { breakpoints, sizes }
|
26 |
|
27 | export default Object.keys(sizes).reduce((accumulator, label) => {
|
28 |
|
29 |
|
30 | const remSize = sizes[label] / 10
|
31 | accumulator[label] = (...args) => css`
|
32 | @media (min-width: ${remSize}em) {
|
33 | ${css(...args)}
|
34 | }
|
35 | `
|
36 | return accumulator
|
37 | }, {})
|
38 |
|
39 | export const breakpointsVerbose = Object.keys(breakpoints).reduce((accumulator, label) => {
|
40 |
|
41 |
|
42 | accumulator[label] = (...args) => css`
|
43 | @media ${breakpoints[label]} {
|
44 | ${css(...args)}
|
45 | }
|
46 | `
|
47 | return accumulator
|
48 | }, {})
|