cssobj-plugin-extend
cssobj plugin to extend selector to another selector, like @extend in SCSS or $extend in LESS.
Install
- npm
npm i cssobj-plugin-extend
Then
var cssobj = var cssobj_plugin_extend = // then consume the cssobj_plugin_extend below
Quick Start
Extend single selector:
var obj = 'p': fontSize: '12px' div: $extend: 'p' color: 'red'
Result css:
Extend with multiple selector:
var obj = '.blue': color: 'blue' 'p': fontSize: '12px' div: $extend: 'p' '.blue' color: 'red'
Result css:
Extend with regexp:
var obj = // clearfix hack '.clearfix': '&:before, &:after': content: '" "' display: 'table' '&:after': clear: 'both' '&': '*zoom': 1 div: $extend: /\.clearfix/ color: 'red'
Result css:
API
cssobj_plugin_extend(option)
return function as cssobj plugin.
option.keyName
Default value: $extend, which means the intended key checking by this plugin is $extend
, you can set it to any value start with '$'
.
var obj = p: color: 'red' div: $ext: 'p' // use $ext as keyName
Requirement
cssobj version >= 0.5.5
License
MIT