Skip to content

djavaweb/unobuilder-style-to-object

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⛳ 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

About

⛳️ Convert native CSS properties to unobuilder object

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published