Skip to content

Instantly share code, notes, and snippets.

@Brettm12345
Created June 22, 2019 05:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Brettm12345/a9056ff0521f4e8735cd74e66cf1c550 to your computer and use it in GitHub Desktop.
Save Brettm12345/a9056ff0521f4e8735cd74e66cf1c550 to your computer and use it in GitHub Desktop.
Media query generator for css in js
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