Skip to content
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
34 changes: 17 additions & 17 deletions packages/tailwindcss/src/canonicalize-candidates.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -520,16 +520,16 @@ describe.each([['default'], ['with-variant'], ['important'], ['prefix']])('%s',
'migrate with custom functional utility `@utility custom-* {…}` that supports bare values',
{ timeout },
async () => {
let candidate = '[tab-size:4]'
let expected = 'tab-4'
let candidate = '[--resolved-value:4]'
let expected = 'example-4'

let input = css`
@import 'tailwindcss';
@theme {
--*: initial;
}
@utility tab-* {
tab-size: --value(integer);
@utility example-* {
--resolved-value: --value(integer);
}
`

Expand All @@ -538,24 +538,24 @@ describe.each([['default'], ['with-variant'], ['important'], ['prefix']])('%s',
)

test.each([
['[tab-size:0]', 'tab-0'],
['[tab-size:4]', 'tab-4'],
['[tab-size:8]', 'tab-github'],
['tab-[0]', 'tab-0'],
['tab-[4]', 'tab-4'],
['tab-[8]', 'tab-github'],
['[--resolved-value:0]', 'example-0'],
['[--resolved-value:4]', 'example-4'],
['[--resolved-value:8]', 'example-a'],
['example-[0]', 'example-0'],
['example-[4]', 'example-4'],
['example-[8]', 'example-a'],
])(
'migrate custom @utility from arbitrary values to bare values and named values (based on theme)',
async (candidate, expected) => {
let input = css`
@import 'tailwindcss';
@theme {
--*: initial;
--tab-size-github: 8;
--example-a: 8;
}

@utility tab-* {
tab-size: --value(--tab-size, integer, [integer]);
@utility example-* {
--resolved-value: --value(--example, integer, [integer]);
}
`

Expand Down Expand Up @@ -676,11 +676,11 @@ describe.each([['default'], ['with-variant'], ['important'], ['prefix']])('%s',
--*: initial;
--spacing: 0.25rem;
--aspect-video: 16 / 9;
--tab-size-github: 8;
--example-a: 8;
}

@utility tab-* {
tab-size: --value(--tab-size, integer);
@utility example-* {
--resolved-value: --value(--example, integer);
}
`

Expand All @@ -689,7 +689,7 @@ describe.each([['default'], ['with-variant'], ['important'], ['prefix']])('%s',
['aspect-16/9', 'aspect-video'],

// Custom utility with bare value integer
['tab-8', 'tab-github'],
['example-8', 'example-a'],
])(testName, { timeout }, async (candidate, expected) => {
await expectCanonicalization(input, candidate, expected)
})
Expand Down
30 changes: 7 additions & 23 deletions packages/tailwindcss/src/intellisense.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,11 +497,6 @@ test('Custom functional @utility', async () => {
@import 'tailwindcss/utilities';

@theme reference {
--tab-size-1: 1;
--tab-size-2: 2;
--tab-size-4: 4;
--tab-size-github: 8;

--text-xs: 0.75rem;
--text-xs--line-height: calc(1 / 0.75);

Expand All @@ -510,10 +505,11 @@ test('Custom functional @utility', async () => {

--spacing: 0.25rem;
--spacing-custom: 123px;
}

@utility tab-* {
tab-size: --value(--tab-size, 'revert', 'initial');
--negative-1: 1;
--negative-2: 2;
--negative-4: 4;
--negative-a: 8;
}

@utility example-* {
Expand All @@ -535,7 +531,7 @@ test('Custom functional @utility', async () => {
}

@utility -negative-* {
margin: --value(--tab-size-*);
margin: --value(--negative-*);
}
`

Expand All @@ -550,18 +546,6 @@ test('Custom functional @utility', async () => {
let classMap = new Map(design.getClassList())
let classNames = Array.from(classMap.keys())

expect(classNames).toContain('tab-1')
expect(classNames).toContain('tab-2')
expect(classNames).toContain('tab-4')
expect(classNames).toContain('tab-github')
expect(classNames).toContain('tab-revert')
expect(classNames).toContain('tab-initial')

expect(classNames).not.toContain('-tab-1')
expect(classNames).not.toContain('-tab-2')
expect(classNames).not.toContain('-tab-4')
expect(classNames).not.toContain('-tab-github')

expect(classNames).toContain('with-custom-spacing-custom')
expect(classNames).not.toContain('with-custom-spacing-0')
expect(classNames).not.toContain('with-custom-spacing-0.5')
Expand All @@ -583,12 +567,12 @@ test('Custom functional @utility', async () => {
expect(classNames).toContain('-negative-1')
expect(classNames).toContain('-negative-2')
expect(classNames).toContain('-negative-4')
expect(classNames).toContain('-negative-github')
expect(classNames).toContain('-negative-a')

expect(classNames).not.toContain('--negative-1')
expect(classNames).not.toContain('--negative-2')
expect(classNames).not.toContain('--negative-4')
expect(classNames).not.toContain('--negative-github')
expect(classNames).not.toContain('--negative-a')

expect(classNames).toContain('example-xs')
expect(classMap.get('example-xs')?.modifiers).toEqual(['normal', 'foo', 'bar'])
Expand Down
Loading