Created
March 20, 2021 05:45
-
-
Save willmendesneto/fc4b5537f3712e3bd3d2e32f4731dacb to your computer and use it in GitHub Desktop.
Helper for CSS-In-JS Media Query integration on Components
This file contains hidden or 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
/** | |
* Helper for CSS-In-JS Media Query integration on Components | |
* | |
* Usage: | |
* // It's using `styled-components` package, but it can be used in any CSS-IN-JS package solution | |
* | |
* import styled from 'styled-components'; | |
*. | |
*. const MyDiv = styled.div` | |
display: inline-block; | |
position: absolute; | |
right: 0; | |
${screen.md} { | |
display: block; | |
} | |
`; | |
*/ | |
// Screen sizes used in your app | |
const sizes = { | |
sm: '320px', | |
md: '768px', | |
lg: '1024px', | |
xl: '1280px', | |
}; | |
// Breakpoints based on your configuration | |
export const breakpoints = { | |
sm: `@media (min-width: ${sizes.sm})`, | |
md: `@media (min-width: ${sizes.md})`, | |
lg: `@media (min-width: ${sizes.lg})`, | |
xl: `@media (min-width: ${sizes.xl})`, | |
max: `${sizes.xlg}`, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment