MCPcopy
hub / github.com/tailwindlabs/tailwindcss / fromAst

Method fromAst

packages/tailwindcss/src/variants.ts:87–111  ·  view source on GitHub ↗
(name: string, ast: AstNode[], designSystem: DesignSystem)

Source from the content-addressed store, hash-verified

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,

Callers 2

parseCssFunction · 0.80
addVariantFunction · 0.80

Calls 5

staticMethod · 0.95
walkFunction · 0.90
substituteAtVariantFunction · 0.85
substituteAtSlotFunction · 0.85
compoundsForSelectorsFunction · 0.85

Tested by

no test coverage detected