2017-01-03 17:46:43 +02:00
|
|
|
const styled = require('styled-components');
|
|
|
|
|
2017-02-06 16:51:55 +02:00
|
|
|
const {
|
|
|
|
css
|
|
|
|
} = styled;
|
|
|
|
|
2017-01-03 17:46:43 +02:00
|
|
|
// github.com/kristoferjoseph/flexboxgrid/blob/master/dist/flexboxgrid.css
|
2017-02-03 13:25:29 +02:00
|
|
|
const small = {
|
|
|
|
upper: '48rem'
|
|
|
|
};
|
|
|
|
|
|
|
|
const medium = {
|
|
|
|
upper: '64rem',
|
|
|
|
lower: '48.1rem',
|
|
|
|
};
|
|
|
|
|
|
|
|
const large = {
|
|
|
|
upper: '75rem',
|
|
|
|
lower: '64.1rem',
|
|
|
|
};
|
|
|
|
|
|
|
|
const xlarge = {
|
|
|
|
lower: '75.1rem',
|
|
|
|
};
|
|
|
|
|
|
|
|
const screen = 'only screen';
|
|
|
|
|
2017-01-03 17:46:43 +02:00
|
|
|
const screens = {
|
|
|
|
// >= 768px
|
2017-02-03 14:35:33 +02:00
|
|
|
'smallOnly': `${screen} and (max-width: ${small.upper})`,
|
2017-02-03 13:25:29 +02:00
|
|
|
'small': `${screen} and (min-width: ${small.upper}})`,
|
2017-01-03 17:46:43 +02:00
|
|
|
// >= 1024px
|
2017-02-06 16:51:55 +02:00
|
|
|
'mediumOnly': `${screen} and (min-width: ${medium.lower})
|
2017-02-03 13:25:29 +02:00
|
|
|
and (max-width: ${medium.upper})`,
|
2017-02-03 15:27:14 +02:00
|
|
|
'mediumDown': `${screen} and (max-width: ${medium.upper})`,
|
2017-02-03 13:25:29 +02:00
|
|
|
'medium': `${screen} and (min-width: ${medium.lower})`,
|
2017-01-03 17:46:43 +02:00
|
|
|
// >= 1200px
|
2017-02-06 16:51:55 +02:00
|
|
|
'largeOnly': `${screen} and (min-width: ${large.lower})
|
2017-02-03 13:25:29 +02:00
|
|
|
and (max-width: ${large.upper})`,
|
2017-02-03 15:27:14 +02:00
|
|
|
'largeDown': `${screen} and (max-width: ${large.upper})`,
|
2017-02-03 13:25:29 +02:00
|
|
|
'large': `${screen} and (min-width: 75rem)`,
|
|
|
|
|
2017-02-06 16:51:55 +02:00
|
|
|
'xlarge': `${screen} and (min-width: ${xlarge.lower})
|
2017-02-03 13:25:29 +02:00
|
|
|
and (max-width: ${xlarge.upper})`,
|
2017-02-03 15:27:14 +02:00
|
|
|
'xlargeUp': `${screen} and (min-width: ${xlarge.lower})`,
|
2017-01-03 17:46:43 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const breakpoints = Object.keys(screens).reduce((acc, label) => {
|
|
|
|
return {
|
|
|
|
...acc,
|
2017-02-06 16:51:55 +02:00
|
|
|
[label]: (...args) => css`
|
2017-01-03 17:46:43 +02:00
|
|
|
@media ${screens[label]} {
|
2017-02-06 16:51:55 +02:00
|
|
|
${css(...args)}
|
2017-01-03 17:46:43 +02:00
|
|
|
}
|
|
|
|
`
|
|
|
|
};
|
|
|
|
}, {});
|
|
|
|
|
|
|
|
module.exports = breakpoints;
|