1.0.12 • Published 2 years ago

@rhizo/seed-get v1.0.12

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

@rhizo/seed-get

The seedGet function is an existential getter function that can be used in any style declaration to get a value from your seed, with support for fallback values. This helps prevent errors from throwing when a seed value is missing, which can be helpful when unit testing styled-components.

npm i @rhizo/seed-get
seedGet(objectPath, fallbackValue)(props)

seedGet returns a function that accepts props as an argument (seedGet(objectPath)(props)), which when used in a tagged template literal should look like this:

import styled from 'styled-components'
import { seedGet } from '@rhizo/seed-get'

const Box = styled.div`
  border-radius: ${seedGet('radii.small', '4px')};
`

When used with object literal syntax, seedGet needs to be in a function call and have props passed to it:

import styled from 'styled-components'
import { seedGet } from '@rhizo/seed-get'

const Box = styled('div')(props => ({
  borderRadius: seedGet('radii.small', '4px')(props),
}))
1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago