Last active
August 22, 2019 00:18
-
-
Save Jimmydalecleveland/a5ed951d5e84cbfc6b3e21ea7fb310e9 to your computer and use it in GitHub Desktop.
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
function styled(css, ...variables) { | |
// . . . | |
const computedCss = css | |
.map( | |
(chunk, index) => | |
// now fires a callback at 'variables[index]' | |
`${chunk}${variables[index] ? variables[index](props) : ''}` | |
) | |
.join('') | |
return computedCss | |
} | |
const Button = styled` | |
/* now passes a callback that accepts a 'props' object */ | |
background: ${({ primary, theme }) => | |
primary ? theme.colors.primary : theme.colors.secondary}; | |
/* ... */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment