Skip to content

Commit 2e14081

Browse files
committed
feat: redesign the home page
1 parent 2afdc1b commit 2e14081

17 files changed

+137
-156
lines changed

block-explorer/app/page.tsx

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
1-
import {
2-
RiArrowRightUpLine,
3-
RiTimerLine,
4-
RiPencilLine,
5-
RiArrowLeftRightLine,
6-
RiWalletLine
7-
} from '@remixicon/react'
8-
91
import { LatestBlocks } from '@/components/homepage/latest-blocks';
102
import { LatestExtrinsics } from '@/components/homepage/latest-extrinsics';
113
import { LatestTransactions } from '@/components/homepage/latest-transactions';
124
import { Search } from '@/components/homepage/search.tsx';
135
import TargetTimeCountdown from '@/components/target-time-countdown';
146
import { ApiCommand, request } from '@/lib/api';
157
import { formatNumber, handleRequestResult } from '@/lib/utils';
8+
import { RiArrowLeftRightLine, RiArrowRightUpLine, RiPencilLine, RiTimerLine, RiWalletLine } from '@remixicon/react';
169

1710
export const dynamic = 'force-dynamic';
1811

@@ -52,7 +45,7 @@ export default async function IndexPage() {
5245
value: Number(chainSummary?.addresses || 0),
5346
icon: RiWalletLine,
5447
},
55-
]
48+
];
5649

5750
return (
5851
<div style={{ background: `url('/home-page-background.png') top / 100% no-repeat` }}>
@@ -68,19 +61,21 @@ export default async function IndexPage() {
6861
className="link-box rounded-[16px] p-px"
6962
style={{ background: 'linear-gradient(90deg, #8F9AE9 0%, #E0BC95 50%, #F78F50 100%)' }}
7063
>
71-
<div
72-
className="flex flex-col gap-1 rounded-[15px] bg-white p-6 pt-5 hover:bg-api-portal-banner dark:bg-black xl:max-w-[330px]"
73-
>
64+
<div className="flex flex-col gap-1 rounded-[15px] bg-white p-6 pt-5 hover:bg-api-portal-banner dark:bg-black xl:max-w-[330px]">
7465
<div className="flex items-center justify-between">
7566
<a
7667
href="https://build.rootscan.io/"
7768
target="_blank"
7869
className="link-overlay text-[18px]/[28px] font-semibold"
79-
>API Portal</a>
70+
>
71+
API Portal
72+
</a>
8073
<RiArrowRightUpLine className="size-6" />
8174
</div>
8275
<p className="text-xs font-normal text-foreground/60">
83-
Kickstart your development on The Root Network with Rootscan’s <strong className="text-foreground">API</strong> and <strong className="text-foreground">RPC</strong> services
76+
Kickstart your development on The Root Network with Rootscan’s{' '}
77+
<strong className="text-foreground">API</strong> and <strong className="text-foreground">RPC</strong>{' '}
78+
services
8479
</p>
8580
</div>
8681
</div>

block-explorer/components/address-display.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1+
import { getAddressName, knownAddressNames } from '@/lib/constants/knownAddresses';
2+
import { cn } from '@/lib/utils';
13
import { RiFileList3Line } from '@remixicon/react';
24
import Link from 'next/link';
35
import { Address, getAddress, isAddress } from 'viem';
46

5-
import { getAddressName, knownAddressNames } from '@/lib/constants/knownAddresses';
6-
import { cn } from '@/lib/utils';
7-
87
import { CopyButton } from './copy-button';
98
import Logo from './logo';
109
import Tooltip from './tooltip';

block-explorer/components/container.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,5 @@ export default function Container({ children, className }: { children: React.Rea
1111
}
1212

1313
export function ContainerV2({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
14-
return (
15-
<div className={cn('container px-4 md:px-6 xl:px-14 lg:px-8', className)} {...props} />
16-
);
14+
return <div className={cn('container px-4 md:px-6 xl:px-14 lg:px-8', className)} {...props} />;
1715
}

block-explorer/components/copy-button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use client';
22

3-
import { RiFileCopyLine, RiCheckLine } from '@remixicon/react'
43
import * as React from 'react';
54

65
import { cn } from '@/lib/utils';
6+
import { RiCheckLine, RiFileCopyLine } from '@remixicon/react';
77

88
const copyToClipboardWithMeta = async (value: string) => {
99
navigator.clipboard.writeText(value);
Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
'use client'
1+
'use client';
22

3-
import { RiArrowDownSLine } from '@remixicon/react'
43
import { ReactNode, useState } from 'react';
54

6-
import { CardContent } from '@/components/ui/v2/card.tsx';
75
import { Button } from '@/components/ui/button.tsx';
6+
import { CardContent } from '@/components/ui/v2/card.tsx';
87
import { cn } from '@/lib/utils.ts';
8+
import { RiArrowDownSLine } from '@remixicon/react';
99

1010
type DataItemCardProps = {
1111
iconSrc: string;
1212
children: ReactNode;
13-
summary: Array<[string, string | number | ReactNode]>
14-
}
13+
summary: Array<[string, string | number | ReactNode]>;
14+
};
1515
export const DataItemCard = (props: DataItemCardProps) => {
16-
const { iconSrc, summary, children } = props
16+
const { iconSrc, summary, children } = props;
1717

18-
const [openSummary, setOpenSummary] = useState(false)
18+
const [openSummary, setOpenSummary] = useState(false);
1919

2020
return (
2121
<CardContent className="relative flex flex-col gap-3 pl-6 lg:flex-row lg:items-center lg:gap-6">
@@ -31,9 +31,7 @@ export const DataItemCard = (props: DataItemCardProps) => {
3131
<div className="shrink-0 rounded-[12px] bg-[#F5F5F5] p-3 dark:bg-[#1C1C1C]">
3232
<img src={iconSrc} alt="" className="size-10" />
3333
</div>
34-
<div className="flex flex-col">
35-
{children}
36-
</div>
34+
<div className="flex flex-col">{children}</div>
3735
</div>
3836
<div
3937
className={cn(
@@ -44,10 +42,14 @@ export const DataItemCard = (props: DataItemCardProps) => {
4442
{summary.map(([label, value], i) => (
4543
<div key={i} className="flex items-center justify-between gap-4">
4644
<p className="text-xs text-[#737373]">{label}</p>
47-
{typeof value === 'string' || typeof value === 'number' ? <p className="text-xs font-semibold">{value}</p> : value}
45+
{typeof value === 'string' || typeof value === 'number' ? (
46+
<p className="text-xs font-semibold">{value}</p>
47+
) : (
48+
value
49+
)}
4850
</div>
4951
))}
5052
</div>
5153
</CardContent>
52-
)
53-
}
54+
);
55+
};
Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
'use client';
22

3-
import Link from 'next/link';
43
import { ReactNode } from 'react';
54

65
import { DataItemCard } from '@/components/homepage/data-item-card.tsx';
76
import { Button } from '@/components/ui/button.tsx';
87
import { Card, CardHeader, CardTitle } from '@/components/ui/v2/card.tsx';
98
import { IBlock } from '@/types/models';
9+
import Link from 'next/link';
1010

1111
import AddressDisplay from '../address-display';
1212
import TimeAgoDate from '../time-ago-date';
1313

1414
type LatestBlocksProps = {
15-
latestBlocks: IBlock[]
16-
}
15+
latestBlocks: IBlock[];
16+
};
1717
export const LatestBlocks = (props: LatestBlocksProps) => {
1818
const { latestBlocks } = props;
1919

@@ -31,29 +31,28 @@ export const LatestBlocks = (props: LatestBlocksProps) => {
3131
['Events', block.eventsCount],
3232
['EVM Txs', block.transactionsCount],
3333
['Extrinsics', block.extrinsicsCount],
34-
]
34+
];
3535

3636
return (
3737
<DataItemCard key={block.number} iconSrc="/cube.png" summary={summary}>
38-
<Link
39-
href={`/blocks/${block.number}`}
40-
className="text-[18px]/[28px] font-semibold"
41-
>
38+
<Link href={`/blocks/${block.number}`} className="text-[18px]/[28px] font-semibold">
4239
{block.number}
4340
</Link>
4441
<div className="flex gap-1">
4542
<span className="text-sm text-muted-foreground">Validator</span>
4643
<AddressDisplay address={block.evmBlock.miner} useShortenedAddress />
4744
</div>
4845
{block?.isFinalized ? (
49-
<span className="text-xs text-foreground/40"><TimeAgoDate date={block.timestamp} /></span>
46+
<span className="text-xs text-foreground/40">
47+
<TimeAgoDate date={block.timestamp} />
48+
</span>
5049
) : (
5150
<span className="text-xs text-[#FB923C]">Unfinalized</span>
5251
)}
5352
</DataItemCard>
54-
)
53+
);
5554
})}
5655
</div>
5756
</Card>
5857
);
59-
}
58+
};
Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
'use client';
22

3-
import Link from 'next/link';
43
import { ReactNode } from 'react';
54

65
import { DataItemCard } from '@/components/homepage/data-item-card.tsx';
76
import { Button } from '@/components/ui/button.tsx';
87
import { Card, CardHeader, CardTitle } from '@/components/ui/v2/card';
98
import { IExtrinsic } from '@/types/models';
9+
import Link from 'next/link';
1010

1111
import AddressDisplay from '../address-display';
1212
import TimeAgoDate from '../time-ago-date';
1313

1414
type LatestExtrinsicsProps = {
15-
latestExtrinsics: IExtrinsic[]
16-
}
15+
latestExtrinsics: IExtrinsic[];
16+
};
1717
export const LatestExtrinsics = (props: LatestExtrinsicsProps) => {
1818
const { latestExtrinsics } = props;
1919

@@ -30,25 +30,23 @@ export const LatestExtrinsics = (props: LatestExtrinsicsProps) => {
3030
const summary: Array<[string, string | number | ReactNode]> = [
3131
['Pallet', extrinsic?.section],
3232
['Method', extrinsic?.method],
33-
['Signer', <AddressDisplay address={extrinsic?.signer} useShortenedAddress className="text-xs font-semibold" />],
34-
]
33+
[
34+
'Signer',
35+
<AddressDisplay address={extrinsic?.signer} useShortenedAddress className="text-xs font-semibold" />,
36+
],
37+
];
3538
return (
36-
<DataItemCard
37-
key={extrinsic?.extrinsicId}
38-
iconSrc="/layers.png"
39-
summary={summary}
40-
>
41-
<Link
42-
href={`/extrinsics/${extrinsic?.extrinsicId}`}
43-
className="text-[18px]/[28px] font-semibold"
44-
>
39+
<DataItemCard key={extrinsic?.extrinsicId} iconSrc="/layers.png" summary={summary}>
40+
<Link href={`/extrinsics/${extrinsic?.extrinsicId}`} className="text-[18px]/[28px] font-semibold">
4541
{extrinsic?.extrinsicId}
4642
</Link>
47-
<span className="text-xs text-foreground/40"><TimeAgoDate date={extrinsic?.timestamp * 1000} /></span>
43+
<span className="text-xs text-foreground/40">
44+
<TimeAgoDate date={extrinsic?.timestamp * 1000} />
45+
</span>
4846
</DataItemCard>
49-
)
47+
);
5048
})}
5149
</div>
5250
</Card>
5351
);
54-
}
52+
};

block-explorer/components/homepage/latest-transactions.tsx

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
'use client';
22

3-
import { generateAvatarURL } from '@cfx-kit/wallet-avatar';
4-
import { RiArrowRightSLine } from '@remixicon/react'
5-
import Image from 'next/image';
6-
import Link from 'next/link';
7-
import { getAddress } from 'viem';
8-
93
import { Badge } from '@/components/ui/badge';
104
import { Button } from '@/components/ui/button.tsx';
115
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/v2/card';
126
import { IEVMTransaction } from '@/types/models';
7+
import { generateAvatarURL } from '@cfx-kit/wallet-avatar';
8+
import { RiArrowRightSLine } from '@remixicon/react';
9+
import Image from 'next/image';
10+
import Link from 'next/link';
11+
import { getAddress } from 'viem';
1312

1413
import AddressDisplay from '../address-display';
1514
import TimeAgoDate from '../time-ago-date';
1615

1716
type LatestTransactionsProps = {
18-
latestTransactions: IEVMTransaction[]
19-
}
17+
latestTransactions: IEVMTransaction[];
18+
};
2019
export const LatestTransactions = (props: LatestTransactionsProps) => {
2120
const { latestTransactions } = props;
2221

@@ -35,23 +34,25 @@ export const LatestTransactions = (props: LatestTransactionsProps) => {
3534
</div>
3635
</Card>
3736
);
38-
}
37+
};
3938

4039
type TransactionCardProps = {
4140
transaction: IEVMTransaction;
42-
}
41+
};
4342
export const TransactionCard = (props: TransactionCardProps) => {
4443
const { transaction } = props;
4544

4645
const renderBadges = () => (
4746
<div className="flex flex-wrap items-center gap-2">
4847
{transaction?.toLookup?.isContract ? <Badge variant="info">Contract Call</Badge> : null}
4948
{transaction?.tags?.map((tag, _) => (
50-
<Badge variant="info" key={_}>{tag}</Badge>
49+
<Badge variant="info" key={_}>
50+
{tag}
51+
</Badge>
5152
))}
5253
{transaction.status === 'success' ? <Badge variant="success">Confirmed</Badge> : null}
5354
</div>
54-
)
55+
);
5556

5657
const renderDirection = () => (
5758
<div className="flex flex-wrap items-center gap-1.5 md:justify-start">
@@ -92,7 +93,7 @@ export const TransactionCard = (props: TransactionCardProps) => {
9293
useShortenedAddress
9394
/>
9495
</div>
95-
)
96+
);
9697

9798
return (
9899
<CardContent className="flex flex-col gap-3 p-4 md:gap-4 md:p-6">
@@ -125,5 +126,5 @@ export const TransactionCard = (props: TransactionCardProps) => {
125126

126127
<div className="md:hidden">{renderDirection()}</div>
127128
</CardContent>
128-
)
129-
}
129+
);
130+
};

block-explorer/components/homepage/search.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
'use client'
1+
'use client';
22

3-
import { RiSearchLine } from '@remixicon/react';
43
import { ChangeEvent, KeyboardEvent, useState } from 'react';
54

65
import { Button } from '@/components/ui/button.tsx';
76
import { performSearchMainSearch } from '@/lib/helpers.ts';
7+
import { RiSearchLine } from '@remixicon/react';
88

99
export const Search = () => {
1010
const [value, setValue] = useState('');
@@ -13,11 +13,11 @@ export const Search = () => {
1313
if (!value.trim()) return;
1414
await performSearchMainSearch(value);
1515
setValue('');
16-
}
16+
};
1717

1818
const handlePress = async (e: KeyboardEvent) => {
1919
if (e?.key === 'Enter') {
20-
handleSearch()
20+
handleSearch();
2121
}
2222
};
2323

@@ -38,5 +38,5 @@ export const Search = () => {
3838
<RiSearchLine className="size-5" />
3939
</Button>
4040
</div>
41-
)
42-
}
41+
);
42+
};

block-explorer/components/site-footer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { RiArrowRightUpLine, RiGithubFill, RiTwitterXFill, RiDiscordFill } from '@remixicon/react'
1+
import { RiArrowRightUpLine, RiDiscordFill, RiGithubFill, RiTwitterXFill } from '@remixicon/react';
22
import Image from 'next/image';
33
import Link from 'next/link';
44

block-explorer/components/site-header.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { Fragment } from 'react';
22

3+
import { SiteTopBar } from '@/components/site-top-bar.tsx';
34
import Image from 'next/image';
45
import Link from 'next/link';
56

6-
import { SiteTopBar } from '@/components/site-top-bar.tsx';
7-
87
import { Navigation } from './navigation';
98
import TestnetWarning from './testnet-warning';
109
import { Badge } from './ui/badge';

0 commit comments

Comments
 (0)