Initial commit

This commit is contained in:
Harivansh Rathi 2024-12-05 15:59:08 -05:00
commit ae239a2849
42 changed files with 6674 additions and 0 deletions

26
src/utils/cn.ts Normal file
View file

@ -0,0 +1,26 @@
type ClassValue = string | number | boolean | undefined | null;
type ClassArray = ClassValue[];
type ClassObject = { [key: string]: any };
type ClassInput = ClassValue | ClassArray | ClassObject;
export function cn(...inputs: ClassInput[]): string {
const classes = [];
for (const input of inputs) {
if (!input) continue;
if (typeof input === 'string') {
classes.push(input);
} else if (Array.isArray(input)) {
classes.push(cn(...input));
} else if (typeof input === 'object') {
for (const key in input) {
if (input[key]) {
classes.push(key);
}
}
}
}
return classes.join(' ');
}