Last active
March 30, 2019 13:48
-
-
Save johnnyBira/db376b785a5e6b5aa4ccec423ac1b4a6 to your computer and use it in GitHub Desktop.
Medium #1 - Grid Example 2
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 withResponsiveProps from 'responsive-props' | |
import styled from 'styled-components' | |
// A column component created with Styled Components | |
const Column = styled.div` | |
// Base styles | |
box-sizing: border-box; | |
width: 100%; | |
flex: 0 0 auto; | |
padding: 1rem, | |
// Apply styles from responsive props | |
${({ responsiveProps }) => responsiveProps} | |
`; | |
// Span mixin example | |
// The `cols` argument will be take from the span prop passed to the component | |
const span = (cols) => ` | |
// calculate the width | |
width: ${cols / 12 * 100 }%; | |
` | |
export const withResponsiveProps( | |
// Wrapped styled component | |
Column, | |
// Mixins | |
{span: span} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment