Last active
August 26, 2020 22:54
-
-
Save LevPewPew/1c0ee51d3bf786b6c3cda15a34b5f8c4 to your computer and use it in GitHub Desktop.
responsive "mixins" breakpoints for style 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
import { css } from 'styled-components'; | |
const breakpoints = { | |
smallScreen: 1200, | |
tablet: 768, | |
mobile: 520, | |
smallMobile: 375 | |
}; | |
export const respondTo = Object.keys(breakpoints).reduce((accumulator, label) => { | |
accumulator[label] = (...args) => css` | |
@media (max-width: ${breakpoints[label] + 'px'}) { | |
${css(...args)}; | |
} | |
`; | |
return accumulator; | |
}, {}); |
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
import { COLORS, respondTo } from 'styles'; | |
const SideBarOffset = styled.div` | |
background-color: ${COLORS.MAIN};; | |
height: 100%; | |
width: ${(props) => props.offset + 'px'}; | |
flex-basis: auto; | |
${respondTo.tablet` | |
width: 0px; | |
`} | |
`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment