Skip to content

Commit b5df5e9

Browse files
Use variables with fallbacks for utility classes (#13177)
* Use variables with fallbacks for utility classes * Update playwright test * rename `resolveBare` to `resolveValue` * make private methods really private --------- Co-authored-by: Adam Wathan <[email protected]> Co-authored-by: Robin Malfait <[email protected]>
1 parent a3cedf2 commit b5df5e9

File tree

9 files changed

+323
-305
lines changed

9 files changed

+323
-305
lines changed

packages/@tailwindcss-postcss/src/__snapshots__/index.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -585,12 +585,12 @@ exports[`\`@import 'tailwindcss'\` is replaced with the generated CSS 1`] = `
585585
586586
@layer utilities {
587587
.text-2xl {
588-
font-size: 1.5rem;
589-
line-height: 2rem;
588+
font-size: var(--font-size-2xl, 1.5rem);
589+
line-height: var(--font-size-2xl--line-height, 2rem);
590590
}
591591
592592
.text-black\\/50 {
593-
color: #00000080;
593+
color: color-mix(in srgb, var(--color-black, #000) 50%, transparent);
594594
}
595595
596596
.underline {

packages/@tailwindcss-postcss/src/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ test('@apply can be used without emitting the theme in the CSS file', async () =
104104

105105
expect(result.css.trim()).toMatchInlineSnapshot(`
106106
".foo {
107-
color: #ef4444;
107+
color: var(--color-red-500, #ef4444);
108108
}"
109109
`)
110110
})

packages/tailwindcss/src/__snapshots__/index.test.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,11 +404,11 @@ exports[`compiling CSS > \`@tailwind utilities\` is replaced by utilities using
404404
}
405405
406406
.w-4 {
407-
width: 1rem;
407+
width: var(--spacing-4, 1rem);
408408
}
409409
410410
.bg-red-500 {
411-
background-color: #ef4444;
411+
background-color: var(--color-red-500, #ef4444);
412412
}
413413
414414
.shadow {

packages/tailwindcss/src/__snapshots__/utilities.test.ts.snap

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ exports[`border-* 1`] = `
9595
}
9696
9797
.border-red-500 {
98-
border-color: #ef4444;
98+
border-color: var(--color-red-500, #ef4444);
9999
}
100100
101101
.border-red-500\\/50 {
102-
border-color: #ef444480;
102+
border-color: color-mix(in srgb, var(--color-red-500, #ef4444) 50%, transparent);
103103
}
104104
105105
.border-transparent {
@@ -208,11 +208,11 @@ exports[`border-b-* 1`] = `
208208
}
209209
210210
.border-b-red-500 {
211-
border-bottom-color: #ef4444;
211+
border-bottom-color: var(--color-red-500, #ef4444);
212212
}
213213
214214
.border-b-red-500\\/50 {
215-
border-bottom-color: #ef444480;
215+
border-bottom-color: color-mix(in srgb, var(--color-red-500, #ef4444) 50%, transparent);
216216
}
217217
218218
.border-b-transparent {
@@ -321,11 +321,11 @@ exports[`border-e-* 1`] = `
321321
}
322322
323323
.border-e-red-500 {
324-
border-inline-end-color: #ef4444;
324+
border-inline-end-color: var(--color-red-500, #ef4444);
325325
}
326326
327327
.border-e-red-500\\/50 {
328-
border-inline-end-color: #ef444480;
328+
border-inline-end-color: color-mix(in srgb, var(--color-red-500, #ef4444) 50%, transparent);
329329
}
330330
331331
.border-e-transparent {
@@ -434,11 +434,11 @@ exports[`border-l-* 1`] = `
434434
}
435435
436436
.border-l-red-500 {
437-
border-left-color: #ef4444;
437+
border-left-color: var(--color-red-500, #ef4444);
438438
}
439439
440440
.border-l-red-500\\/50 {
441-
border-left-color: #ef444480;
441+
border-left-color: color-mix(in srgb, var(--color-red-500, #ef4444) 50%, transparent);
442442
}
443443
444444
.border-l-transparent {
@@ -547,11 +547,11 @@ exports[`border-r-* 1`] = `
547547
}
548548
549549
.border-r-red-500 {
550-
border-right-color: #ef4444;
550+
border-right-color: var(--color-red-500, #ef4444);
551551
}
552552
553553
.border-r-red-500\\/50 {
554-
border-right-color: #ef444480;
554+
border-right-color: color-mix(in srgb, var(--color-red-500, #ef4444) 50%, transparent);
555555
}
556556
557557
.border-r-transparent {
@@ -660,11 +660,11 @@ exports[`border-s-* 1`] = `
660660
}
661661
662662
.border-s-red-500 {
663-
border-inline-start-color: #ef4444;
663+
border-inline-start-color: var(--color-red-500, #ef4444);
664664
}
665665
666666
.border-s-red-500\\/50 {
667-
border-inline-start-color: #ef444480;
667+
border-inline-start-color: color-mix(in srgb, var(--color-red-500, #ef4444) 50%, transparent);
668668
}
669669
670670
.border-s-transparent {
@@ -773,11 +773,11 @@ exports[`border-t-* 1`] = `
773773
}
774774
775775
.border-t-red-500 {
776-
border-top-color: #ef4444;
776+
border-top-color: var(--color-red-500, #ef4444);
777777
}
778778
779779
.border-t-red-500\\/50 {
780-
border-top-color: #ef444480;
780+
border-top-color: color-mix(in srgb, var(--color-red-500, #ef4444) 50%, transparent);
781781
}
782782
783783
.border-t-transparent {
@@ -915,13 +915,13 @@ exports[`border-x-* 1`] = `
915915
}
916916
917917
.border-x-red-500 {
918-
border-left-color: #ef4444;
919-
border-right-color: #ef4444;
918+
border-left-color: var(--color-red-500, #ef4444);
919+
border-right-color: var(--color-red-500, #ef4444);
920920
}
921921
922922
.border-x-red-500\\/50 {
923-
border-left-color: #ef444480;
924-
border-right-color: #ef444480;
923+
border-left-color: color-mix(in srgb, var(--color-red-500, #ef4444) 50%, transparent);
924+
border-right-color: color-mix(in srgb, var(--color-red-500, #ef4444) 50%, transparent);
925925
}
926926
927927
.border-x-transparent {
@@ -1060,13 +1060,13 @@ exports[`border-y-* 1`] = `
10601060
}
10611061
10621062
.border-y-red-500 {
1063-
border-top-color: #ef4444;
1064-
border-bottom-color: #ef4444;
1063+
border-top-color: var(--color-red-500, #ef4444);
1064+
border-bottom-color: var(--color-red-500, #ef4444);
10651065
}
10661066
10671067
.border-y-red-500\\/50 {
1068-
border-top-color: #ef444480;
1069-
border-bottom-color: #ef444480;
1068+
border-top-color: color-mix(in srgb, var(--color-red-500, #ef4444) 50%, transparent);
1069+
border-bottom-color: color-mix(in srgb, var(--color-red-500, #ef4444) 50%, transparent);
10701070
}
10711071
10721072
.border-y-transparent {

0 commit comments

Comments
 (0)