-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'next' into 10-21-escape_js_theme_configuration_keys
- Loading branch information
Showing
9 changed files
with
82 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
packages/@tailwindcss-upgrade/src/template/codemods/max-width-screen.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { __unstable__loadDesignSystem } from '@tailwindcss/node' | ||
import { expect, test } from 'vitest' | ||
import { maxWidthScreen } from './max-width-screen' | ||
|
||
test('converts max-w-screen-* to max-w-[theme(screens.*)] (so it will later be converted to the var injection)', async () => { | ||
let designSystem = await __unstable__loadDesignSystem('@import "tailwindcss";', { | ||
base: __dirname, | ||
}) | ||
|
||
let migrated = maxWidthScreen(designSystem, {}, 'max-w-screen-md') | ||
expect(migrated).toMatchInlineSnapshot(`"max-w-[theme(screens.md)]"`) | ||
}) |
26 changes: 26 additions & 0 deletions
26
packages/@tailwindcss-upgrade/src/template/codemods/max-width-screen.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import type { Config } from 'tailwindcss' | ||
import type { DesignSystem } from '../../../../tailwindcss/src/design-system' | ||
import { printCandidate } from '../candidates' | ||
|
||
export function maxWidthScreen( | ||
designSystem: DesignSystem, | ||
_userConfig: Config, | ||
rawCandidate: string, | ||
): string { | ||
for (let candidate of designSystem.parseCandidate(rawCandidate)) { | ||
if ( | ||
candidate.kind === 'functional' && | ||
candidate.root === 'max-w' && | ||
candidate.value?.value.startsWith('screen-') | ||
) { | ||
return printCandidate(designSystem, { | ||
...candidate, | ||
value: { | ||
...candidate.value, | ||
value: `[theme(screens.${candidate.value.value.slice(7)})]`, | ||
}, | ||
}) | ||
} | ||
} | ||
return rawCandidate | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters