1 | 'use strict';
|
2 |
|
3 | var _postcss = require('postcss');
|
4 |
|
5 | var _postcss2 = _interopRequireDefault(_postcss);
|
6 |
|
7 | var _postcssValueParser = require('postcss-value-parser');
|
8 |
|
9 | var _postcssValueParser2 = _interopRequireDefault(_postcssValueParser);
|
10 |
|
11 | var _hslFunctionalNotation = require('./lib/hsl-functional-notation');
|
12 |
|
13 | var _hslFunctionalNotation2 = _interopRequireDefault(_hslFunctionalNotation);
|
14 |
|
15 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
16 |
|
17 | function transformHsl(value) {
|
18 | return (0, _postcssValueParser2.default)(value).walk(function (node) {
|
19 |
|
20 | if (node.type !== 'function' || node.value !== 'hsl' && node.value !== 'hsla') {
|
21 | return;
|
22 | }
|
23 | node.value = _hslFunctionalNotation2.default.legacy(_postcssValueParser2.default.stringify(node));
|
24 | node.type = 'word';
|
25 | }).toString();
|
26 | }
|
27 |
|
28 | module.exports = _postcss2.default.plugin('postcss-color-hsl', function (opts) {
|
29 | opts = opts || {};
|
30 |
|
31 | return function (root, result) {
|
32 | root.walkDecls(function (decl) {
|
33 |
|
34 | if (!decl.value || decl.value.indexOf('hsl(') === -1 && decl.value.indexOf('hsla(') === -1) {
|
35 | return;
|
36 | }
|
37 | decl.value = transformHsl(decl.value);
|
38 | });
|
39 | };
|
40 | }); |
\ | No newline at end of file |