Skip to content

Commit adb9580

Browse files
committed
fix
1 parent 24ed64e commit adb9580

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ test('config values can be merged into the theme', () => {
5555
lg: ['1.125rem', '2'],
5656
xl: ['1.5rem', '3rem', 'invalid'],
5757
'2xl': ['2rem'],
58+
LargeTitle: ['28px', { fontWeight: 700, lineHeight: '36px' }],
5859
},
5960

6061
letterSpacing: {
@@ -117,6 +118,7 @@ test('config values can be merged into the theme', () => {
117118
])
118119
expect(theme.resolve('2xl', ['--text'])).toEqual('2rem')
119120
expect(theme.resolveWith('2xl', ['--text'], ['--line-height'])).toEqual(['2rem', {}])
121+
expect(theme.resolve('LargeTitle', ['--text'])).toEqual('28px')
120122
expect(theme.resolve('super-wide', ['--tracking'])).toEqual('0.25em')
121123
expect(theme.resolve('super-loose', ['--leading'])).toEqual('3')
122124
expect(theme.resolve('1/2', ['--width'])).toEqual('60%')

packages/tailwindcss/src/theme.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,12 @@ export class Theme {
165165
candidateValue !== null ? (`${namespace}-${candidateValue}` as ThemeKey) : namespace
166166

167167
if (!this.values.has(themeKey)) {
168-
// If the exact theme key is not found, we might be trying to resolve a key containing a dot
169-
// that was registered with an underscore instead:
170-
if (candidateValue !== null && candidateValue.includes('.')) {
171-
themeKey = `${namespace}-${candidateValue.replaceAll('.', '_')}` as ThemeKey
168+
if (candidateValue !== null) {
169+
// If the exact theme key is not found, we might be trying to resolve a key:
170+
// - containing a dot that was registered with an underscore instead
171+
// - containing a lowercase alphabet followed by an uppercase one that was replaced to kebab case
172+
themeKey =
173+
`${namespace}-${candidateValue.replaceAll('.', '_').replace(/([a-z])([A-Z])/g, (_, a, b) => `${a}-${b.toLowerCase()}`)}` as ThemeKey
172174

173175
if (!this.values.has(themeKey)) continue
174176
} else {

0 commit comments

Comments
 (0)