Created
March 25, 2020 21:23
-
-
Save nikosantis/b4b0684fe82bcaedb4e278915f0b1968 to your computer and use it in GitHub Desktop.
Media queries for Styled Components
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 { css } from 'styled-components' | |
const breakpoints = { | |
xs: '480px', | |
sm: '768px', | |
md: '992px', | |
lg: '1200px' | |
} | |
export const MQ = Object.keys(breakpoints).reduce((accumulator, label) => { | |
accumulator[label] = (...args) => css` | |
@media (min-width: ${breakpoints[label]}) { | |
${css(...args)} | |
} | |
` | |
return accumulator | |
}, {}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment