@@ -1055,6 +1055,87 @@ test(
1055
1055
} ,
1056
1056
)
1057
1057
1058
+ test (
1059
+ 'migrate data theme keys to custom variants' ,
1060
+ {
1061
+ fs : {
1062
+ 'package.json' : json `
1063
+ {
1064
+ "dependencies": {
1065
+ "tailwindcss": "^3",
1066
+ "@tailwindcss/upgrade": "workspace:^"
1067
+ }
1068
+ }
1069
+ ` ,
1070
+ 'tailwind.config.ts' : ts `
1071
+ export default {
1072
+ content: {
1073
+ relative: true,
1074
+ files: ['./src/**/*.html'],
1075
+ },
1076
+ theme: {
1077
+ extend: {
1078
+ data: {
1079
+ // Automatically handled by bare values
1080
+ foo: 'foo',
1081
+
1082
+ // Not automatically handled by bare values because names differ
1083
+ bar: 'baz',
1084
+
1085
+ // Custom
1086
+ checked: 'ui~="checked"',
1087
+ },
1088
+ },
1089
+ },
1090
+ }
1091
+ ` ,
1092
+ 'src/input.css' : css `
1093
+ @tailwind base;
1094
+ @tailwind components;
1095
+ @tailwind utilities;
1096
+ ` ,
1097
+ } ,
1098
+ } ,
1099
+ async ( { exec, fs, expect } ) => {
1100
+ await exec ( 'npx @tailwindcss/upgrade' )
1101
+
1102
+ expect ( await fs . dumpFiles ( 'src/*.css' ) ) . toMatchInlineSnapshot ( `
1103
+ "
1104
+ --- src/input.css ---
1105
+ @import 'tailwindcss';
1106
+
1107
+ /*
1108
+ These variants have been migrated from your Tailwind CSS configuration file.
1109
+ Since they are custom variants, they will be sorted after all built-in variants.
1110
+
1111
+ This may result in elements appearing different if you were relying on the order of
1112
+ the variants in the CSS.
1113
+ */
1114
+ @custom-variant data-bar (&[data-baz]);
1115
+ @custom-variant data-checked (&[data-ui~="checked"]);
1116
+
1117
+ /*
1118
+ The default border color has changed to \`currentcolor\` in Tailwind CSS v4,
1119
+ so we've added these compatibility styles to make sure everything still
1120
+ looks the same as it did with Tailwind CSS v3.
1121
+
1122
+ If we ever want to remove these styles, we need to add an explicit border
1123
+ color utility to any element that depends on these defaults.
1124
+ */
1125
+ @layer base {
1126
+ *,
1127
+ ::after,
1128
+ ::before,
1129
+ ::backdrop,
1130
+ ::file-selector-button {
1131
+ border-color: var(--color-gray-200, currentcolor);
1132
+ }
1133
+ }
1134
+ "
1135
+ ` )
1136
+ } ,
1137
+ )
1138
+
1058
1139
describe ( 'border compatibility' , ( ) => {
1059
1140
test (
1060
1141
'migrate border compatibility' ,
0 commit comments