summaryrefslogtreecommitdiff
path: root/frontend/lib/utils.ts
diff options
context:
space:
mode:
authordiogo464 <[email protected]>2025-08-11 16:04:32 +0100
committerdiogo464 <[email protected]>2025-08-11 16:04:32 +0100
commitf4d8a26972728891de8bde4eeb94c80f027ce2d2 (patch)
tree3c8b9c25c2a1e3fab7a86f51922c39eb2ed93697 /frontend/lib/utils.ts
parent32b008a9c0c8e0130ab10bc96ffea9232f9cf95a (diff)
basic v0 ui working
Diffstat (limited to 'frontend/lib/utils.ts')
-rw-r--r--frontend/lib/utils.ts29
1 files changed, 4 insertions, 25 deletions
diff --git a/frontend/lib/utils.ts b/frontend/lib/utils.ts
index 857d8d9..bd0c391 100644
--- a/frontend/lib/utils.ts
+++ b/frontend/lib/utils.ts
@@ -1,27 +1,6 @@
1/** 1import { clsx, type ClassValue } from "clsx"
2 * Formats a size in bytes into a human-readable string 2import { twMerge } from "tailwind-merge"
3 * @param bytes Size in bytes
4 * @returns Formatted size string (e.g., "1.5 KB", "2.3 MB", "1.2 GB")
5 */
6export function formatSize(bytes: number | null): string {
7 if (bytes === null || bytes === 0) {
8 return '-'
9 }
10 3
11 const units = ['B', 'KB', 'MB', 'GB', 'TB'] 4export function cn(...inputs: ClassValue[]) {
12 let size = bytes 5 return twMerge(clsx(inputs))
13 let unitIndex = 0
14
15 while (size >= 1024 && unitIndex < units.length - 1) {
16 size /= 1024
17 unitIndex++
18 }
19
20 // Format with appropriate decimal places
21 if (size < 10 && unitIndex > 0) {
22 return `${size.toFixed(1)} ${units[unitIndex]}`
23 } else {
24 return `${Math.round(size)} ${units[unitIndex]}`
25 }
26} 6}
27