@dntly/cssjson
v5.0.0
Published
Convert CSS <> JSON for use as custom styles in a Donately Donation Form
Downloads
149
Maintainers
Readme
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}`)