Skip to content

Instantly share code, notes, and snippets.

View AlfieDarko's full-sized avatar

Alfie Darko AlfieDarko

View GitHub Profile
@granmoe
granmoe / __responsive styled components
Last active January 6, 2021 02:22
Programmatically create responsive styled components with react and styled-components
// this file is just here to change the name of the gist
import React from 'react'
import styled from 'styled-components'
const makeResponsiveComponent = (rulesets, tagName = 'div') =>
styled(tagName)`${buildStyles(rulesets)}`
const buildStyles = rulesets =>
rulesets.reduce(
(cssString, { constraint, width, rules }) =>