-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
35 lines (28 loc) · 866 Bytes
/
index.js
File metadata and controls
35 lines (28 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var postcss = require('postcss');
var pluginName = 'postcss-text-stroke';
module.exports = postcss.plugin(pluginName, function (opts) {
opts = opts || {};
return function (css) {
css.walkDecls('text-stroke', function (decl) {
var stroke = postcss.list.space(decl.value);
var cssSize = stroke[0];
var cssColor = stroke[1];
var cssSmooth = stroke[2];
var cssTextshadow = '';
for (var w = cssSize*-1; w <= cssSize; w++) {
for (var h = cssSize*-1; h <= cssSize; h++) {
if (cssSmooth === 'smooth') {
cssTextshadow += w + 'px ' + h + 'px 1px ' + cssColor + ',';
} else {
cssTextshadow += w + 'px ' + h + 'px 0 ' + cssColor + ',';
}
}
}
cssTextshadow = cssTextshadow.slice(0, -1);
decl.cloneBefore({
prop: 'text-shadow', value: cssTextshadow
});
decl.remove();
});
};
});