PostCSS plugin that to add matter property
npm i postcss-matter
Define matters using the @matter
atrule.
Then use they.
@matter {
common {
-webkit-tap-highlight-color: #fff;
}
default-a {
matter: common;
color: inherit;
text-decoration: none;
cursor: pointer;
}
}
@matter namespace {
default-input {
box-sizing: border-box;
border: 1px solid #333;
}
}
a.that {
matter: default-a;
}
a.this {
matter: default-a;
}
.input {
matter: namespace-default-input;
}
.btn {
matter: default-button;
}
.btn--small {
matter: default-button;
font-size: .85em;
}
@matter {
default-button {
padding: .5em 1em;
background: #e42829;
}
}
const fs = require('fs');
const postcss = require('postcss');
const matter = require('postcss-matter'):
const beautify = require('cssbeautify');
const css = fs.readFileSync('./sample.css', 'utf-8');
postcss([matter])
.process(css)
.then(result => console.log(beautify(result.css, {indent: ' '})));
like this.
a.that,
a.this {
-webkit-tap-highlight-color: #fff;
color: inherit;
text-decoration: none;
cursor: pointer;
}
.input {
box-sizing: border-box;
border: 1px solid #333;
}
.btn {
padding: .5em 1em;
background: #e42829;
}
.btn--small {
padding: .5em 1em;
background: #e42829;
font-size: .85em;
}
@matter <namespace-name> {
<matter-name> {
declaration;
...
}
(<matter-name> {...})
(<matter-name> {...})
}
<selector> {
matter: <defined matter-name>;
}
isolateLength
For example,That's now@matter { that { color: #000; font-size: 15px; line-height: 1.7; } } .a { matter: that; } .b { matter: that; }
isolateLength: 3
, you will get this.When that's.a, .b { color: #000; font-size: 15px; line-height: 1.7 }
isolateLength: 4
, get it..a { color: #000; font-size: 15px; line-height: 1.7; } .b { color: #000; font-size: 15px; line-height: 1.7; }
3
by default.
1 Clone this
git clone git@github.com:totora0155/postcss-matter.git
2 Change directory
cd postcss-matter
3 Install modules
npm install
4 Run to script
cd examples && node postcss.js
version | log |
---|---|
0.1.1 | Change output. result.warn -> console.log |
0.1.0 | Use a matter from a matter |
0.0.4 | Bugfix for filter |
0.0.3 | Bugfix when a matter unused |
0.0.2 | Fix bug |
0.0.1 | Release! |