Code Monkey home page Code Monkey logo

jss's Introduction

JSS

Gitter Build Status codecov bitHound Score OpenCollective OpenCollective

JSS is a more powerful abstraction over CSS. It uses JavaScript as a language to describe styles in a declarative and maintainable way. It is a high performance JS to CSS compiler which works at runtime and server-side. This core library is low level and framework agnostic. It is about 6KB (minified and gzipped) and is extensible via plugins API.

Feel free to ask any JSS related questions on twitter by using hashtag #cssinjs and mentioning @oleg008.

Integrations

Official

TOC

  1. Live examples.
  2. Benefits
  3. Setup
  4. JSON API (JSS Syntax)
  5. JavaScript API
  6. Server-side rendering
  7. Performance
  8. Plugins API
  9. Official plugins
  10. All related projects
  11. CLI Converter
  12. Contributing

Example

Try it out on webpackbin. You need to setup plugins before. You can use a preset for a quick setup with default plugins.

import jss from 'jss'
import preset from 'jss-preset-default'
import color from 'color'

// One time setup with default plugins and settings.
jss.setup(preset())

const styles = {
  button: {
    fontSize: 12,
    '&:hover': {
      background: 'blue'
    }
  },
  ctaButton: {
    extend: 'button',
    '&:hover': {
      background: color('blue').darken(0.3).hex()
    }
  },
  '@media (min-width: 1024px)': {
    button: {
      width: 200
    }
  }
}

const {classes} = jss.createStyleSheet(styles).attach()

document.body.innerHTML = `
  <button class="${classes.button}">Button</button>
  <button class="${classes.ctaButton}">CTA Button</button>
`

Result

<head>
  <style type="text/css">
    .button-123456 {
      font-size: 12px;
    }
    .button-123456:hover {
      background: blue;
    }
    .ctaButton-789012 {
      font-size: 12px;
    }
    .ctaButton-789012:hover {
      background: red;
    }
    @media (min-width: 1024px) {
      .button-123456 {
        min-width: 200px;
      }
    }
  </style>
</head>
<body>
  <button class="button-123456">Button</button>
  <button class="ctaButton-789012">CTA Button</button>
</body>

When should I use it?

  • You build a JavaScript heavy application.
  • You use components based architecture.
  • You build a reusable UI library.
  • You need a collision free CSS (external content, third-party UI components ...).
  • You need code sharing between js and css.
  • Minimal download size is important to you.
  • Robustness and code reuse is important to you.
  • Ease of maintenance is important to you.
  • You just want to use any of its benefits

Roadmap

  • Make it easier for newcomers to setup jss with plugins (like presets).
  • Make JSON DSL even better, for e.g. jss-expand.
  • Make it easy to see when changes in the core break plugins (integrate plugins test suite).
  • Make community create plugins (better plugins API documentation, infrastructure).
  • Introduce a way for theming with react-jss
  • Help release material-ui alpha version.
  • Use ISTF
  • Better React Native support.
  • Stylelint integration #490.
  • Source maps #469
  • Flow and typescript typings for the JSON DSL #375 #361
  • Do more benchmarking, include plugins, always track perf regressions.
  • Make SSR even better (vendor prefixer server-side, smaller critical CSS)
  • Make CLI tool better: allow integration of styles written in various preprocessing languages as well as pure css #166

Browsers Support

We have automated tests running in real browsers.

License

MIT

Thanks

Thanks to BrowserStack for providing the infrastructure that allows us to run our tests in real browsers and to all awesome contributors.

Backers

Support us with a monthly donation and help us continue our activities. [Become a backer]

Sponsors

Chatgrape

Become a sponsor and get your logo on our README on Github with a link to your site. [Become a sponsor]

jss's People

Contributors

0xr avatar ai avatar avocadowastaken avatar b2whats avatar bigslycat avatar denisizmaylov avatar gitter-badger avatar greenkeeperio-bot avatar jedwards1211 avatar joshgillies avatar kof avatar lestad avatar lttb avatar mindjuice avatar nathanmarks avatar npmcdn-to-unpkg-bot avatar okonet avatar oliviertassinari avatar piamancini avatar qimingweng avatar sapegin avatar timothykrell avatar timsnadden avatar typical000 avatar urbantumbleweed avatar visioncan avatar vovacodes avatar watilde avatar wellguimaraes avatar wldcordeiro 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.