Skip to content

Commit fcf472b

Browse files
authored
feat: replace plain-text loading states with a Spinner component (#393)
* feat: add Spinner component for loading states Add a centered spinning-circle component to replace the plain "Loading…" text currently shown across the top, detail, and search results pages. * feat: use Spinner for detail page loading state Replace the plain-text "Loading…" paragraph with the Spinner component. * feat: use Spinner for top page loading state Replace the plain-text "Loading…" div with the Spinner component. * feat: render Spinner standalone for search results loading state Previously the loading state rendered the full SearchResultsPage shell with rangeText="Loading…", which could misleadingly show the "no sites found" empty state while a request was in flight. Render the Spinner standalone alongside the search header instead.
1 parent 0d528ba commit fcf472b

4 files changed

Lines changed: 22 additions & 3 deletions

File tree

client/src/app/features/search/containers/search-heritage-result-container.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { toWorldHeritageListVm } from "@features/heritages/mappers/to-world-heri
1919
import { HeritageSubHeader } from "@features/top/components/HeritageSubHeader";
2020
import { DEFAULT_HERITAGE_SEARCH_PARAMS as SEARCH_PARAMS } from "../mapper/search-heritage.types";
2121
import { useLocale } from "@shared/locale/LocaleHooks";
22+
import { Spinner } from "@shared/uis/Spinner.tsx";
2223

2324
const fmtRangeText = (pagination: Pagination, count: number): string => {
2425
if (count === 0) {
@@ -201,7 +202,12 @@ export function SearchHeritageResultsContainer(): React.ReactElement {
201202
};
202203

203204
if (isLoading) {
204-
return <SearchResultsPage {...baseProps} pagination={null} rangeText="Loading…" />;
205+
return (
206+
<main className="mx-auto max-w-7xl px-4 py-12">
207+
{header}
208+
<Spinner />
209+
</main>
210+
);
205211
}
206212

207213
if (error) {

client/src/app/features/top/containers/top-page-container.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { TopPagePagination } from "../components/TopPagePagination";
1010
import type { IdSortOption } from "../../../../domain/types";
1111
import { parseHeritageSearchParams } from "@features/search/mapper/search-heritages.params";
1212
import { DEFAULT_HERITAGE_SEARCH_PARAMS as SEARCH_PARAMS } from "@features/search/mapper/search-heritage.types";
13+
import { Spinner } from "@shared/uis/Spinner.tsx";
1314

1415
const DEFAULT_TOP_PER_PAGE = 30;
1516
const DEFAULT_ORDER: IdSortOption = "asc";
@@ -94,7 +95,7 @@ export default function TopPageContainer(): React.ReactElement {
9495
<>
9596
{header}
9697
<main className="p-6">
97-
<div>Loading…</div>
98+
<Spinner />
9899
</main>
99100
</>
100101
);

client/src/app/features/top/containers/world-heritage-detail-container.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useParams, useNavigate } from "react-router-dom";
33
import { useWorldHeritageDetail } from "../hooks/use-world-heritage-detail";
44
import { HeritageDetailLayout } from "../components/heritage-detail/HeritageDetailLayout";
55
import BreadcrumbContext from "@features/breadcrumbs/BreadCrumbProvider";
6+
import { Spinner } from "@shared/uis/Spinner.tsx";
67

78
export function WorldHeritageDetailContainer() {
89
const { id } = useParams<{ id: string }>();
@@ -23,7 +24,7 @@ export function WorldHeritageDetailContainer() {
2324
setLabel("/heritages/:id", label);
2425
}, [setLabel, isLoading, isError, item?.name]);
2526

26-
if (isLoading) return <p>Loading…</p>;
27+
if (isLoading) return <Spinner />;
2728

2829
if (isError) {
2930
return (

client/src/shared/uis/Spinner.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export function Spinner({ className = "" }: { className?: string }) {
2+
return (
3+
<div
4+
role="status"
5+
aria-label="Loading"
6+
className={`flex items-center justify-center p-12 ${className}`}
7+
>
8+
<div className="h-8 w-8 animate-spin rounded-full border-4 border-zinc-200 border-t-indigo-600" />
9+
</div>
10+
);
11+
}

0 commit comments

Comments
 (0)