6.2.0 • Published 6 years ago

jss-extend v6.2.0

Weekly downloads
114,335
License
MIT
Repository
github
Last release
6 years ago

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

6.2.0

6 years ago

6.1.0

6 years ago

6.0.1

7 years ago

6.0.0

7 years ago

5.0.0

7 years ago

4.0.1

7 years ago

4.0.0

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

2.0.6

7 years ago

2.0.5

7 years ago

2.0.4

7 years ago

2.0.3

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.0

8 years ago

1.0.0

9 years ago

0.2.0

9 years ago

0.1.7

9 years ago

0.1.6

9 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago