fix: fix indentation, export ClassValue, add object-syntax test
This commit is contained in:
@@ -22,6 +22,12 @@ describe('cn', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('object syntax', () => {
|
||||||
|
it('includes classes with truthy object values', () => {
|
||||||
|
expect(cn({ foo: true, bar: false })).toBe('foo')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('tailwind conflict resolution', () => {
|
describe('tailwind conflict resolution', () => {
|
||||||
it('last padding wins', () => {
|
it('last padding wins', () => {
|
||||||
expect(cn('px-2', 'px-4')).toBe('px-4')
|
expect(cn('px-2', 'px-4')).toBe('px-4')
|
||||||
|
|||||||
@@ -5,5 +5,5 @@ import { twMerge } from 'tailwind-merge'
|
|||||||
* Merges Tailwind classes, resolving conflicts in favor of the last value.
|
* Merges Tailwind classes, resolving conflicts in favor of the last value.
|
||||||
*/
|
*/
|
||||||
export function cn(...inputs: ClassValue[]): string {
|
export function cn(...inputs: ClassValue[]): string {
|
||||||
return twMerge(clsx(inputs))
|
return twMerge(clsx(inputs))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
export { cn } from './cn'
|
export { cn } from './cn'
|
||||||
|
export type { ClassValue } from 'clsx'
|
||||||
|
|||||||
Reference in New Issue
Block a user