unobuilder-style-to-object

1.3.0 • Public • Published

⛳️ Unobuilder Style to Object

Convert native CSS properties to unobuilder object

Install

Using NPM:
npm install unobuilder-style-to-object

Using Yarn:
yarn add unobuilder-style-to-object

Usage

Native CSS Properties are object that should be generated from getComputedStyle

import cssToProps from 'unobuilder-style-to-object'
 
const nativeProps = window.getComputedStyle(document.querySelector('#my-element'))
const cssProps = cssToProps(nativeProps)
 
console.log(cssProps)
/*
{
  backgroundColor: {
    value: {
      hsl: {
        h:0,
        s:0,
        l:0,
        a:1
      },
      hex: '#000000',
      rgba: {
        r:0,
        g:0,
        b:0,
        a:1
      },
      hsv: {
        h:0,
        s:0,
        v:0,
        a:1
      },
      oldHue: 0
      source: 'rgb',
      a:1
    }
  },
  display: {
    value: 'block'
  },
  width: {
    value: 10,
    unit: 'px'
  }
}
*/

License

MIT © djavaweb

Readme

Keywords

Package Sidebar

Install

npm i unobuilder-style-to-object

Weekly Downloads

0

Version

1.3.0

License

MIT

Last publish

Collaborators

  • oknoorap