postcss-pseudo-companion-classes
v0.1.1
Published
PostCSS plugin to add companion classes to pseudo-classes for testing purposes (works with css modules)
Downloads
7,215
Maintainers
Readme
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
| Property | Description | Default Value |
| --- | --- | --- |
| exclude
| An array of pseudo-classes to skip when generating companion classes | [':before', ':after']
|
| restrictTo
| Limit the companion classes to an array of pseudo-classes | |
| allCombinations
| When 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.\:focus | false
|
| isModule
| Wrap companion classes in :global()
to prevent them from being renamed when CSS modules are being used | false
| prefix
| The prefix for the companion class | \\:
|