2025-03-25 11:59:55 +00:00

49 lines
1.5 KiB
TypeScript

import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
export function formatDate(date: string | Date): string {
return new Date(date).toLocaleDateString('en-US', {
year: 'numeric',
month: 'long',
day: 'numeric',
});
}
export const IUCN_STATUS_COLORS: Record<string, string> = {
'EX': 'bg-black text-white', // Extinct
'EW': 'bg-gray-800 text-white', // Extinct in the Wild
'CR': 'bg-red-600 text-white', // Critically Endangered
'EN': 'bg-orange-600 text-white', // Endangered
'VU': 'bg-yellow-500 text-black', // Vulnerable
'NT': 'bg-yellow-300 text-black', // Near Threatened
'LC': 'bg-green-500 text-black', // Least Concern
'DD': 'bg-gray-500 text-white', // Data Deficient
'NE': 'bg-gray-300 text-black', // Not Evaluated
};
export const IUCN_STATUS_FULL_NAMES: Record<string, string> = {
'EX': 'Extinct',
'EW': 'Extinct in the Wild',
'CR': 'Critically Endangered',
'EN': 'Endangered',
'VU': 'Vulnerable',
'NT': 'Near Threatened',
'LC': 'Least Concern',
'DD': 'Data Deficient',
'NE': 'Not Evaluated',
};
export const CITES_APPENDIX_COLORS: Record<string, string> = {
'I': 'bg-red-600 text-white', // Appendix I
'II': 'bg-blue-600 text-white', // Appendix II
'III': 'bg-green-600 text-white', // Appendix III
};
export function truncateString(str: string, maxLength: number): string {
if (str.length <= maxLength) return str;
return str.slice(0, maxLength) + '...';
}