@rhizo/seed-get

1.0.12 • Public • Published

@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),
}))

Readme

Keywords

none

Package Sidebar

Install

npm i @rhizo/seed-get

Weekly Downloads

2

Version

1.0.12

License

MIT

Unpacked Size

3.77 kB

Total Files

7

Last publish

Collaborators

  • chazeprasad