brisky-style

1.2.6 • Public • Published

brisky-style

Build Status js-standard-style npm version Coverage Status

Set style properties on brisky-elements, automatically adds prefixes

basic

  const render = require('brisky/render')
  const app = render({
    field: {
      style: {
        opacity: {
          $: 'animal',
          $transform: (val) => val === 'cat' ? 1 : 0
        }
      }
    }
  }, { animal: 'cat' })
 
  // returns opacity 1 when state.animal equals "cat"

px

Automaticly converts numbers to [number] + px

  • width
  • height
  • left
  • right
  • bottom
  • top
  • margin
  • padding
  const render = require('brisky/render')
  const app = render({
    field: {
      style: {
        width: { $: width }
      }
    }
  }, { width: 100 })
 
  // renders a div with width: 100px

Add your own px property

  const render = require('brisky/render')
  const app = render({
    field: {
      style: {
        something: {
          type: 'px',
          $: 'something'
        }
      }
    }
  }, { something: 100 })
  // renders a div with style - something: 100px

transform

Adds helpers for x y and rotate

  const render = require('brisky/render')
  const app = render({
    field: {
      style: {
        transform: {
          x: { $: 'x' },
          y: { $: 'y' },
          rotate: { $: 'rotate' }
        }
      }
    }
  }, { x: 100, y 100, rotate: 20 })
 
  // renders a div with transform style
  // translate3d(100px,100px,0) scale(0.1) rotate(20deg)

Package Sidebar

Install

npm i brisky-style

Weekly Downloads

0

Version

1.2.6

License

ISC

Last publish

Collaborators

  • vigour-io