Skip to content

Commit 0257fe8

Browse files
committed
Add array length possibilities
1 parent 6f3063f commit 0257fe8

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

integrations/upgrade/js-config.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ test(
3838
sm: ['0.875rem', { lineHeight: '1.5rem' }],
3939
base: ['1rem', { lineHeight: '2rem' }],
4040
lg: ['1.125rem', '2.5rem'],
41+
xl: ['1.5rem', '3rem', 'invalid'],
42+
'2xl': ['2rem'],
4143
},
4244
width: {
4345
px: '1px',
@@ -191,6 +193,9 @@ test(
191193
--text-base--line-height: 2rem;
192194
--text-lg: 1.125rem;
193195
--text-lg--line-height: 2.5rem;
196+
--text-xl: 1.5rem;
197+
--text-xl--line-height: 3rem;
198+
--text-2xl: 2rem;
194199
195200
--width-*: initial;
196201
--width-0: 0%;

packages/tailwindcss/src/compat/apply-config-to-theme.test.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,9 @@ test('config values can be merged into the theme', () => {
5252
lineHeight: '1.5',
5353
},
5454
],
55-
lg: [
56-
'1.125rem',
57-
'2',
58-
],
55+
lg: ['1.125rem', '2'],
56+
xl: ['1.5rem', '3rem', 'invalid'],
57+
'2xl': ['2rem'],
5958
},
6059

6160
letterSpacing: {
@@ -111,6 +110,16 @@ test('config values can be merged into the theme', () => {
111110
'1.125rem',
112111
{ '--line-height': '2' },
113112
])
113+
expect(theme.resolve('xl', ['--text'])).toEqual('1.5rem')
114+
expect(theme.resolveWith('xl', ['--text'], ['--line-height'])).toEqual([
115+
'1.5rem',
116+
{ '--line-height': '3rem' },
117+
])
118+
expect(theme.resolve('2xl', ['--text'])).toEqual('2rem')
119+
expect(theme.resolveWith('2xl', ['--text'], ['--line-height'])).toEqual([
120+
'2rem',
121+
{},
122+
])
114123
expect(theme.resolve('super-wide', ['--tracking'])).toEqual('0.25em')
115124
expect(theme.resolve('super-loose', ['--leading'])).toEqual('3')
116125
expect(theme.resolve('1/2', ['--width'])).toEqual('60%')

packages/tailwindcss/src/compat/apply-config-to-theme.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,10 @@ export function themeableValues(config: ResolvedConfig['theme']): [string[], unk
132132
if (Array.isArray(value) && value.every((v) => typeof v === 'string')) {
133133
if (path[0] === 'fontSize') {
134134
toAdd.push([path, value[0]])
135-
toAdd.push([[...path, '-line-height'], value[1]])
135+
136+
if (value.length >= 2) {
137+
toAdd.push([[...path, '-line-height'], value[1]])
138+
}
136139
} else {
137140
toAdd.push([path, value.join(', ')])
138141
}

0 commit comments

Comments
 (0)