-
Notifications
You must be signed in to change notification settings - Fork 585
/
Copy pathfour-stats-widget.tsx
53 lines (50 loc) · 1.49 KB
/
four-stats-widget.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import {LOADING_DASH} from '@/constants'
import type {FourStatsItem, FourStatsWidget, FourStatsWidgetProps} from '@/modules/widgets/shared/constants'
import {cn} from '@/shadcn-lib/utils'
import {WidgetContainer, widgetTextCva} from './shared/shared'
export function FourStatsWidget({
items,
link,
onClick,
}: FourStatsWidgetProps & {
onClick?: (link?: string) => void
}) {
return (
<WidgetContainer
onClick={() => onClick?.(link)}
className='grid grid-cols-2 grid-rows-2 gap-0 gap-1 p-1.5 md:gap-2 md:p-2.5'
>
{items
?.slice(0, 4)
?.map((item) => <Item key={item.title} title={item.title} text={item.text} subtext={item.subtext} />)}
{!items && (
<>
<Item title={LOADING_DASH} text={LOADING_DASH} subtext={LOADING_DASH} />
<Item title={LOADING_DASH} text={LOADING_DASH} subtext={LOADING_DASH} />
<Item title={LOADING_DASH} text={LOADING_DASH} subtext={LOADING_DASH} />
<Item title={LOADING_DASH} text={LOADING_DASH} subtext={LOADING_DASH} />
</>
)}
</WidgetContainer>
)
}
function Item(item?: FourStatsItem) {
return (
<div className='flex h-full flex-col justify-center rounded-5 bg-white/5 px-1 leading-none md:rounded-12 md:px-5'>
<p
className={cn(
widgetTextCva({
opacity: 'secondary',
}),
'text-[8px] md:text-11',
)}
title={item?.text}
>
{item?.title}
</p>
<p className={widgetTextCva()}>
{item?.text} <span className={widgetTextCva({opacity: 'tertiary'})}>{item?.subtext}</span>
</p>
</div>
)
}