@@ -3,13 +3,7 @@ import { useState } from 'react';
33
44import { cn } from '@/utils/lib' ;
55
6- const HISTORY = 30 ;
7-
8- const getColor = ( fps : number ) => {
9- if ( fps >= 50 ) return 'text-green-500' ;
10- if ( fps >= 30 ) return 'text-amber-500' ;
11- return 'text-destructive' ;
12- } ;
6+ const HISTORY = 40 ;
137
148const getBarColor = ( fps : number ) => {
159 if ( fps >= 50 ) return 'bg-green-500' ;
@@ -30,74 +24,46 @@ const Demo = () => {
3024 const peak = history . length ? Math . max ( ...history ) : 0 ;
3125
3226 return (
33- < section className = 'flex w-full max-w-xs flex-col p-4' >
34- < div className = 'border-border bg-card flex flex-col gap-3 rounded-xl border p-3 shadow-sm' >
35- < div className = 'flex items-end justify-between gap-3' >
36- < div className = 'flex flex-col leading-none' >
37- < span className = 'text-muted-foreground text-[9px] tracking-[0.2em] uppercase' >
38- Frames per second
39- </ span >
40- < div className = 'flex items-baseline gap-1.5' >
41- < span
42- className = { cn (
43- 'font-mono text-2xl font-bold tabular-nums transition-colors' ,
44- getColor ( fps )
45- ) }
46- >
47- { String ( fps ) . padStart ( 2 , '0' ) }
48- </ span >
49- < span className = 'text-muted-foreground text-[10px]' > FPS</ span >
50- </ div >
51- </ div >
52-
53- < div className = 'flex items-center gap-1.5' >
54- < span className = { cn ( 'size-1.5 animate-pulse rounded-full' , getBarColor ( fps ) ) } />
55- < span className = 'text-muted-foreground font-mono text-[9px] tracking-wider uppercase' >
56- Live
57- </ span >
58- </ div >
59- </ div >
27+ < section className = 'flex w-full max-w-sm flex-col gap-3 p-4' >
28+ < div className = 'flex items-center justify-between' >
29+ < span className = 'text-foreground text-sm font-semibold' > Frames per second</ span >
30+ < span className = 'text-muted-foreground font-mono text-xs tabular-nums' >
31+ { String ( fps ) . padStart ( 2 , '0' ) } FPS
32+ </ span >
33+ </ div >
6034
61- < div className = 'flex h-10 items-end gap-[2px]' >
62- { Array . from ( { length : HISTORY } ) . map ( ( _ , index ) => {
63- const value = history [ history . length - HISTORY + index ] ?? 0 ;
64- const height = Math . max ( ( value / max ) * 100 , 4 ) ;
35+ < div className = 'bg-background flex h-28 items-end gap-[2px] rounded-lg border p-3' >
36+ { Array . from ( { length : HISTORY } ) . map ( ( _ , index ) => {
37+ const value = history [ history . length - HISTORY + index ] ?? 0 ;
38+ const height = Math . max ( ( value / max ) * 100 , 4 ) ;
39+ return (
40+ < div
41+ key = { index }
42+ className = { cn ( 'flex-1 rounded-sm' , value ? getBarColor ( value ) : 'bg-muted' ) }
43+ style = { { height : `${ height } %` , opacity : value ? 1 : 0.4 } }
44+ />
45+ ) ;
46+ } ) }
47+ </ div >
6548
66- return (
67- < div
68- key = { index }
69- className = { cn ( 'flex-1 rounded-sm' , value ? getBarColor ( value ) : 'bg-muted' ) }
70- style = { { height : `${ height } %` , opacity : value ? 1 : 0.4 } }
71- />
72- ) ;
73- } ) }
49+ < div className = 'grid grid-cols-3 gap-3' >
50+ < div className = 'flex flex-col gap-0.5' >
51+ < span className = 'text-muted-foreground text-[10px] tracking-wider uppercase' > Min</ span >
52+ < span className = 'text-foreground font-mono text-sm font-semibold tabular-nums' >
53+ { min || '—' }
54+ </ span >
7455 </ div >
75-
76- < div className = 'border-border grid grid-cols-3 gap-2 border-t pt-2' >
77- < div className = 'flex flex-col items-center leading-tight' >
78- < span className = 'text-muted-foreground text-[8px] tracking-[0.15em] uppercase' >
79- Min
80- </ span >
81- < span className = 'text-foreground font-mono text-xs font-semibold tabular-nums' >
82- { min || '—' }
83- </ span >
84- </ div >
85- < div className = 'flex flex-col items-center leading-tight' >
86- < span className = 'text-muted-foreground text-[8px] tracking-[0.15em] uppercase' >
87- Avg
88- </ span >
89- < span className = 'text-foreground font-mono text-xs font-semibold tabular-nums' >
90- { avg || '—' }
91- </ span >
92- </ div >
93- < div className = 'flex flex-col items-center leading-tight' >
94- < span className = 'text-muted-foreground text-[8px] tracking-[0.15em] uppercase' >
95- Peak
96- </ span >
97- < span className = 'text-foreground font-mono text-xs font-semibold tabular-nums' >
98- { peak || '—' }
99- </ span >
100- </ div >
56+ < div className = 'flex flex-col gap-0.5' >
57+ < span className = 'text-muted-foreground text-[10px] tracking-wider uppercase' > Avg</ span >
58+ < span className = 'text-foreground font-mono text-sm font-semibold tabular-nums' >
59+ { avg || '—' }
60+ </ span >
61+ </ div >
62+ < div className = 'flex flex-col gap-0.5' >
63+ < span className = 'text-muted-foreground text-[10px] tracking-wider uppercase' > Peak</ span >
64+ < span className = 'text-foreground font-mono text-sm font-semibold tabular-nums' >
65+ { peak || '—' }
66+ </ span >
10167 </ div >
10268 </ div >
10369 </ section >
0 commit comments