postcss-autoreset
PostCSS plugin for partial styles reset
Last updated 3 years ago by maximkoretskiy .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install postcss-autoreset 
SYNC missed versions from official npm registry.

PostCSS Auto Reset

Build Status NPM David DM

PostCSS plugin for automatic conditional rules reset. Useful for creation of bullet-proof styles isolation in your extension. Can be used in combination with postcss-initial.

The following CSS is written in BEM notation.

.block {
  padding: 1em;
}

.block:hover {
  background-color: red;
}

.block__element {
  margin: 1em;
}

.block--modifier {
  border: 1em;
}

.block, .block__element { /* combined reset block */
  all: initial;
}

.block { /* reseted */
  padding: 1em;
}

.block:hover { /* ignored, we don`t need to reset pseudoclasses  */
  background-color: red;
}

.block__element { /* reseted */
  margin: 1em;
}

.block--modifier { /* ignored, we don`t need to reset BEM modifiers  */
  border: 1em;
}

Options

reset

Set of properties that we use to reset rules.
Takes string or object.
Possible values:

  • 'initial' - all: initial;
  • 'sizes' - reset size properties.

Use object to create your own reset. CSS-in-JS notation is supported.

Example

postcss([ require('postcss-autoreset')({
    reset: {
      margin: 0,
      padding: 0,
      borderRadius: 0
    }
  })])

rulesMatcher

Rules filter function.
Takes string or function.
Possible values:

  • 'bem' - reset all BEM blocks and element, ignore modifiers and pseudoclasses. (naming: .block__element-modifier);
  • 'suit' - reset all SUIT CSS components and parts, ignore modifiers, states and pseudoclasses.

You can define custom rules filter to fit your styles naming.

Example

postcss([ require('postcss-autoreset')({
  rulesMatcher: (rule)=> rule.selector.match(/regexp/)
  })])

Usage

postcss([ require('postcss-autoreset')()])

See PostCSS docs for examples for your environment.

Current Tags

  • 2.0.2                                ...           latest (3 years ago)

13 Versions

  • 2.0.2                                ...           3 years ago
  • 2.0.1                                ...           3 years ago
  • 2.0.0                                ...           3 years ago
  • 1.2.1                                ...           4 years ago
  • 1.2.0                                ...           4 years ago
  • 1.1.5                                ...           5 years ago
  • 1.1.4                                ...           5 years ago
  • 1.1.3                                ...           5 years ago
  • 1.1.2                                ...           5 years ago
  • 1.1.1                                ...           5 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago

Copyright 2014 - 2016 © taobao.org |