Skip to content
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

Fix incorrect conflicts in Font Variant Numeric classes #18

Merged
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
48 changes: 38 additions & 10 deletions src/default-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -584,16 +584,32 @@ export function getDefaultConfig() {
* Font Variant Numeric
* @see https://tailwindcss.com/docs/font-variant-numeric
*/
'font-variant-numeric': [
'normal-nums',
'ordinal',
'slashed-zero',
'lining-nums',
'oldstyle-nums',
'tabular-nums',
'diagonal-nums',
'stacked-fractons',
],
'fvn-normal': ['normal-nums'],
/**
* Font Variant Numeric
* @see https://tailwindcss.com/docs/font-variant-numeric
*/
'fvn-ordinal': ['ordinal'],
/**
* Font Variant Numeric
* @see https://tailwindcss.com/docs/font-variant-numeric
*/
'fvn-slashed-zero': ['slashed-zero'],
/**
* Font Variant Numeric
* @see https://tailwindcss.com/docs/font-variant-numeric
*/
'fvn-figure': ['lining-nums', 'oldstyle-nums'],
/**
* Font Variant Numeric
* @see https://tailwindcss.com/docs/font-variant-numeric
*/
'fvn-spacing': ['proportional-nums', 'tabular-nums'],
/**
* Font Variant Numeric
* @see https://tailwindcss.com/docs/font-variant-numeric
*/
'fvn-fraction': ['diagonal-fractions', 'stacked-fractons'],
/**
* Letter Spacing
* @see https://tailwindcss.com/docs/letter-spacing
Expand Down Expand Up @@ -1228,6 +1244,18 @@ export function getDefaultConfig() {
mx: ['mr', 'ml'],
my: ['mt', 'mb'],
'font-size': ['leading'],
'fvn-normal': [
'fvn-ordinal',
'fvn-slashed-zero',
'fvn-figure',
'fvn-spacing',
'fvn-fraction',
],
'fvn-ordinal': ['fvn-normal'],
'fvn-slashed-zero': ['fvn-normal'],
'fvn-figure': ['fvn-normal'],
'fvn-spacing': ['fvn-normal'],
'fvn-fraction': ['fvn-normal'],
rounded: [
'rounded-t',
'rounded-r',
Expand Down
23 changes: 23 additions & 0 deletions tests/class-group-conflicts.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { twMerge } from '../src'

test('merges classes from same group correctly', () => {
expect(twMerge('overflow-x-auto overflow-x-hidden')).toBe('overflow-x-hidden')
expect(twMerge('overflow-x-auto overflow-x-hidden overflow-x-scroll')).toBe('overflow-x-scroll')
expect(twMerge('overflow-x-auto hover:overflow-x-hidden overflow-x-scroll')).toBe(
'hover:overflow-x-hidden overflow-x-scroll'
)
expect(
twMerge('overflow-x-auto hover:overflow-x-hidden hover:overflow-x-auto overflow-x-scroll')
).toBe('hover:overflow-x-auto overflow-x-scroll')
})

test('merges classes from Font Variant Numeric section correctly', () => {
expect(twMerge('lining-nums tabular-nums diagonal-fractions')).toBe(
'lining-nums tabular-nums diagonal-fractions'
)
expect(twMerge('normal-nums tabular-nums diagonal-fractions')).toBe(
'tabular-nums diagonal-fractions'
)
expect(twMerge('tabular-nums diagonal-fractions normal-nums')).toBe('normal-nums')
expect(twMerge('tabular-nums proportional-nums')).toBe('proportional-nums')
})
12 changes: 0 additions & 12 deletions tests/dynamic-classes.test.ts

This file was deleted.