mirror of
https://github.com/zoo-apps/network.git
synced 2026-10-30 14:56:38 +00:00
- Full app extraction from zoo monorepo (source only) - Configured for GitHub Pages deployment - Static export enabled - Custom domain: zoo.network - Excludes node_modules and build artifacts
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { type ClassValue, clsx } from "clsx"
|
|
import { twMerge } from "tailwind-merge"
|
|
|
|
export function cn(...inputs: ClassValue[]) {
|
|
return twMerge(clsx(inputs))
|
|
}
|
|
|
|
export function formatAddress(address: string, chars = 6): string {
|
|
if (!address) return ''
|
|
return `${address.slice(0, chars)}...${address.slice(-chars)}`
|
|
}
|
|
|
|
export function formatNumber(num: number): string {
|
|
if (num >= 1e9) return `${(num / 1e9).toFixed(2)}B`
|
|
if (num >= 1e6) return `${(num / 1e6).toFixed(2)}M`
|
|
if (num >= 1e3) return `${(num / 1e3).toFixed(2)}K`
|
|
return num.toString()
|
|
}
|
|
|
|
export function formatHash(hash: string, chars = 10): string {
|
|
if (!hash) return ''
|
|
return `${hash.slice(0, chars)}...${hash.slice(-chars)}`
|
|
}
|
|
|
|
export function timeAgo(timestamp: number): string {
|
|
const seconds = Math.floor((Date.now() - timestamp) / 1000)
|
|
|
|
if (seconds < 60) return `${seconds}s ago`
|
|
const minutes = Math.floor(seconds / 60)
|
|
if (minutes < 60) return `${minutes}m ago`
|
|
const hours = Math.floor(minutes / 60)
|
|
if (hours < 24) return `${hours}h ago`
|
|
const days = Math.floor(hours / 24)
|
|
return `${days}d ago`
|
|
} |