Skip to content

Commit a29a73d

Browse files
fix: add skeleton for better loading state (#2063)
1 parent 75a30b9 commit a29a73d

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

apps/namadillo/src/App/Common/TableWithPaginator.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export const TableWithPaginator = <T,>({
6868
);
6969
}, [page, itemList, onPageChange]);
7070

71+
// Show empty state only when no results
7172
if (rows.length === 0) {
7273
return (
7374
<div className="flex items-center justify-center text-sm py-4 text-neutral-200">

apps/namadillo/src/App/Governance/AllProposalsTable.tsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { Stack, StyledSelectBox, TableRow } from "@namada/components";
1+
import {
2+
SkeletonLoading,
3+
Stack,
4+
StyledSelectBox,
5+
TableRow,
6+
} from "@namada/components";
27
import { Pagination } from "@namada/indexer-client";
38
import { Proposal, isProposalStatus, proposalStatuses } from "@namada/types";
49
import { mapUndefined } from "@namada/utils";
@@ -25,9 +30,11 @@ const Table: React.FC<
2530
pagination: Pagination;
2631
page: number;
2732
onPageChange: (page: number) => void;
33+
isLoading?: boolean;
2834
} & ExtensionConnectedProps
2935
> = (props) => {
3036
const navigate = useNavigate();
37+
const proposals = props.proposals;
3138

3239
const headers = [
3340
"ID",
@@ -89,11 +96,23 @@ const Table: React.FC<
8996
],
9097
});
9198

99+
// Show loading skeleton when data is loading and if no rows are rendered
100+
if (props.isLoading && proposals.length === 0) {
101+
return (
102+
<div className="flex flex-col gap-4">
103+
<SkeletonLoading height="450px" width="100%" />
104+
<div className="flex justify-center">
105+
<SkeletonLoading height="40px" width="100px" />
106+
</div>
107+
</div>
108+
);
109+
}
110+
92111
return (
93112
<TableWithPaginator
94113
id="all-proposals-table"
95114
headers={headers}
96-
itemList={props.proposals}
115+
itemList={proposals}
97116
renderRow={renderRow}
98117
tableProps={{
99118
className: clsx(
@@ -252,6 +271,7 @@ export const AllProposalsTable: React.FC<ExtensionConnectedProps> = (props) => {
252271
page={page}
253272
onPageChange={setPage}
254273
pagination={proposals.data?.pagination || {}}
274+
isLoading={proposals.isLoading}
255275
/>
256276
</div>
257277
</Stack>

apps/namadillo/src/App/Governance/GovernanceOverview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export const GovernanceOverview: React.FC = () => {
7070
className="flex-1"
7171
title="All Proposals"
7272
errorText="Unable to load the list of proposals"
73-
atoms={activeAtoms}
73+
atoms={[]}
7474
>
7575
<AllProposalsTable
7676
votedProposalIds={(votedProposals.data || []).map(

0 commit comments

Comments
 (0)