From 1f6fb932b6fa29dc37b4df28bc2edcd08234efad Mon Sep 17 00:00:00 2001 From: T'JAMPENS QUENTIN p2406187 Date: Tue, 24 Feb 2026 14:47:30 +0100 Subject: [PATCH 1/2] Create Loading component --- src/components/ui/loading/loading.module.css | 25 ++++++++++++++++++++ src/components/ui/loading/loading.tsx | 12 ++++++++++ src/stories/Loading.stories.jsx | 13 ++++++++++ 3 files changed, 50 insertions(+) create mode 100644 src/components/ui/loading/loading.module.css create mode 100644 src/components/ui/loading/loading.tsx create mode 100644 src/stories/Loading.stories.jsx diff --git a/src/components/ui/loading/loading.module.css b/src/components/ui/loading/loading.module.css new file mode 100644 index 0000000..b12ba9f --- /dev/null +++ b/src/components/ui/loading/loading.module.css @@ -0,0 +1,25 @@ +.wrapper { + display: flex; + justify-content: center; + align-items: center; + + width: 100%; + min-height: 200px; +} + +.spinner { + width: 48px; + height: 48px; + + border: 5px solid #e0e0e0; + border-top: 5px solid #3498db; + + border-radius: 50%; + animation: spin 0.8s linear infinite; +} + +@keyframes spin { + to { + transform: rotate(360deg); + } +} \ No newline at end of file diff --git a/src/components/ui/loading/loading.tsx b/src/components/ui/loading/loading.tsx new file mode 100644 index 0000000..536cc99 --- /dev/null +++ b/src/components/ui/loading/loading.tsx @@ -0,0 +1,12 @@ +import React from "react"; +import styles from "./loading.module.css"; + +const Loading: React.FC = () => { + return ( +
+
+
+ ); +}; + +export default Loading; \ No newline at end of file diff --git a/src/stories/Loading.stories.jsx b/src/stories/Loading.stories.jsx new file mode 100644 index 0000000..6986aa8 --- /dev/null +++ b/src/stories/Loading.stories.jsx @@ -0,0 +1,13 @@ +import Loading from "../components/ui/loading/loading.tsx"; + + +export default { + title: 'UI/Loading', + component: Loading, + parameters: { + layout: 'centered', + }, + tags: ['autodocs'], +}; + +export const Primary = {}; \ No newline at end of file From ffa6cd649443966a7dec2d909cdc1165fb5f22c9 Mon Sep 17 00:00:00 2001 From: T'JAMPENS QUENTIN p2406187 Date: Tue, 24 Feb 2026 14:47:36 +0100 Subject: [PATCH 2/2] Use Loading component --- src/pages/Volunteers/VolunteersPage.tsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/pages/Volunteers/VolunteersPage.tsx b/src/pages/Volunteers/VolunteersPage.tsx index 869d6a5..ae43fbc 100644 --- a/src/pages/Volunteers/VolunteersPage.tsx +++ b/src/pages/Volunteers/VolunteersPage.tsx @@ -6,6 +6,7 @@ import ToolBar from "../../components/ToolBar/ToolBar"; import filter from "../../utils/filter"; import getUserById from "../../utils/users/getUserById"; import User from "./interfaces/user.interface"; +import Loading from "../../components/ui/loading/loading"; interface Filters { alphabetical: "asc" | "desc"; @@ -57,6 +58,7 @@ const VolunteerPage: React.FC = () => { fetchUsers(); }, []); + if(loading) return ; return (
@@ -67,13 +69,9 @@ const VolunteerPage: React.FC = () => { />
- {loading ? ( -
Chargement des bénévoles…
- ) : ( - filter(users, filters, "user").map((user: User) => ( + {filter(users, filters, "user").map((user: User) => ( - )) - )} + ))}