Skip to content

Remove fallbacks from theme var(...) calls #14881

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Remove fixed line-height theme values and derive `leading-*` utilites from `--spacing-*` scale ([#14857](https://github.com/tailwindlabs/tailwindcss/pull/14857))
- Remove `--transition-timing-function-linear` from the default theme in favor of a static `ease-linear` utility ([#14880](https://github.com/tailwindlabs/tailwindcss/pull/14880))
- Remove default `--spacing-*` scale in favor of `--spacing` multiplier ([#14857](https://github.com/tailwindlabs/tailwindcss/pull/14857))
- Remove `var(…)` fallbacks from theme values in utilities ([#14881](https://github.com/tailwindlabs/tailwindcss/pull/14881))

## [4.0.0-alpha.31] - 2024-10-29

Expand Down
4 changes: 2 additions & 2 deletions integrations/cli/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ describe.each([
candidate`hocus:underline`,
css`
.text-primary {
color: var(--color-primary, black);
color: var(--color-primary);
}
`,
])
Expand Down Expand Up @@ -207,7 +207,7 @@ describe.each([
await fs.expectFileToContain('project-a/dist/out.css', [
css`
.text-primary {
color: var(--color-primary, red);
color: var(--color-primary);
}
`,
])
Expand Down
4 changes: 2 additions & 2 deletions integrations/postcss/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ test(
candidate`hocus:underline`,
css`
.text-primary {
color: var(--color-primary, black);
color: var(--color-primary);
}
`,
])
Expand Down Expand Up @@ -446,7 +446,7 @@ test(
await fs.expectFileToContain('project-a/dist/out.css', [
css`
.text-primary {
color: var(--color-primary, red);
color: var(--color-primary);
}
`,
])
Expand Down
4 changes: 2 additions & 2 deletions integrations/vite/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ for (let transformer of ['postcss', 'lightningcss']) {
candidate`flex`,
css`
.text-primary {
color: var(--color-primary, black);
color: var(--color-primary);
}
`,
])
Expand All @@ -356,7 +356,7 @@ for (let transformer of ['postcss', 'lightningcss']) {

expect(styles).toContain(css`
.text-primary {
color: var(--color-primary, red);
color: var(--color-primary);
}
`)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,12 +541,12 @@ exports[`\`@import 'tailwindcss'\` is replaced with the generated CSS 1`] = `

@layer utilities {
.text-2xl {
font-size: var(--font-size-2xl, 1.5rem);
line-height: var(--tw-leading, var(--font-size-2xl--line-height, 2rem));
font-size: var(--font-size-2xl);
line-height: var(--tw-leading, var(--font-size-2xl--line-height));
}

.text-black\\/50 {
color: color-mix(in oklch, var(--color-black, #000) 50%, transparent);
color: color-mix(in oklch, var(--color-black) 50%, transparent);
}

.underline {
Expand Down
2 changes: 1 addition & 1 deletion packages/@tailwindcss-postcss/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ test('@apply can be used without emitting the theme in the CSS file', async () =

expect(result.css.trim()).toMatchInlineSnapshot(`
".foo {
color: var(--color-red-500, oklch(.637 .237 25.331));
color: var(--color-red-500);
}"
`)
})
Expand Down
4 changes: 2 additions & 2 deletions packages/tailwindcss/src/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,11 @@ exports[`compiling CSS > \`@tailwind utilities\` is replaced by utilities using
}

.w-4 {
width: calc(var(--spacing, .25rem) * 4);
width: calc(var(--spacing) * 4);
}

.bg-red-500 {
background-color: var(--color-red-500, oklch(.637 .237 25.331));
background-color: var(--color-red-500);
}

.shadow-sm {
Expand Down
36 changes: 18 additions & 18 deletions packages/tailwindcss/src/__snapshots__/utilities.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ exports[`border-* 1`] = `
}

.border-red-500 {
border-color: var(--color-red-500, #ef4444);
border-color: var(--color-red-500);
}

.border-red-500\\/50 {
border-color: color-mix(in oklch, var(--color-red-500, #ef4444) 50%, transparent);
border-color: color-mix(in oklch, var(--color-red-500) 50%, transparent);
}

.border-transparent {
Expand Down Expand Up @@ -216,11 +216,11 @@ exports[`border-b-* 1`] = `
}

.border-b-red-500 {
border-bottom-color: var(--color-red-500, #ef4444);
border-bottom-color: var(--color-red-500);
}

.border-b-red-500\\/50 {
border-bottom-color: color-mix(in oklch, var(--color-red-500, #ef4444) 50%, transparent);
border-bottom-color: color-mix(in oklch, var(--color-red-500) 50%, transparent);
}

.border-b-transparent {
Expand Down Expand Up @@ -337,11 +337,11 @@ exports[`border-e-* 1`] = `
}

.border-e-red-500 {
border-inline-end-color: var(--color-red-500, #ef4444);
border-inline-end-color: var(--color-red-500);
}

.border-e-red-500\\/50 {
border-inline-end-color: color-mix(in oklch, var(--color-red-500, #ef4444) 50%, transparent);
border-inline-end-color: color-mix(in oklch, var(--color-red-500) 50%, transparent);
}

.border-e-transparent {
Expand Down Expand Up @@ -458,11 +458,11 @@ exports[`border-l-* 1`] = `
}

.border-l-red-500 {
border-left-color: var(--color-red-500, #ef4444);
border-left-color: var(--color-red-500);
}

.border-l-red-500\\/50 {
border-left-color: color-mix(in oklch, var(--color-red-500, #ef4444) 50%, transparent);
border-left-color: color-mix(in oklch, var(--color-red-500) 50%, transparent);
}

.border-l-transparent {
Expand Down Expand Up @@ -579,11 +579,11 @@ exports[`border-r-* 1`] = `
}

.border-r-red-500 {
border-right-color: var(--color-red-500, #ef4444);
border-right-color: var(--color-red-500);
}

.border-r-red-500\\/50 {
border-right-color: color-mix(in oklch, var(--color-red-500, #ef4444) 50%, transparent);
border-right-color: color-mix(in oklch, var(--color-red-500) 50%, transparent);
}

.border-r-transparent {
Expand Down Expand Up @@ -700,11 +700,11 @@ exports[`border-s-* 1`] = `
}

.border-s-red-500 {
border-inline-start-color: var(--color-red-500, #ef4444);
border-inline-start-color: var(--color-red-500);
}

.border-s-red-500\\/50 {
border-inline-start-color: color-mix(in oklch, var(--color-red-500, #ef4444) 50%, transparent);
border-inline-start-color: color-mix(in oklch, var(--color-red-500) 50%, transparent);
}

.border-s-transparent {
Expand Down Expand Up @@ -821,11 +821,11 @@ exports[`border-t-* 1`] = `
}

.border-t-red-500 {
border-top-color: var(--color-red-500, #ef4444);
border-top-color: var(--color-red-500);
}

.border-t-red-500\\/50 {
border-top-color: color-mix(in oklch, var(--color-red-500, #ef4444) 50%, transparent);
border-top-color: color-mix(in oklch, var(--color-red-500) 50%, transparent);
}

.border-t-transparent {
Expand Down Expand Up @@ -942,11 +942,11 @@ exports[`border-x-* 1`] = `
}

.border-x-red-500 {
border-inline-color: var(--color-red-500, #ef4444);
border-inline-color: var(--color-red-500);
}

.border-x-red-500\\/50 {
border-inline-color: color-mix(in oklch, var(--color-red-500, #ef4444) 50%, transparent);
border-inline-color: color-mix(in oklch, var(--color-red-500) 50%, transparent);
}

.border-x-transparent {
Expand Down Expand Up @@ -1063,11 +1063,11 @@ exports[`border-y-* 1`] = `
}

.border-y-red-500 {
border-block-color: var(--color-red-500, #ef4444);
border-block-color: var(--color-red-500);
}

.border-y-red-500\\/50 {
border-block-color: color-mix(in oklch, var(--color-red-500, #ef4444) 50%, transparent);
border-block-color: color-mix(in oklch, var(--color-red-500) 50%, transparent);
}

.border-y-transparent {
Expand Down
2 changes: 1 addition & 1 deletion packages/tailwindcss/src/at-import.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ test('supports theme(reference) imports', async () => {
),
).resolves.toMatchInlineSnapshot(`
".text-red-500 {
color: var(--color-red-500, red);
color: var(--color-red-500);
}
"
`)
Expand Down
16 changes: 8 additions & 8 deletions packages/tailwindcss/src/compat/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ describe('theme overrides order', () => {
--color-blue: blue;
}
.bg-blue {
background-color: var(--color-blue, blue);
background-color: var(--color-blue);
}
.bg-red {
background-color: very-red;
Expand Down Expand Up @@ -491,19 +491,19 @@ describe('theme overrides order', () => {
--color-slate-500: #100500;
}
.bg-slate-100 {
background-color: var(--color-slate-100, #000100);
background-color: var(--color-slate-100);
}
.bg-slate-200 {
background-color: #200200;
}
.bg-slate-300 {
background-color: var(--color-slate-300, #000300);
background-color: var(--color-slate-300);
}
.bg-slate-400 {
background-color: var(--color-slate-400, #100400);
background-color: var(--color-slate-400);
}
.bg-slate-500 {
background-color: var(--color-slate-500, #100500);
background-color: var(--color-slate-500);
}
.bg-slate-600 {
background-color: #200600;
Expand Down Expand Up @@ -742,7 +742,7 @@ describe('default font family compatibility', () => {
--font-family-sans: Sandwich Sans;
}
.font-sans {
font-family: var(--font-family-sans, Sandwich Sans);
font-family: var(--font-family-sans);
}
"
`)
Expand Down Expand Up @@ -1021,7 +1021,7 @@ describe('default font family compatibility', () => {
--font-family-mono: Sandwich Mono;
}
.font-mono {
font-family: var(--font-family-mono, Sandwich Mono);
font-family: var(--font-family-mono);
}
"
`)
Expand Down Expand Up @@ -1476,7 +1476,7 @@ test('blocklisted candidates are not generated', async () => {
}
.md\\:bg-white {
@media (width >= 48rem) {
background-color: var(--color-white, #fff);
background-color: var(--color-white);
}
}
"
Expand Down
Loading