Skip to content

Instantly share code, notes, and snippets.

@LevPewPew
Last active August 26, 2020 22:54
Show Gist options
  • Save LevPewPew/1c0ee51d3bf786b6c3cda15a34b5f8c4 to your computer and use it in GitHub Desktop.
Save LevPewPew/1c0ee51d3bf786b6c3cda15a34b5f8c4 to your computer and use it in GitHub Desktop.
responsive "mixins" breakpoints for style components
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;
}, {});
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