Skip to content

Instantly share code, notes, and snippets.

@johnnyBira
Last active March 30, 2019 13:48
Show Gist options
  • Save johnnyBira/db376b785a5e6b5aa4ccec423ac1b4a6 to your computer and use it in GitHub Desktop.
Save johnnyBira/db376b785a5e6b5aa4ccec423ac1b4a6 to your computer and use it in GitHub Desktop.
Medium #1 - Grid Example 2
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