Files
users/lib/utils.ts
v0 2408d50cb0 refactor: overhaul UI for streamlined user experience
Redesign navigation, home overview, user portrait, and valuation pages
with improved functionality and responsive design.

Co-authored-by: null <4804959+fnvtk@users.noreply.github.com>
2025-07-18 13:47:12 +00:00

38 lines
934 B
TypeScript

import { type ClassValue, clsx } from "clsx"
import { twMerge } from "tailwind-merge"
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
export function formatNumber(num: number): string {
return new Intl.NumberFormat("zh-CN").format(num)
}
export function formatPercent(num: number): string {
return new Intl.NumberFormat("zh-CN", {
style: "percent",
minimumFractionDigits: 1,
maximumFractionDigits: 1,
}).format(num / 100)
}
export function formatDate(date: Date | string): string {
if (typeof date === "string") {
date = new Date(date)
}
return new Intl.DateTimeFormat("zh-CN", {
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
}).format(date)
}
export function getGrowthClass(value: number): string {
if (value > 0) return "text-green-500"
if (value < 0) return "text-red-500"
return "text-gray-500"
}