Skip to content

Commit

Permalink
feat: improve performance of home page by suspension of search result…
Browse files Browse the repository at this point in the history
…s table
  • Loading branch information
RyukTheCoder committed Dec 23, 2024
1 parent 914e71c commit 4c3dbd1
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 21 deletions.
32 changes: 15 additions & 17 deletions src/app/(home)/_components/RecentSwaps/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,24 @@ const RecentSwaps = async () => {
const lastSwaps = await getLastSwaps();

return (
<div className="pt-[17.68rem] md:pt-[14.68rem] flex justify-center">
<div className="w-[calc(100%-3.125rem)] md:container mt-30 md:mt-[3.125rem] rounded-normal bg-baseForeground px-15 py-20 md:p-35 overflow-hidden">
<div className="flex flex-col">
<div className="flex justify-between md:mb-25 items-start">
<div className="flex flex-col justify-center items-start">
<h2 className="text-14 md:text-28 font-semibold text-primary-500">
Recent Swaps
</h2>
<p className="text-12 md:text-16 text-neutral-800">
Latest 25 swaps on Rango
</p>
</div>
<div className="flex items-center pt-10">
<Timer />
</div>
<div className="w-[calc(100%-3.125rem)] md:container mt-30 md:mt-[3.125rem] rounded-normal bg-baseForeground px-15 py-20 md:p-35 overflow-hidden">
<div className="flex flex-col">
<div className="flex justify-between md:mb-25 items-start">
<div className="flex flex-col justify-center items-start">
<h2 className="text-14 md:text-28 font-semibold text-primary-500">
Recent Swaps
</h2>
<p className="text-12 md:text-16 text-neutral-800">
Latest 25 swaps on Rango
</p>
</div>
<div>
<Table data={lastSwaps} />
<div className="flex items-center pt-10">
<Timer />
</div>
</div>
<div>
<Table data={lastSwaps} />
</div>
</div>
</div>
);
Expand Down
8 changes: 7 additions & 1 deletion src/app/(home)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { getSummary } from 'src/services';
import Summary from './_components/Summary';
import ChartBox from './_components/ChartBox';
import RecentSwaps from './_components/RecentSwaps';
import TableLoading from 'src/components/common/Table/TableLoading';
import { Suspense } from 'react';

export const metadata: Metadata = {
title: 'Track all transactions on Rango Exchange',
Expand All @@ -25,7 +27,11 @@ export default async function HomePage() {
</div>
</div>
</div>
<RecentSwaps />
<div className="pt-[17.68rem] md:pt-[14.68rem] flex justify-center">
<Suspense fallback={<TableLoading title="Recent Swaps" />}>
<RecentSwaps />
</Suspense>
</div>
</div>
);
}
2 changes: 1 addition & 1 deletion src/app/search/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const Page = async ({

return (
<div className="w-full flex justify-center">
<Suspense fallback={<TableLoading />}>
<Suspense fallback={<TableLoading title="Search Results" />}>
<Result page={Number(page || 0)} query={query as string} />
</Suspense>
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/components/common/Table/Table.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ export interface ColumnType {
tokenType?: TokenType;
component?: React.ComponentType<CellProps>;
}

export interface TableLoadingProps {
title: string;
}
6 changes: 4 additions & 2 deletions src/components/common/Table/TableLoading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ import { useId } from 'react';
import TableHead from './TableHead';
import { Skeleton } from '../Skeleton';
import Link from 'next/link';
import { TableLoadingProps } from './Table.type';

function TableLoading() {
function TableLoading(props: TableLoadingProps) {
const id = useId();
const { title } = props;
return (
<div className="w-[calc(100%-3.125rem)] md:container mt-30 md:mt-[3.125rem] rounded-normal bg-baseForeground px-15 py-20 md:p-35 overflow-hidden">
<div className="flex flex-col">
<div className="flex flex-col justify-center">
<h2 className="text-14 md:text-28 font-semibold text-primary-500">
Search Results
{title}
</h2>
<div className="text-12 md:text-16 text-neutral-800">
<Skeleton width={300} height={10} />
Expand Down

0 comments on commit 4c3dbd1

Please sign in to comment.