0.1.1 • Published 2 years ago

postcss-pseudo-companion-classes v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

PostCSS Pseudo Companion Classes

PostCSS plugin to add companion classes to pseudo-classes for testing purposes. This allows you to add the class name to force the styling of a pseudo-class, which can be helpful for visual QA and building sticker sheets of all style states.

Input

.some-selector:hover {
  text-decoration: underline;
}

Output

.some-selector:hover,
.some-selector.\:hover {
  text-decoration: underline;
}

Credits

This plugin is a fork of postcss-pseudo-classes and adds support for css modules.

Usage

Step 1: Install plugin:

npm install --save-dev postcss postcss-pseudo-companion-classes

or

yarn add --dev postcss postcss-pseudo-companion-classes

Step 2: Check you project for existed PostCSS config: postcss.config.js in the project root, "postcss" section in package.json or postcss in bundle config.

If you do not use PostCSS, add it according to official docs and set this plugin in settings.

Step 3: Add the plugin to plugins list:

module.exports = {
  plugins: [
+   require('postcss-pseudo-companion-classes'),
    require('autoprefixer')
  ]
}

Options

PropertyDescriptionDefault Value
excludeAn array of pseudo-classes to skip when generating companion classes[':before', ':after']
restrictToLimit the companion classes to an array of pseudo-classes
allCombinationsWhen multiple pseudo-classes are present (ie .selector:hover:focus), output classes for each combination .selector:hover:focus, .selector:hover.\:focus, .selector.\:hover:focus, .selector.\:hover.\:focusfalse
isModuleWrap companion classes in :global() to prevent them from being renamed when CSS modules are being usedfalse
prefixThe prefix for the companion class\\: