Created
June 22, 2019 05:19
-
-
Save Brettm12345/a9056ff0521f4e8735cd74e66cf1c550 to your computer and use it in GitHub Desktop.
Media query generator for css in js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { curry, pipe, prop } from 'rambda' | |
import layout from 'theme/layout' | |
const media = value => | |
`@media (${Array.isArray(value) ? value.join('and') : value})` | |
const minWidth = curry(bp => `min-width: ${prop(bp, layout.breakpoints)}`) | |
const maxWidth = curry(bp => `max-width: ${prop(bp, layout.breakpoints)}`) | |
export const up = pipe( | |
minWidth, | |
media | |
) | |
export const down = pipe( | |
maxWidth, | |
media | |
) | |
export const between = (down, up) => media([minWidth(down), maxWidth(up)]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment