(name: string, ast: AstNode[], designSystem: DesignSystem)
| 85 | } |
| 86 | |
| 87 | fromAst(name: string, ast: AstNode[], designSystem: DesignSystem) { |
| 88 | let selectors: string[] = [] |
| 89 | |
| 90 | let usesAtVariant = false |
| 91 | walk(ast, (node) => { |
| 92 | if (node.kind === 'rule') { |
| 93 | selectors.push(node.selector) |
| 94 | } else if (node.kind === 'at-rule' && node.name === '@variant') { |
| 95 | usesAtVariant = true |
| 96 | } else if (node.kind === 'at-rule' && node.name !== '@slot') { |
| 97 | selectors.push(`${node.name} ${node.params}`) |
| 98 | } |
| 99 | }) |
| 100 | |
| 101 | this.static( |
| 102 | name, |
| 103 | (r) => { |
| 104 | let body = ast.map(cloneAstNode) |
| 105 | if (usesAtVariant) substituteAtVariant(body, designSystem) |
| 106 | substituteAtSlot(body, r.nodes) |
| 107 | r.nodes = body |
| 108 | }, |
| 109 | { compounds: compoundsForSelectors(selectors) }, |
| 110 | ) |
| 111 | } |
| 112 | |
| 113 | functional( |
| 114 | name: string, |
no test coverage detected