-
Notifications
You must be signed in to change notification settings - Fork 645
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
I made a suggestion in #368 that I think allows us to at least remove the fallback values from our styled-system themeGet() calls. Rather than this:
import {themeGet} from 'styled-system'
import {colors} from './theme'
const Component = styled('div')`
color: ${themeGet('colors.green.5', colors.green[5])};
`We can export a get() function from theme.js using styled-system's own get() function to compute the fallback value:
import {get as getKey, themeGet} from 'styled-system'
export const get = key => themeGet(key, getKey(theme, key))...which simplifies our components that use themeGet() nicely:
import {get} from './theme'
const Component = styled('div')`
color: ${get('colors.green.5')};
`This does allow us to get rid of defaultProps.theme in cases where we only use themeGet(), but other system props will still need theme to be set outside of a ThemeProvider to work properly. 😕
/cc @mxstbr
colebemis
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request