Initial commit
This commit is contained in:
18
lib/utils.ts
Normal file
18
lib/utils.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { twMerge } from 'tailwind-merge';
|
||||
|
||||
type ClassValue = string | undefined | null | false | Record<string, boolean>;
|
||||
type ClassArray = ClassValue[];
|
||||
|
||||
export function cn(...classes: (ClassValue | ClassArray)[]): string {
|
||||
const merged = classes
|
||||
.flat()
|
||||
.filter((cls): cls is string => typeof cls === 'string')
|
||||
.join(' ');
|
||||
return twMerge(merged);
|
||||
}
|
||||
|
||||
export const truncate = (text: string, maxLength: number): string => {
|
||||
if (!text) return '';
|
||||
if (text.length <= maxLength) return text;
|
||||
return text.slice(0, maxLength).trim() + '...';
|
||||
};
|
||||
Reference in New Issue
Block a user