Skip to content

Define and insert CSS via javascript. This also generates unique class and id names automatically. Handy when using virtual-dom (or react) inline css as your primary styling.

License

Notifications You must be signed in to change notification settings

smallhelm/js-managed-css

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

js-managed-css

build status dependency status

Define and insert CSS via javascript. This also generates unique class and id names automatically. Handy when using virtual-dom (or react) inline css as your primary styling.

var jsCss = require("js-managed-css");

var btn_height = 10;

var vars = jsCss({
  ".$btn": {
    "color": "blue",
    "height": btn_height + "px",
    ":hover": {
      "color": "red"
    },
    "&.active": {
      "color": "yello"
    }
  },
  "#$nav": {
    "> .$link": {
      "margin": "0 auto"
    }
  }
});

//At this point your css was compiled and inserted into the DOM
//"vars" is an object where the keys are your variable names and
//the values are the generated names

//now in your rendering code you can use variables from your css 
h("a." + vars.btn, "click me")

Why?

Modular css code that lives right next to the js code that depends on it.

License

MIT

About

Define and insert CSS via javascript. This also generates unique class and id names automatically. Handy when using virtual-dom (or react) inline css as your primary styling.

Resources

License

Stars

Watchers

Forks

Packages

No packages published