Last active
October 18, 2018 12:28
-
-
Save simonfranzen/4cc070d0e0e88da21faf7210e8ca37ef to your computer and use it in GitHub Desktop.
styled-component boilerplate
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 styled, { css } from 'styled-components' | |
import { media } from 'styled-bootstrap-grid' | |
import { padding } from 'polished' | |
const Sample = styled.div` | |
/* 1. Default mobile first styles */ | |
${ padding('10px', '14px', '10px', '8px') } | |
color: black; | |
/* 2. DOM element states (hover, active, ...) */ | |
&:hover{ | |
color: green; | |
} | |
/* 3. Modifiers with properties */ | |
${props => props.primary && css` | |
color: red; | |
`} | |
/* 4. Child element stylings (layouting only) */ | |
& > ${Header} { | |
font-size: 2em; | |
} | |
/* 5. Media queries (order phone -> giant) */ | |
${media.phone` | |
`} | |
${media.tablet` | |
`} | |
${media.desktop` | |
`} | |
${media.giant` | |
`} | |
` | |
export default Sample |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment