From 09b2f1220ddbae114e0f54c8bc6864fee82fbe2f Mon Sep 17 00:00:00 2001 From: Jalil Arfaoui Date: Tue, 7 Feb 2023 02:40:01 +0100 Subject: [PATCH] feat: add thumbs grid --- src/main.tsx | 2 ++ src/routes/Liste/index.tsx | 30 +++++++++++++++++++++++------- src/routes/ResistantRow.tsx | 2 +- src/routes/ResistantThumb.tsx | 19 +++++++++++++++++++ src/style/row.css | 8 ++++++++ src/style/thumbs.css | 20 ++++++++++++++++++++ 6 files changed, 73 insertions(+), 8 deletions(-) create mode 100644 src/routes/ResistantThumb.tsx create mode 100644 src/style/row.css create mode 100644 src/style/thumbs.css diff --git a/src/main.tsx b/src/main.tsx index 4f2be2a..e9fd895 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -10,6 +10,8 @@ import './style/SquareSpace/global.css' import './style/SquareSpace/blocks.css' import './style/SquareSpace/table.css' import './style/SquareSpace/video.css' +import './style/thumbs.css' +import './style/row.css' import './photos' const Layout = () =>
diff --git a/src/routes/Liste/index.tsx b/src/routes/Liste/index.tsx index 61696b3..437489d 100644 --- a/src/routes/Liste/index.tsx +++ b/src/routes/Liste/index.tsx @@ -2,11 +2,12 @@ import React from "react"; import {Outlet, useLoaderData} from "react-router"; import {ResistantRow} from "../ResistantRow"; import {Resistant} from "../../Resistant"; -import {Group, TextInput} from "@mantine/core"; +import {Center, Grid, Group, SegmentedControl, TextInput} from "@mantine/core"; import {FiltreDepartement} from "./FiltreDepartement"; -import {IconUsers} from "@tabler/icons-react"; +import {IconCameraSelfie, IconList, IconMap, IconPhoto, IconUsers} from "@tabler/icons-react"; import {Separator} from "../../components/Separator"; import {FiltreAcademie} from "./FiltreAcademie"; +import {ResistantThumb} from "../ResistantThumb"; export const resistantsLoader = async () => { const spreadsheetId = '1GL1MBChnwNn0t8WtKK5M3PbtCJ_bTJRhoTwAI9jeWck' @@ -21,18 +22,30 @@ const normalize = (text: string) => (text || "") .normalize("NFD") .replace(/\p{Diacritic}/gu, "") +type ViewMode = "list" | "photos" | "map"; export const ListeResistants = () => { const { resistants } = useLoaderData() as { resistants: Resistant[] } const [departement, setDepartement] = React.useState(null) const [academie, setAcademie] = React.useState(null) const [nom, setNom] = React.useState(undefined) + const [viewMode, setViewMode ] = React.useState("photos") const filtreNom = (event: React.ChangeEvent) => setNom(event.target.value) + const filteredResistants = resistants + .filter(r => !nom || normalize(r.noms).includes(normalize(nom.toLowerCase()))) + .filter(r => !departement || normalize(r.departement).includes(normalize(departement))) + .filter(r => !academie || normalize(r.academie).includes(normalize(academie))) + return ( <>
+ Liste}, + { value: "photos", label:
Photos
}, + { value: "map", label:
Carte
}, + ]} size="xs" defaultValue="photos" onChange={(value) => setViewMode(value as ViewMode )} /> } placeholder="Nom" onChange={filtreNom}/> @@ -40,11 +53,14 @@ export const ListeResistants = () => { - {resistants - .filter(r => !nom || normalize(r.noms).includes(normalize(nom.toLowerCase()))) - .filter(r => !departement || normalize(r.departement).includes(normalize(departement))) - .filter(r => !academie || normalize(r.academie).includes(normalize(academie))) - .map((r) => )} + {viewMode === "list" && filteredResistants.map((r) => )} + {viewMode === "photos" && + {filteredResistants.map((r) => + + )} + } + +
diff --git a/src/routes/ResistantRow.tsx b/src/routes/ResistantRow.tsx index 11d705e..f34f331 100644 --- a/src/routes/ResistantRow.tsx +++ b/src/routes/ResistantRow.tsx @@ -11,7 +11,7 @@ export const ResistantRow = ({resistant}: Props) => { return ( <> -
navigate(resistant.noms)}> +
navigate(resistant.noms)}>
{ + const navigate = useNavigate() + + return +
navigate(resistant.noms)} style={{width: "200px", height: "200px", position: "relative"}}> +
{resistant.noms}
+
+
+ +} diff --git a/src/style/row.css b/src/style/row.css new file mode 100644 index 0000000..084d8c0 --- /dev/null +++ b/src/style/row.css @@ -0,0 +1,8 @@ +.resistant-row { + height: 250px; +} + +.resistant-row:hover { + background-color: #8f96a3; + cursor: pointer; +} diff --git a/src/style/thumbs.css b/src/style/thumbs.css new file mode 100644 index 0000000..4b4c536 --- /dev/null +++ b/src/style/thumbs.css @@ -0,0 +1,20 @@ +.thumb { + cursor: pointer; +} + +.thumb .thumb-name { + display: none; + position: absolute; + bottom: 0px; + background-color: white; + width: 100%; +} + +.thumb:hover { + border: black solid 2px; + box-sizing: border-box; +} + +.thumb:hover .thumb-name { + display: block; +}