Skip to content

Commit

Permalink
Remove the negative flag from the Candidate AST (#14938)
Browse files Browse the repository at this point in the history
This PR removes the `negative` flag from the `Candidate` AST. The system
itself doesn't this information at all, but it's up to each plugin to
handle the `negative` flag themselves.

This also means that if you _don't_ handle it, that `foo` and `-foo`
results in the same CSS output.

To make sure that the negative version of utilities that supported it
still work, this PR also adds the negative versions as separate
utilities. E.g.: `-scale` is registered in addition to `scale`.

This is an internal refactor only, and doesn't change any behavior.

---------

Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
  • Loading branch information
RobinMalfait and adamwathan authored Nov 11, 2024
1 parent d325e70 commit 292efa5
Show file tree
Hide file tree
Showing 7 changed files with 365 additions and 378 deletions.
7 changes: 0 additions & 7 deletions packages/@tailwindcss-upgrade/src/template/candidates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,6 @@ export function printCandidate(designSystem: DesignSystem, candidate: Candidate)

let base: string = ''

// Handle negative
if (candidate.kind === 'static' || candidate.kind === 'functional') {
if (candidate.negative) {
base += '-'
}
}

// Handle static
if (candidate.kind === 'static') {
base += candidate.root
Expand Down
46 changes: 46 additions & 0 deletions packages/tailwindcss/src/__snapshots__/intellisense.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ exports[`getClassList 1`] = `
"-bottom-80",
"-bottom-9",
"-bottom-96",
"-bottom-full",
"-bottom-px",
"-col-end-1",
"-col-end-10",
"-col-end-11",
Expand Down Expand Up @@ -96,6 +98,8 @@ exports[`getClassList 1`] = `
"-end-80",
"-end-9",
"-end-96",
"-end-full",
"-end-px",
"-indent-0",
"-indent-0.5",
"-indent-1",
Expand Down Expand Up @@ -130,6 +134,7 @@ exports[`getClassList 1`] = `
"-indent-80",
"-indent-9",
"-indent-96",
"-indent-px",
"-inset-0",
"-inset-0.5",
"-inset-1",
Expand Down Expand Up @@ -164,6 +169,8 @@ exports[`getClassList 1`] = `
"-inset-80",
"-inset-9",
"-inset-96",
"-inset-full",
"-inset-px",
"-inset-x-0",
"-inset-x-0.5",
"-inset-x-1",
Expand Down Expand Up @@ -198,6 +205,8 @@ exports[`getClassList 1`] = `
"-inset-x-80",
"-inset-x-9",
"-inset-x-96",
"-inset-x-full",
"-inset-x-px",
"-inset-y-0",
"-inset-y-0.5",
"-inset-y-1",
Expand Down Expand Up @@ -232,6 +241,8 @@ exports[`getClassList 1`] = `
"-inset-y-80",
"-inset-y-9",
"-inset-y-96",
"-inset-y-full",
"-inset-y-px",
"-left-0",
"-left-0.5",
"-left-1",
Expand Down Expand Up @@ -266,6 +277,8 @@ exports[`getClassList 1`] = `
"-left-80",
"-left-9",
"-left-96",
"-left-full",
"-left-px",
"-m-0",
"-m-0.5",
"-m-1",
Expand Down Expand Up @@ -300,6 +313,7 @@ exports[`getClassList 1`] = `
"-m-80",
"-m-9",
"-m-96",
"-m-px",
"-mb-0",
"-mb-0.5",
"-mb-1",
Expand Down Expand Up @@ -334,6 +348,7 @@ exports[`getClassList 1`] = `
"-mb-80",
"-mb-9",
"-mb-96",
"-mb-px",
"-me-0",
"-me-0.5",
"-me-1",
Expand Down Expand Up @@ -368,6 +383,7 @@ exports[`getClassList 1`] = `
"-me-80",
"-me-9",
"-me-96",
"-me-px",
"-ml-0",
"-ml-0.5",
"-ml-1",
Expand Down Expand Up @@ -402,6 +418,7 @@ exports[`getClassList 1`] = `
"-ml-80",
"-ml-9",
"-ml-96",
"-ml-px",
"-mr-0",
"-mr-0.5",
"-mr-1",
Expand Down Expand Up @@ -436,6 +453,7 @@ exports[`getClassList 1`] = `
"-mr-80",
"-mr-9",
"-mr-96",
"-mr-px",
"-ms-0",
"-ms-0.5",
"-ms-1",
Expand Down Expand Up @@ -470,6 +488,7 @@ exports[`getClassList 1`] = `
"-ms-80",
"-ms-9",
"-ms-96",
"-ms-px",
"-mt-0",
"-mt-0.5",
"-mt-1",
Expand Down Expand Up @@ -504,6 +523,7 @@ exports[`getClassList 1`] = `
"-mt-80",
"-mt-9",
"-mt-96",
"-mt-px",
"-mx-0",
"-mx-0.5",
"-mx-1",
Expand Down Expand Up @@ -538,6 +558,7 @@ exports[`getClassList 1`] = `
"-mx-80",
"-mx-9",
"-mx-96",
"-mx-px",
"-my-0",
"-my-0.5",
"-my-1",
Expand Down Expand Up @@ -572,6 +593,7 @@ exports[`getClassList 1`] = `
"-my-80",
"-my-9",
"-my-96",
"-my-px",
"-order-1",
"-order-10",
"-order-11",
Expand Down Expand Up @@ -618,6 +640,8 @@ exports[`getClassList 1`] = `
"-right-80",
"-right-9",
"-right-96",
"-right-full",
"-right-px",
"-rotate-0",
"-rotate-1",
"-rotate-12",
Expand Down Expand Up @@ -758,6 +782,7 @@ exports[`getClassList 1`] = `
"-scroll-m-80",
"-scroll-m-9",
"-scroll-m-96",
"-scroll-m-px",
"-scroll-mb-0",
"-scroll-mb-0.5",
"-scroll-mb-1",
Expand Down Expand Up @@ -792,6 +817,7 @@ exports[`getClassList 1`] = `
"-scroll-mb-80",
"-scroll-mb-9",
"-scroll-mb-96",
"-scroll-mb-px",
"-scroll-me-0",
"-scroll-me-0.5",
"-scroll-me-1",
Expand Down Expand Up @@ -826,6 +852,7 @@ exports[`getClassList 1`] = `
"-scroll-me-80",
"-scroll-me-9",
"-scroll-me-96",
"-scroll-me-px",
"-scroll-ml-0",
"-scroll-ml-0.5",
"-scroll-ml-1",
Expand Down Expand Up @@ -860,6 +887,7 @@ exports[`getClassList 1`] = `
"-scroll-ml-80",
"-scroll-ml-9",
"-scroll-ml-96",
"-scroll-ml-px",
"-scroll-mr-0",
"-scroll-mr-0.5",
"-scroll-mr-1",
Expand Down Expand Up @@ -894,6 +922,7 @@ exports[`getClassList 1`] = `
"-scroll-mr-80",
"-scroll-mr-9",
"-scroll-mr-96",
"-scroll-mr-px",
"-scroll-ms-0",
"-scroll-ms-0.5",
"-scroll-ms-1",
Expand Down Expand Up @@ -928,6 +957,7 @@ exports[`getClassList 1`] = `
"-scroll-ms-80",
"-scroll-ms-9",
"-scroll-ms-96",
"-scroll-ms-px",
"-scroll-mt-0",
"-scroll-mt-0.5",
"-scroll-mt-1",
Expand Down Expand Up @@ -962,6 +992,7 @@ exports[`getClassList 1`] = `
"-scroll-mt-80",
"-scroll-mt-9",
"-scroll-mt-96",
"-scroll-mt-px",
"-scroll-mx-0",
"-scroll-mx-0.5",
"-scroll-mx-1",
Expand Down Expand Up @@ -996,6 +1027,7 @@ exports[`getClassList 1`] = `
"-scroll-mx-80",
"-scroll-mx-9",
"-scroll-mx-96",
"-scroll-mx-px",
"-scroll-my-0",
"-scroll-my-0.5",
"-scroll-my-1",
Expand Down Expand Up @@ -1030,6 +1062,7 @@ exports[`getClassList 1`] = `
"-scroll-my-80",
"-scroll-my-9",
"-scroll-my-96",
"-scroll-my-px",
"-skew-0",
"-skew-1",
"-skew-12",
Expand Down Expand Up @@ -1082,6 +1115,7 @@ exports[`getClassList 1`] = `
"-space-x-80",
"-space-x-9",
"-space-x-96",
"-space-x-px",
"-space-y-0",
"-space-y-0.5",
"-space-y-1",
Expand Down Expand Up @@ -1116,6 +1150,7 @@ exports[`getClassList 1`] = `
"-space-y-80",
"-space-y-9",
"-space-y-96",
"-space-y-px",
"-start-0",
"-start-0.5",
"-start-1",
Expand Down Expand Up @@ -1150,6 +1185,8 @@ exports[`getClassList 1`] = `
"-start-80",
"-start-9",
"-start-96",
"-start-full",
"-start-px",
"-top-0",
"-top-0.5",
"-top-1",
Expand Down Expand Up @@ -1184,6 +1221,8 @@ exports[`getClassList 1`] = `
"-top-80",
"-top-9",
"-top-96",
"-top-full",
"-top-px",
"-translate-0",
"-translate-0.5",
"-translate-1",
Expand Down Expand Up @@ -1218,6 +1257,8 @@ exports[`getClassList 1`] = `
"-translate-80",
"-translate-9",
"-translate-96",
"-translate-full",
"-translate-px",
"-translate-x-0",
"-translate-x-0.5",
"-translate-x-1",
Expand Down Expand Up @@ -1252,6 +1293,8 @@ exports[`getClassList 1`] = `
"-translate-x-80",
"-translate-x-9",
"-translate-x-96",
"-translate-x-full",
"-translate-x-px",
"-translate-y-0",
"-translate-y-0.5",
"-translate-y-1",
Expand Down Expand Up @@ -1286,6 +1329,8 @@ exports[`getClassList 1`] = `
"-translate-y-80",
"-translate-y-9",
"-translate-y-96",
"-translate-y-full",
"-translate-y-px",
"-translate-z-0",
"-translate-z-0.5",
"-translate-z-1",
Expand Down Expand Up @@ -1320,6 +1365,7 @@ exports[`getClassList 1`] = `
"-translate-z-80",
"-translate-z-9",
"-translate-z-96",
"-translate-z-px",
"-underline-offset-0",
"-underline-offset-1",
"-underline-offset-2",
Expand Down
Loading

0 comments on commit 292efa5

Please sign in to comment.