1 |
|
2 | import { list } from 'postcss';
|
3 | import setVariable from './set-variable';
|
4 |
|
5 |
|
6 | export default function transformMixinAtrule(atrule, result, opts) {
|
7 |
|
8 | const [ name, sourceParams ] = atrule.params.split(matchOpeningParen, 2);
|
9 | const params = sourceParams
|
10 | ? list.comma(sourceParams.slice(0, -1)).map(
|
11 | param => {
|
12 | const parts = list.split(param, ':');
|
13 | const paramName = parts[0].slice(1);
|
14 | const paramValue = parts.length > 1 ? parts.slice(1).join(':') : undefined;
|
15 |
|
16 | return { name: paramName, value: paramValue };
|
17 | }
|
18 | )
|
19 | : [];
|
20 |
|
21 |
|
22 | setVariable(atrule.parent, name, { params, atrule }, opts);
|
23 |
|
24 |
|
25 | atrule.remove();
|
26 | }
|
27 |
|
28 |
|
29 | const matchOpeningParen = '(';
|