forgeplus-react/node_modules/jss-extend
zhiyuanliu cb17bad1d4 activity visualize step one 2023-07-29 06:19:10 -07:00
..
dist activity visualize step one 2023-07-29 06:19:10 -07:00
lib activity visualize step one 2023-07-29 06:19:10 -07:00
node_modules/warning activity visualize step one 2023-07-29 06:19:10 -07:00
tests activity visualize step one 2023-07-29 06:19:10 -07:00
.babelrc activity visualize step one 2023-07-29 06:19:10 -07:00
.eslintrc activity visualize step one 2023-07-29 06:19:10 -07:00
LICENSE activity visualize step one 2023-07-29 06:19:10 -07:00
changelog.md activity visualize step one 2023-07-29 06:19:10 -07:00
karma.conf.js activity visualize step one 2023-07-29 06:19:10 -07:00
package.json activity visualize step one 2023-07-29 06:19:10 -07:00
readme.md activity visualize step one 2023-07-29 06:19:10 -07:00
tests.html activity visualize step one 2023-07-29 06:19:10 -07:00
tests.webpack.js activity visualize step one 2023-07-29 06:19:10 -07:00
webpack.config.js activity visualize step one 2023-07-29 06:19:10 -07:00

readme.md

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