Skip to content

Commit bb79aca

Browse files
committed
use substituteAtVariant in main CSS handling
1 parent e32751c commit bb79aca

File tree

1 file changed

+3
-26
lines changed

1 file changed

+3
-26
lines changed

packages/tailwindcss/src/index.ts

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { substituteAtImports } from './at-import'
2222
import { applyCompatibilityHooks } from './compat/apply-compat-hooks'
2323
import type { UserConfig } from './compat/config/types'
2424
import { type Plugin } from './compat/plugin-api'
25-
import { applyVariant, compileCandidates } from './compile'
25+
import { compileCandidates } from './compile'
2626
import { substituteFunctions } from './css-functions'
2727
import * as CSS from './css-parser'
2828
import { buildDesignSystem, type DesignSystem } from './design-system'
@@ -32,7 +32,7 @@ import { createCssUtility } from './utilities'
3232
import { expand } from './utils/brace-expansion'
3333
import { escape, unescape } from './utils/escape'
3434
import { segment } from './utils/segment'
35-
import { compoundsForSelectors, IS_VALID_VARIANT_NAME } from './variants'
35+
import { compoundsForSelectors, IS_VALID_VARIANT_NAME, substituteAtVariant } from './variants'
3636
export type Config = UserConfig
3737

3838
const IS_VALID_PREFIX = /^[a-z]+$/
@@ -636,30 +636,7 @@ async function parseCss(
636636
firstThemeRule.nodes = [context({ theme: true }, nodes)]
637637
}
638638

639-
// Replace the `@variant` at-rules with the actual variant rules.
640-
if (variantNodes.length > 0) {
641-
for (let variantNode of variantNodes) {
642-
// Starting with the `&` rule node
643-
let node = styleRule('&', variantNode.nodes)
644-
645-
let variant = variantNode.params
646-
647-
let variantAst = designSystem.parseVariant(variant)
648-
if (variantAst === null) {
649-
throw new Error(`Cannot use \`@variant\` with unknown variant: ${variant}`)
650-
}
651-
652-
let result = applyVariant(node, variantAst, designSystem.variants)
653-
if (result === null) {
654-
throw new Error(`Cannot use \`@variant\` with variant: ${variant}`)
655-
}
656-
657-
// Update the variant at-rule node, to be the `&` rule node
658-
Object.assign(variantNode, node)
659-
}
660-
features |= Features.Variants
661-
}
662-
639+
features |= substituteAtVariant(ast, designSystem)
663640
features |= substituteFunctions(ast, designSystem)
664641
features |= substituteAtApply(ast, designSystem)
665642

0 commit comments

Comments
 (0)