open-swe/apps/web/src/lib/utils.ts

23 lines
579 B
TypeScript
Raw Normal View History

import { type ClassValue, clsx } from "clsx";
2025-05-28 12:26:47 -07:00
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
/**
* Utility function to get a cookie value by name from the client-side
*/
export function getCookie(name: string): string | null {
if (typeof document === "undefined") {
return null; // Return null during SSR
}
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) {
return parts.pop()?.split(";").shift() || null;
}
return null;
}