5.0.0 • Published 3 years ago

@dntly/cssjson v5.0.0

Weekly downloads
22
License
ISC
Repository
-
Last release
3 years ago

Donately CssJson

Convert CSS <> JSON && JSON <> CSS

For use as custom styles in a Donately Donation Form from Donately

Install

npm install @dntly/cssjson

Usage

const DntlyCssJson = require('@dntly/cssjson')
const CssJson = new DntlyCssJson()

const myCss = `body {
  font-weight: bold
}
h1 {
  font-size: 2em
}
`
const convertedJson = CssJson.toJSON(myCss)
// returns JSON

console.log('convertedJson:', convertedJson)

const myJson = { body: { 'font-weight': 'bold' }, h1: { 'font-size': '2em' } }
const convertedCss = CssJson.toCSS(myJson)
// returns CSS

console.log(`convertedCss: ${convertedCss}`)

const malformedCss = `.unfinished {`
const parseError = CssJson.validateInput(malformedCss)
// returns 'Unclosed block'

console.log(`parseError: ${parseError}`)