Git Product home page Git Product logo

jsoncss's Introduction

Build CSS with JSON and use the full power of JavaScript instead of reinventing wheel with precompilers.

Play with example code in here: http://jussir.net/#/edit/jsonCssExample

blackBox =
  padding: 10
  background: 'black'
  color: 'white'

cssDefinitions =
  '.jsonCssExample':
    # camelCase poperty names transform to kebab-case, e.g.
    # borderRadius -> border-radius
    borderRadius: "10px"
    # pixel values can be defined with plain numbers:
    padding: 10
    background: 'white'
    color: 'black'
    h1:
      fontSize: 14
      # & -sign can be used to mixin definition to parent
      '&': blackBox
      # unlike with jsonHtml, whitespace characters do matter
      '&.second':
        color: "hsl(120, 90%, 45%)"
    ul:
      padding: blackBox.padding
      li:
        # add -v to property to create vendor prefixes
        "filter -v": "blur(2px)"
    '.remove':
      color: 'red'
      margin: 10
  # nested definitions can also be define in one string
  'body pre': blackBox

jsonCss.addStyles(styleId, cssDefinitions)

โ†“

.jsonCssExample {
  border-radius: 10px;
  padding: 10px;global
  background: white;
  color: black;
}
.jsonCssExample h1 {
  font-size: 14px;
}
.jsonCssExample h1 {
  padding: 10px;
  background: black;
  color: white;
}
.jsonCssExample h1.second {
  color: hsl(120, 90%, 45%);
}
.jsonCssExample ul {
  padding: 10px;
}
.jsonCssExample ul li {
  -webkit-filter: blur(2px);
  -moz-filter: blur(2px);
  -ms-filter: blur(2px);
  filter: blur(2px);
}
.jsonCssExample .remove {
  color: red;
  margin: 10px;
}
body pre {
  padding: 10px;
  background: black;
  color: white;
}

Install

Just import dist/jsonCss.min.js

Library uses CommonJS syntax for export, or window.jsonCss when local 'module' variable not defined.

With JSPM, it can be installed directly: jspm install github:jussiry/jsonCss

jsonHtml

Combine with jsonHtml to create compact UI modules with HTML, JS, and controller all in same file. See an example here.

CCSS

This library is a fork from James Campos's CCSS

jsoncss's People

Contributors

jussiry avatar

Watchers

James Cloos 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.