Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update statistics design #468

Merged
merged 1 commit into from
Aug 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 33 additions & 21 deletions packages/frontend/src/view/pages/home/components/HomeStatistics.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import classNames from 'classnames'
import React from 'react'

import { formatInt } from '../../../../utils/formatting/formatAmount'
import { Card } from '../../../components/Card'
import { SectionHeading } from '../../../components/SectionHeading'

Expand All @@ -28,37 +27,37 @@ export function HomeStatistics({
<SectionHeading title="Statistics" />
<Card
className={classNames(
'grid h-full grid-cols-1 divide-y-2 divide-slate-800 !px-0',
showL2Transactions
? 'md:grid-cols-2'
: 'md:grid-cols-3 md:divide-x-2 md:divide-y-0'
'grid h-full grid-cols-1 divide-y-2 divide-slate-800 md:grid-cols-3 md:divide-x-2 md:divide-y-0'
)}
>
<StatisticsItem
title="State updates"
value={statistics.stateUpdateCount}
className="pb-6 md:pb-0"
/>
{showL2Transactions && (
<>
<StatisticsItem
title="Live transactions"
className="pt-5 md:!border-t-0 md:pt-0"
value={statistics.l2TransactionCount}
/>
</>
<StatisticsItem
title="Transactions"
className="py-6 md:!border-t-0 md:py-0"
value={statistics.l2TransactionCount}
/>
)}
<StatisticsItem
title="Forced transactions"
className={classNames(
showL2Transactions ? 'pt-5' : 'pt-5 md:!border-t-0 md:pt-0'
'md:!border-t-0',
showL2Transactions && 'pt-6 md:pt-0',
!showL2Transactions && 'py-6 md:py-0'
)}
value={statistics.forcedTransactionCount}
/>
<StatisticsItem
title="Offers"
className={classNames(showL2Transactions ? 'pt-5' : 'pt-5 md:pt-0')}
value={statistics.offerCount}
/>
{!showL2Transactions && (
<StatisticsItem
title="Offers"
className="pt-6 md:pt-0"
value={statistics.offerCount}
/>
)}
</Card>
</div>
)
Expand All @@ -76,12 +75,25 @@ function StatisticsItem({
return (
<div
className={classNames(
'flex flex-col justify-center text-center',
'flex flex-col items-center justify-between gap-4 text-center leading-none',
className
)}
>
<div className="text-gray-400 text-lg font-medium">{title}</div>
<div className="text-bold text-[50px] text-brand">{formatInt(value)}</div>
<span className="text-[20px] font-semibold">{title}</span>
<span className="text-[50px] font-extrabold text-brand">
{formatStatisticsCount(value)}
</span>
<span className="hidden text-sm font-semibold text-zinc-500 md:inline">
# of all current {title.toLowerCase()}
</span>
</div>
)
}

function formatStatisticsCount(count: number) {
torztomasz marked this conversation as resolved.
Show resolved Hide resolved
if (count < 1000000) {
return count.toString()
}

return `${(count / 1000000).toFixed(2).replace('.', ',')}M`
}