File tree Expand file tree Collapse file tree 6 files changed +46
-2
lines changed
packages/@tailwindcss-upgrade/src/template Expand file tree Collapse file tree 6 files changed +46
-2
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
1212- _ Upgrade (experimental)_ : Migrate ` plugins ` with options to CSS ([ #14700 ] ( https://github.com/tailwindlabs/tailwindcss/pull/14700 ) )
1313- _ Upgrade (experimental)_ : Allow JS configuration files with ` corePlugins ` options to be migrated to CSS ([ #14742 ] ( https://github.com/tailwindlabs/tailwindcss/pull/14742 ) )
14+ - _ Upgrade (experimental)_ : Migrate ` max-w-screen-* ` utilities to ` max-w-[var(…)] ` ([ #14754 ] ( https://github.com/tailwindlabs/tailwindcss/pull/14754 ) )
1415
1516### Fixed
1617
Original file line number Diff line number Diff line change 2020 ` ,
2121 'src/index.html' : html `
2222 <h1 > 🤠👋</ h1>
23- <div class= "!flex sm:!block bg-gradient-to-t bg-[--my-red]" > </div>
23+ <div class= "!flex sm:!block bg-gradient-to-t bg-[--my-red] max-w-screen-md " > </div>
2424 ` ,
2525 'src/input.css' : css `
2626 @tailwind base;
3636 "
3737 --- ./src/index.html ---
3838 <h1>🤠👋</h1>
39- <div class="flex! sm:block! bg-linear-to-t bg-[var(--my-red)]"></div>
39+ <div class="flex! sm:block! bg-linear-to-t bg-[var(--my-red)] max-w-[var(--breakpoint-md)] "></div>
4040
4141 --- ./src/input.css ---
4242 @import 'tailwindcss';
Original file line number Diff line number Diff line change 1+ import { __unstable__loadDesignSystem } from '@tailwindcss/node'
2+ import { expect , test } from 'vitest'
3+ import { maxWScreen } from './max-w-screen'
4+
5+ test ( 'converts max-w-screen-* to max-w-[theme(screens.*)] (so it will later be converted to the var injection)' , async ( ) => {
6+ let designSystem = await __unstable__loadDesignSystem ( '@import "tailwindcss";' , {
7+ base : __dirname ,
8+ } )
9+
10+ let migrated = maxWScreen ( designSystem , { } , 'max-w-screen-md' )
11+ expect ( migrated ) . toMatchInlineSnapshot ( `"max-w-[screens(md)]"` )
12+ } )
Original file line number Diff line number Diff line change 1+ import type { Config } from 'tailwindcss'
2+ import type { DesignSystem } from '../../../../tailwindcss/src/design-system'
3+ import { printCandidate } from '../candidates'
4+
5+ export function maxWScreen (
6+ designSystem : DesignSystem ,
7+ _userConfig : Config ,
8+ rawCandidate : string ,
9+ ) : string {
10+ for ( let candidate of designSystem . parseCandidate ( rawCandidate ) ) {
11+ if (
12+ candidate . kind === 'functional' &&
13+ candidate . root === 'max-w' &&
14+ candidate . value ?. value . startsWith ( 'screen-' )
15+ ) {
16+ return printCandidate ( designSystem , {
17+ ...candidate ,
18+ value : {
19+ ...candidate . value ,
20+ value : `[theme(screens.${ candidate . value . value . slice ( 7 ) } )]` ,
21+ } ,
22+ } )
23+ }
24+ }
25+ return rawCandidate
26+ }
Original file line number Diff line number Diff line change @@ -86,6 +86,9 @@ test.each([
8686 // `theme(…)` calls valid in v3, but not in v4 should still be converted.
8787 [ '[--foo:theme(fontWeight.semibold)]' , '[--foo:theme(fontWeight.semibold)]' ] ,
8888
89+ // `screens` values
90+ [ 'max-w-[theme(screens.md)]' , 'max-w-[var(--breakpoint-md)]' ] ,
91+
8992 // Invalid cases
9093 [ '[--foo:theme(colors.red.500/50/50)]' , '[--foo:theme(colors.red.500/50/50)]' ] ,
9194 [ '[--foo:theme(colors.red.500/50/50)]/50' , '[--foo:theme(colors.red.500/50/50)]/50' ] ,
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import { arbitraryValueToBareValue } from './codemods/arbitrary-value-to-bare-va
77import { automaticVarInjection } from './codemods/automatic-var-injection'
88import { bgGradient } from './codemods/bg-gradient'
99import { important } from './codemods/important'
10+ import { maxWScreen } from './codemods/max-w-screen'
1011import { prefix } from './codemods/prefix'
1112import { simpleLegacyClasses } from './codemods/simple-legacy-classes'
1213import { themeToVar } from './codemods/theme-to-var'
@@ -26,6 +27,7 @@ export const DEFAULT_MIGRATIONS: Migration[] = [
2627 bgGradient ,
2728 simpleLegacyClasses ,
2829 arbitraryValueToBareValue ,
30+ maxWScreen ,
2931 themeToVar ,
3032 variantOrder ,
3133]
You can’t perform that action at this time.
0 commit comments