Coder Social home page Coder Social logo

crete's Introduction

crete - Simple CSS ruleset generation from a JavaScript object

This generates a CSS ruleset from an object of the form:

var ruleset = {
  sel: 'body',
  'background-color': '#eee',
  color: '#111'
}

The input isn't escaped, and thus this isn't recommended for generating CSS for user input. It was created to make it slightly easier to build pages in requirebin.

To install:

npm install crete --save

The module is just one function. To use:

var crete = require('crete')
console.log(crete(ruleset))

This will output the following:

body {
background-color: #eee;
color: #111;
}

It returns rulesets with a newline at the end, so the returned CSS can be joined together without newlines, as below:

var css = [
  {sel: '*', 'font-family': 'Helvetica, Arial, sans-serif'},
  {sel: 'h1, h2, h3', color: 'purple'}
].map(crete).join('')

It runs on modern browsers with a CommonJS build tool like browserify and should run with old versions of IE if Object.keys and Array.prototype.shim are shimmed.

license

MIT

crete's People

Contributors

benatkin avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.