This repository has been archived on 2025-08-19. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
coinstorge/website/src/lib/utils.ts

28 lines
996 B
TypeScript
Raw Normal View History

2025-05-21 21:34:22 +03:00
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type WithoutChild<T> = T extends { child?: any } ? Omit<T, "child"> : T;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type WithoutChildren<T> = T extends { children?: any } ? Omit<T, "children"> : T;
export type WithoutChildrenOrChild<T> = WithoutChildren<WithoutChild<T>>;
export type WithElementRef<T, U extends HTMLElement = HTMLElement> = T & { ref?: U | null };
2025-05-22 14:00:43 +03:00
export function getTimeBasedGreeting(name: string): string {
const hour = new Date().getHours();
if (hour < 12) {
return `Good morning, ${name}`;
} else if (hour < 17) {
return `Good afternoon, ${name}`;
} else if (hour < 22) {
return `Good evening, ${name}`;
} else {
return `Good night, ${name}`;
}
}