@@ -1118,6 +1118,95 @@ test(
11181118 } ,
11191119)
11201120
1121+ test (
1122+ 'migrate supports theme keys to custom variants' ,
1123+ {
1124+ fs : {
1125+ 'package.json' : json `
1126+ {
1127+ "dependencies": {
1128+ "tailwindcss": "^3",
1129+ "@tailwindcss/upgrade": "workspace:^"
1130+ }
1131+ }
1132+ ` ,
1133+ 'tailwind.config.ts' : ts `
1134+ export default {
1135+ content: {
1136+ relative: true,
1137+ files: ['./src/**/*.html'],
1138+ },
1139+ theme: {
1140+ extend: {
1141+ supports: {
1142+ // Automatically handled by bare values (using CSS variable as the value)
1143+ foo: 'foo: var(--foo)', // parentheses are optional
1144+ bar: '(bar: var(--bar))',
1145+
1146+ // Not automatically handled by bare values because names differ
1147+ foo: 'bar: var(--foo)', // parentheses are optional
1148+ bar: '(qux: var(--bar))',
1149+
1150+ // Custom
1151+ grid: 'display: grid',
1152+ },
1153+ },
1154+ },
1155+ }
1156+ ` ,
1157+ 'src/input.css' : css `
1158+ @tailwind base;
1159+ @tailwind components;
1160+ @tailwind utilities;
1161+ ` ,
1162+ } ,
1163+ } ,
1164+ async ( { exec, fs, expect } ) => {
1165+ await exec ( 'npx @tailwindcss/upgrade' )
1166+
1167+ expect ( await fs . dumpFiles ( 'src/*.css' ) ) . toMatchInlineSnapshot ( `
1168+ "
1169+ --- src/input.css ---
1170+ @import 'tailwindcss';
1171+
1172+ @custom-variant supports-foo {
1173+ @supports (bar: var(--foo)) {
1174+ @slot;
1175+ }
1176+ }
1177+ @custom-variant supports-bar {
1178+ @supports ((qux: var(--bar))) {
1179+ @slot;
1180+ }
1181+ }
1182+ @custom-variant supports-grid {
1183+ @supports (display: grid) {
1184+ @slot;
1185+ }
1186+ }
1187+
1188+ /*
1189+ The default border color has changed to \`currentcolor\` in Tailwind CSS v4,
1190+ so we've added these compatibility styles to make sure everything still
1191+ looks the same as it did with Tailwind CSS v3.
1192+
1193+ If we ever want to remove these styles, we need to add an explicit border
1194+ color utility to any element that depends on these defaults.
1195+ */
1196+ @layer base {
1197+ *,
1198+ ::after,
1199+ ::before,
1200+ ::backdrop,
1201+ ::file-selector-button {
1202+ border-color: var(--color-gray-200, currentcolor);
1203+ }
1204+ }
1205+ "
1206+ ` )
1207+ } ,
1208+ )
1209+
11211210describe ( 'border compatibility' , ( ) => {
11221211 test (
11231212 'migrate border compatibility' ,
0 commit comments