json-to-css

0.1.0 • Public • Published

Json to Css

Converts JSON to Css

This module exists so that you can store inline styles in JSON files, in a structured way. It is utilised by vudash among others, to allow storage of CSS rules inside a configuration file in a better way than just bunging it in a string.

It can also make merging two sets of CSS easy - meaning that third-parties don't have to understand your existing CSS and how it cascades, in order to replace rules.

Build Status Standard - JavaScript Style Guide

Dependencies

This module has no external dependencies.

Install

npm install json-to-css

API

  • Css
    • [string] of(json)
      • Returns a minified version of the css rules defined in json

Usage

const Css = require('json-to-css')
const json = require('./some-css.json')
 
const css = Css.of(json)
console.log(css)

Output

You can get a pretty good idea of what the generated CSS looks like by looking at the tests, but in a pinch it produces a somewhat minified css output. Something like:

const json = require('my-css.json')
// {
//  "h1": {
//    "font-size": "18vw",
//    "color": "#f00"
//  }
// }
 
const css = Css.of(json)
// h1{font-size:18vw;color:#f00;}

Readme

Keywords

Package Sidebar

Install

npm i json-to-css

Weekly Downloads

435

Version

0.1.0

License

MIT

Unpacked Size

3.62 kB

Total Files

6

Last publish

Collaborators

  • antony