8000 Resolve values in functional utilities based on `@theme` options by RobinMalfait · Pull Request #15623 · tailwindlabs/tailwindcss · GitHub
Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
update tests
  • Loading branch information
RobinMalfait committed Jan 14, 2025
commit 76c118f9c0fb612e92571fcdae93dc915ef627e1
110 changes: 57 additions & 53 deletions packages/tailwindcss/src/utilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17452,22 +17452,22 @@ describe('custom utilities', () => {

expect(await compileCss(input, ['tab-1', 'tab-2', 'tab-4', 'tab-github']))
.toMatchInlineSnapshot(`
".tab-1 {
tab-size: 1;
}
".tab-1 {
tab-size: var(--tab-size-1);
}

.tab-2 {
tab-size: 2;
}
.tab-2 {
tab-size: var(--tab-size-2);
}

.tab-4 {
tab-size: 4;
}
.tab-4 {
tab-size: var(--tab-size-4);
}

.tab-github {
tab-size: 8;
}"
`)
.tab-github {
tab-size: var(--tab-size-github);
}"
`)
expect(await compileCss(input, ['tab-3', 'tab-gitlab'])).toEqual('')
})

Expand All @@ -17494,19 +17494,19 @@ describe('custom utilities', () => {
expect(await compileCss(input, ['tab-1', 'tab-2', 'tab-4', 'tab-github']))
.toMatchInlineSnapshot(`
".tab-1 {
tab-size: 1;
tab-size: var(--tab-size-1);
}

.tab-2 {
tab-size: 2;
tab-size: var(--tab-size-2);
}

.tab-4 {
tab-size: 4;
tab-size: var(--tab-size-4);
}

.tab-github {
tab-size: 8;
tab-size: var(--tab-size-github);
}"
`)
expect(await compileCss(input, ['tab-3', 'tab-gitlab'])).toEqual('')
Expand All @@ -17531,19 +17531,19 @@ describe('custom utilities', () => {
expect(await compileCss(input, ['tab-1', 'tab-2', 'tab-4', 'tab-github']))
.toMatchInlineSnapshot(`
".tab-1 {
tab-size: 1;
tab-size: var(--tab-size-1);
}

.tab-2 {
tab-size: 2;
tab-size: var(--tab-size-2);
}

.tab-4 {
tab-size: 4;
tab-size: var(--tab-size-4);
}

.tab-github {
tab-size: 8;
tab-size: var(--tab-size-github);
}"
`)
expect(await compileCss(input, ['tab-3', 'tab-gitlab'])).toEqual('')
Expand Down Expand Up @@ -17817,7 +17817,7 @@ describe('custom utilities', () => {
}

.tab-github {
tab-size: 8;
tab-size: var(--tab-size-github);
}"
`)
expect(await compileCss(input, ['tab-[#0088cc]', 'tab-[1px]'])).toEqual('')
Expand Down Expand Up @@ -17849,7 +17849,7 @@ describe('custom utilities', () => {
}

.example-full {
--value: 100%;
--value: var(--example-full);
}"
`)
expect(await compileCss(input, ['example-half', 'example-[#0088cc]'])).toEqual('')
Expand Down Expand Up @@ -17893,7 +17893,7 @@ describe('custom utilities', () => {
}

.example-full {
--value: 100%;
--value: var(--example-full);
}

.tab-76 {
Expand All @@ -17905,7 +17905,7 @@ describe('custom utilities', () => {
}

.tab-github {
tab-size: 8;
tab-size: var(--tab-size-github);
}"
`)
expect(
Expand Down Expand Up @@ -17949,7 +17949,7 @@ describe('custom utilities', () => {
}

.-example-full {
--value: calc(100% * -1);
--value: calc(var(--example-full) * -1);
}

.example-\\[10px\\] {
Expand All @@ -17961,7 +17961,7 @@ describe('custom utilities', () => {
}

.example-full {
--value: 100%;
--value: var(--example-full);
}"
`)
expect(await compileCss(input, ['example-10'])).toEqual('')
Expand Down Expand Up @@ -18062,13 +18062,13 @@ describe('custom utilities', () => {
}

.example-sm {
--value: 14px;
--value: var(--value-sm);
}

.example-sm\\/7 {
--value: 14px;
--modifier: 28px;
--modifier-with-calc: calc(28px * 2);
--value: var(--value-sm);
--modifier: var(--modifier-7);
--modifier-with-calc: calc(var(--modifier-7) * 2);
}"
`)
expect(
Expand All @@ -18091,18 +18091,18 @@ describe('custom utilities', () => {

expect(await compileCss(input, ['example-video', 'example-1/1', 'example-[7/9]']))
.toMatchInlineSnapshot(`
".example-1\\/1 {
--value: 1 / 1;
}
".example-1\\/1 {
--value: 1 / 1;
}

.example-\\[7\\/9\\] {
--value: 7 / 9;
}
.example-\\[7\\/9\\] {
--value: 7 / 9;
}

.example-video {
--value: 16 / 9;
}"
`)
.example-video {
--value: var(--example-video);
}"
`)
expect(await compileCss(input, ['example-foo'])).toEqual('')
})

Expand All @@ -18124,12 +18124,13 @@ describe('custom utilities', () => {

expect(await compileCss(input, ['example-xs', 'example-xs/6'])).toMatchInlineSnapshot(`
".example-xs {
font-size: .75rem;
line-height: 1.33333;
font-size: var(--text-xs);
line-height: var(--text-xs--line-height);
}

.example-xs\\/6 {
font-size: .75rem;
font-size: var(--text-xs);
line-height: var(--text-xs--line-height);
line-height: 6;
Comment on lines +18133 to 18134
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before this change, we also generated 2 line-height declarations, but Lightning CSS collapsed it. However, now that one is generating a variable, Lightning CSS is not optimizing it.

E.g.:

}"
`)
Expand All @@ -18154,12 +18155,13 @@ describe('custom utilities', () => {

expect(await compileCss(input, ['example-xs', 'example-xs/6'])).toMatchInlineSnapshot(`
".example-xs {
font-size: .75rem;
line-height: 1.33333;
font-size: var(--text-xs);
line-height: var(--text-xs--line-height);
}

.example-xs\\/6 {
font-size: .75rem;
font-size: var(--text-xs);
line-height: var(--text-xs--line-height);
line-height: 6;
}"
`)
Expand All @@ -18184,12 +18186,13 @@ describe('custom utilities', () => {

expect(await compileCss(input, ['example-xs', 'example-xs/6'])).toMatchInlineSnapshot(`
".example-xs {
font-size: .75rem;
line-height: 1.33333;
font-size: var(--text-xs);
line-height: var(--text-xs--line-height);
}

.example-xs\\/6 {
font-size: .75rem;
font-size: var(--text-xs);
line-height: var(--text-xs--line-height);
line-height: 6;
}"
`)
Expand All @@ -18214,12 +18217,13 @@ describe('custom utilities', () => {

expect(await compileCss(input, ['example-xs', 'example-xs/6'])).toMatchInlineSnapshot(`
".example-xs {
font-size: .75rem;
line-height: 1.33333;
font-size: var(--text-xs);
line-height: var(--text-xs--line-height);
}

.example-xs\\/6 {
font-size: .75rem;
font-size: var(--text-xs);
line-height: var(--text-xs--line-height);
line-height: 6;
}"
`)
Expand Down