GithubHelp home page GithubHelp logo

serjopepper / jss-extend Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mpal9000/jss-extend

0.0 2.0 0.0 38 KB

Extend rules and rules definitions when creating new rules.

License: MIT License

JavaScript 89.86% HTML 10.14%

jss-extend's Introduction

JSS logo

JSS plugin that enables inheritance

This plugin implements a custom extend style property.

Demo - JSS

![Gitter](https://badges.gitter.im/Join Chat.svg)

Value of extend property can be a string, object and array. If string is used, it will look for a rule with such a name. If object - plain rule object is expected, if array - an array of plain rule obejcts is expected.

Usage examples

import jss from 'jss'
import extend from 'jss-extend'

// Setup jss plugins.
jss.use(extend())

const sheet = jss.createStyleSheet({
  redContainer: {
    background: 'red'
  },
  container: {
    extend: 'redContainer',
    'font-size': '20px'
  }
})

const redContainer = {
  background: 'red'
}
const sheet = jss.createStyleSheet({
  container: {
    extend: redContainer, // Can be an array of styles
    'font-size': '20px'
  }
})

// Without `extend`, using ES7.
const sheet = jss.createStyleSheet({
  container: {
    ...redContainer,
    'font-size': '20px'
  }
})

console.log(sheet.toString())
.jss-0-0 {
  background: red;
  font-size: 20px;
}
console.log(sheet.classes)
{container: 'jss-0-0'}

Issues

File a bug against cssinjs/jss prefixed with [jss-extend].

Run tests

npm i
npm run test

License

MIT

jss-extend's People

Contributors

kof 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.