Socket
Socket
Sign inDemoInstall

jss-extend

Package Overview
Dependencies
6
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    jss-extend

JSS plugin that enables mixing in styles.


Version published
Weekly downloads
54K
decreased by-12.35%
Maintainers
1
Install size
114 kB
Created
Weekly downloads
 

Readme

Source

JSS plugin that enables mixing in styles

Gitter

This plugin implements a custom property extend which allows you to mix in styles in various ways.

Style object own properties always take precedence over extended objects, so you can always override the extended definition. Exception is function values.

Use style object reference


const buttonColor = {
  color: 'green'
}
const buttonTheme = {
  extend: buttonColor
  background: 'red'
}
const styles = {
  button: {
    extend: buttonTheme,
    fontSize: '20px'
  }
}

Use rule name from the current styles object

const styles = {
  buttonColor: {
    background: 'red'
  },
  button: {
    extend: 'buttonColor',
    fontSize: '20px'
  }
}

Use array of style objects

const styles = {
  button: {
    extend: [{background: 'red'}, {color: 'green'}],
    fontSize: '20px'
  }
}

const background = {background: 'red'}
const color = {color: 'green'}

const styles = {
  button: {
    extend: [background, color],
    fontSize: '20px'
  }
}

Use function which returns a style object

Nested extend inside of the function is not supported. Will override other properties defined in the same rule.

const styles = {
  button: {
    extend: (data) => ({
      color: data.theme.color
    }),
    fontSize: '20px'
  }
}

Demo

Simple demo

Multi objects demo

Issues

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

Run tests

npm i
npm run test

License

MIT

Keywords

FAQs

Last updated on 06 Feb 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc