Skip to content

kumarikandam/control-style

Repository files navigation

@lemuria/control-style

npm version

@lemuria/control-style is Extracts CSS Properties From Component Properties Map And Returns The Composed Style.

yarn add @lemuria/control-style

Table Of Contents

API

The package is available by importing its default function:

import controlStyle from '@lemuria/control-style'

controlStyle(
  style: string|undefined,
  props: Object<string, ?>,
): void

Extracts CSS Properties From Component Properties Map And Returns The Composed Style. Returns the joined style as the string, or a hash with the style rules if no style was given. Deletes CSS properties from the passed props object.

import controlStyle from '@lemuria/control-style'

const Component = ({ style, ...props }) => {
  return controlStyle(style, props)
}

// return as string
const res = Component({
  style: 'padding: 10px',
  margin: '1rem',
  'border-radius': '5px'
})
console.log(res)

// return as object
const res1 = Component({
  margin: '1rem',
  'border-radius': '5px',
})
console.log(res1)
margin:1rem;border-radius:5px;padding: 10px
{ margin: '1rem', 'border-radius': '5px' }

Copyright

(c) Art Deco 2019

About

Extracts CSS Properties From Component Properties Map And Returns The Composed Style.

Resources

License

Stars

Watchers

Forks

Packages

No packages published