This commit is contained in:
sunzhongyi
2026-05-20 01:30:49 +08:00
parent 7dded89537
commit 610805a374
42 changed files with 3451 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
import { describe, it, expect } from 'vitest';
import { cx } from '../cx';
describe('cx', () => {
it('joins truthy strings', () => {
expect(cx('a', 'b', 'c')).toBe('a b c');
});
it('filters out falsy values', () => {
expect(cx('a', false, 'b', null, undefined, 'c')).toBe('a b c');
});
it('returns empty string when all falsy', () => {
expect(cx(false, null, undefined)).toBe('');
});
});
+6
View File
@@ -0,0 +1,6 @@
type ClassValue = string | false | null | undefined;
/** Tiny className joiner. Filters out falsy values. */
export function cx(...args: ClassValue[]): string {
return args.filter(Boolean).join(' ');
}