Skip to content

Commit

Permalink
do not migrate group-[]:flex to in-[.group]:flex
Browse files Browse the repository at this point in the history
Because this requires prefixing the `.group` if the prefix is
configured.
  • Loading branch information
RobinMalfait committed Nov 18, 2024
1 parent 9def3a6 commit cbff570
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,6 @@ test.each([
['[p_&]:flex', 'in-[p]:flex'],
['[.foo_&]:flex', 'in-[.foo]:flex'],
['[[data-visible]_&]:flex', 'in-data-visible:flex'],
// Some extreme examples of what happens in the wild:
['group-[]:flex', 'in-[.group]:flex'],
['group-[]/name:flex', 'in-[.group\\/name]:flex'],

// These shouldn't happen in the real world (because compound variants are
// new). But this could happen once we allow codemods to run in v4+ projects.
['has-group-[]:flex', 'has-in-[.group]:flex'],
['has-group-[]/name:flex', 'has-in-[.group\\/name]:flex'],
['not-group-[]:flex', 'not-in-[.group]:flex'],
['not-group-[]/name:flex', 'not-in-[.group\\/name]:flex'],

// nth-child
['[&:nth-child(2)]:flex', 'nth-2:flex'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,6 @@ export function modernizeArbitraryValues(
}
}

// Promote `group-[]:flex` to `in-[.group]:flex`
// ^^ Yes, this is empty
// Promote `group-[]/name:flex` to `in-[.group\/name]:flex`
if (
variant.kind === 'compound' &&
variant.root === 'group' &&
variant.variant.kind === 'arbitrary' &&
variant.variant.selector === '&:is()'
) {
// `group-[]`
if (variant.modifier === null) {
changed = true
Object.assign(variant, designSystem.parseVariant('in-[.group]'))
}

// `group-[]/name`
else if (variant.modifier.kind === 'named') {
changed = true
Object.assign(
variant,
designSystem.parseVariant(`in-[.group\\/${variant.modifier.value}]`),
)
}
}

// Expecting an arbitrary variant
if (variant.kind !== 'arbitrary') continue

Expand Down

0 comments on commit cbff570

Please sign in to comment.