0.2.1 • Published 6 years ago

postcss-decrease-specificity v0.2.1

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

PostCSS Decrease Specificity Build Status npmStatus

PostCSS plugin that decreases the specificity of given selector.

Example

.foo1 .bar1 .foo2 .bar2 {
    /* Input example */
}
.bar1 .foo2 .bar2 {
  /* Output example */
}

Complex example

tag .class1 .class2 #id .class3 a.class4:pseudo {
    /* Input example */
}
tag .class2 #id .class3 a.class4:pseudo {
  /* Output example */
}

Options

depth: Number (default: 3)

Usage

const plugin = require('postcss-decrease-specificity');
postcss([ plugin(options) ])
  .then((result) => {
     result.css // modified css
  });

Tests

$ npm test

Notes

  1. ⚠️ Use this plugin with caution, it may break your design.
  2. This plugin takes into consideration as depth only class selectors with descendant combinator, therefore, .a .b .c > .d tag .f{ decl:1 } will become .b .c > .d tag .f{ decl:1 }

See PostCSS docs for examples for your environment.