@dntly/cssjson

5.0.0 • Public • Published

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}`)

Package Sidebar

Install

npm i @dntly/cssjson

Weekly Downloads

17

Version

5.0.0

License

ISC

Unpacked Size

147 kB

Total Files

5

Last publish

Collaborators

  • dntly