/css2obj

Tagged template literal that takes CSS and returns a JavaScript object suitable for free-style

Primary LanguageJavaScriptMIT LicenseMIT

css2obj

Takes CSS-looking properties as an ES6 tagged template literal and returns an object suitable for styles.registerStyle() in Free-Style.

npm install css2obj

Raw example:

const thirty = 30;
const obj = css2obj`
  position: absolute;
  left: 20px;
  bottom: ${thirty}px;
`;

console.log(obj);
/*
{
  'position': 'absolute',
  'left': '20px',
  'bottom': '30px'
}
*/

Example with Free-Style:

const thirty = 30;

styles.registerStyle(css2obj`
  position: absolute;
  left: 20px;
  bottom: ${thirty}px;
`);