From aecc4e727ef5be26837bb7ab039abbf942027e62 Mon Sep 17 00:00:00 2001 From: Helene Lotsberg Date: Mon, 9 Nov 2026 11:30:23 +0100 Subject: [PATCH 01/13] add number of results shown after a search in ExplorePlants --- frontend/src/i18n/locales/en/translation.json | 2 ++ frontend/src/i18n/locales/no/translation.json | 2 ++ frontend/src/pages/explorePlants/ExplorePlants.css | 7 +++++++ frontend/src/pages/explorePlants/ExplorePlants.tsx | 6 ++++++ 4 files changed, 17 insertions(+) diff --git a/frontend/src/i18n/locales/en/translation.json b/frontend/src/i18n/locales/en/translation.json index 288b0935..045d1d11 100644 --- a/frontend/src/i18n/locales/en/translation.json +++ b/frontend/src/i18n/locales/en/translation.json @@ -53,6 +53,8 @@ "careLevel_asc": "Care (easy-hard)", "reset": "Reset", "noResults": "No results found", + "resultsCount_one": "{{count}} result found", + "resultsCount_other": "{{count}} results found", "watering": "Watering needs", "all": "All", "minimum": "Low", diff --git a/frontend/src/i18n/locales/no/translation.json b/frontend/src/i18n/locales/no/translation.json index f7c8da11..0392dee4 100644 --- a/frontend/src/i18n/locales/no/translation.json +++ b/frontend/src/i18n/locales/no/translation.json @@ -53,6 +53,8 @@ "careLevel_asc": "Stell (lett-krevende)", "reset": "Nullstill", "noResults": "Ingen resultater funnet", + "resultsCount_one": "{{count}} treff funnet", + "resultsCount_other": "{{count}} treff funnet", "watering": "Vanningsbehov", "all": "Alle", "minimum": "Sjeldent", diff --git a/frontend/src/pages/explorePlants/ExplorePlants.css b/frontend/src/pages/explorePlants/ExplorePlants.css index 3be91b98..6804ccc8 100644 --- a/frontend/src/pages/explorePlants/ExplorePlants.css +++ b/frontend/src/pages/explorePlants/ExplorePlants.css @@ -132,6 +132,13 @@ font-family: Georgia, serif; } +.explore-results .results-count { + margin: 0 0 1rem; + font-size: 1.25rem; + text-align: left; + color: var(--text-dark); +} + .plant-grid { list-style: none; margin: 0; diff --git a/frontend/src/pages/explorePlants/ExplorePlants.tsx b/frontend/src/pages/explorePlants/ExplorePlants.tsx index b5e2aa0f..ee903203 100644 --- a/frontend/src/pages/explorePlants/ExplorePlants.tsx +++ b/frontend/src/pages/explorePlants/ExplorePlants.tsx @@ -316,6 +316,12 @@ export default function ExplorePlants() { {!loading && !error && plants.length === 0 && (

{t("ExplorePlants.noResults")}

)} + {/* aria-live so screen readers hear the new count when search or filters change */} +

+ {!loading && !error && totalCount > 0 + ? t("ExplorePlants.resultsCount", { count: totalCount }) + : ""} +

{totalCount > 0 && ( - + + updateExploreParams({ page: String(target) }) + } + /> )} diff --git a/frontend/src/tests/ExplorePage.test.tsx b/frontend/src/tests/ExplorePage.test.tsx index a2eadb29..8c74ba75 100644 --- a/frontend/src/tests/ExplorePage.test.tsx +++ b/frontend/src/tests/ExplorePage.test.tsx @@ -282,30 +282,30 @@ describe("ExplorePlants", () => { mockResponse({ offset: 24 }, makePlants(6, 25), 30), ]); const previous = () => - screen.getByRole("button", { name: "ExplorePlants.previous" }); + screen.getByRole("button", { name: "pagination.previous" }); const next = () => - screen.getByRole("button", { name: "ExplorePlants.next" }); + screen.getByRole("button", { name: "pagination.next" }); // 30 plants with 12 per page gives 3 pages expect( - await screen.findByText("ExplorePlants.pageOf 1/3"), + await screen.findByText("pagination.pageOf 1/3"), ).toBeInTheDocument(); expect(previous()).toBeDisabled(); expect(next()).toBeEnabled(); await user.click(next()); expect(await screen.findByText("Testplante 13")).toBeInTheDocument(); - expect(screen.getByText("ExplorePlants.pageOf 2/3")).toBeInTheDocument(); + expect(screen.getByText("pagination.pageOf 2/3")).toBeInTheDocument(); await user.click(next()); expect(await screen.findByText("Testplante 25")).toBeInTheDocument(); expect(cards()).toHaveLength(6); - expect(screen.getByText("ExplorePlants.pageOf 3/3")).toBeInTheDocument(); + expect(screen.getByText("pagination.pageOf 3/3")).toBeInTheDocument(); expect(next()).toBeDisabled(); await user.click(previous()); expect(await screen.findByText("Testplante 13")).toBeInTheDocument(); - expect(screen.getByText("ExplorePlants.pageOf 2/3")).toBeInTheDocument(); + expect(screen.getByText("pagination.pageOf 2/3")).toBeInTheDocument(); }); it("goes back to page 1 when a filter changes", async () => { @@ -318,13 +318,13 @@ describe("ExplorePlants", () => { mockResponse({ offset: 12 }, makePlants(12, 13), 30), filtered, ]); - await screen.findByText("ExplorePlants.pageOf 1/3"); + await screen.findByText("pagination.pageOf 1/3"); await user.click( - screen.getByRole("button", { name: "ExplorePlants.next" }), + screen.getByRole("button", { name: "pagination.next" }), ); expect( - await screen.findByText("ExplorePlants.pageOf 2/3"), + await screen.findByText("pagination.pageOf 2/3"), ).toBeInTheDocument(); await user.selectOptions( @@ -335,7 +335,7 @@ describe("ExplorePlants", () => { // The request has offset 0, not 12, and the page counter starts over expect(await screen.findByText("Høy 1")).toBeInTheDocument(); expect(filtered.result).toHaveBeenCalledTimes(1); - expect(screen.getByText("ExplorePlants.pageOf 1/1")).toBeInTheDocument(); + expect(screen.getByText("pagination.pageOf 1/1")).toBeInTheDocument(); }); it("goes back to page 1 when the search text changes", async () => { @@ -345,17 +345,17 @@ describe("ExplorePlants", () => { mockResponse({ offset: 12 }, makePlants(12, 13), 30), search, ]); - await screen.findByText("ExplorePlants.pageOf 1/3"); + await screen.findByText("pagination.pageOf 1/3"); await user.click( - screen.getByRole("button", { name: "ExplorePlants.next" }), + screen.getByRole("button", { name: "pagination.next" }), ); - await screen.findByText("ExplorePlants.pageOf 2/3"); + await screen.findByText("pagination.pageOf 2/3"); await user.type(screen.getByRole("searchbox"), "rose"); // The page is reset immediately, before the debounced request is sent expect( - await screen.findByText("ExplorePlants.pageOf 1/3"), + await screen.findByText("pagination.pageOf 1/3"), ).toBeInTheDocument(); expect(search.result).not.toHaveBeenCalled(); @@ -398,7 +398,7 @@ describe("ExplorePlants", () => { "high", ); expect(await screen.findByText("Gjenopprettet 13")).toBeInTheDocument(); - expect(screen.getByText("ExplorePlants.pageOf 2/3")).toBeInTheDocument(); + expect(screen.getByText("pagination.pageOf 2/3")).toBeInTheDocument(); expect(restored.result).toHaveBeenCalledTimes(1); expect(screen.getByTestId("location-search")).toHaveTextContent( "?search=rose&watering=minimum&sunlight=part_shade&careLevel=high&sort=name_desc&page=2", @@ -462,7 +462,7 @@ describe("ExplorePlants", () => { screen.getByRole("searchbox", { name: "ExplorePlants.search" }), ).toBeInTheDocument(); expect( - screen.getByRole("navigation", { name: "ExplorePlants.pagination" }), + screen.getByRole("navigation", { name: "pagination.label" }), ).toBeInTheDocument(); expect( screen.getByLabelText("ExplorePlants.watering"), diff --git a/frontend/src/tests/__snapshots__/ExplorePage.test.tsx.snap b/frontend/src/tests/__snapshots__/ExplorePage.test.tsx.snap index 02bce4e1..cc44c838 100644 --- a/frontend/src/tests/__snapshots__/ExplorePage.test.tsx.snap +++ b/frontend/src/tests/__snapshots__/ExplorePage.test.tsx.snap @@ -200,6 +200,10 @@ exports[`ExplorePlants > snapshots > matches the snapshot of the page with no re

ExplorePlants.noResults

+

+ + pagination.pageOf 1/3 + @@ -984,6 +1041,12 @@ exports[`ExplorePlants > snapshots > matches the snapshot of the page with the s
+

+ ExplorePlants.resultsCount undefined/undefined +

    @@ -1067,26 +1130,55 @@ exports[`ExplorePlants > snapshots > matches the snapshot of the page with the s
diff --git a/frontend/src/tests/getPageItems.test.ts b/frontend/src/tests/getPageItems.test.ts new file mode 100644 index 00000000..b5878c12 --- /dev/null +++ b/frontend/src/tests/getPageItems.test.ts @@ -0,0 +1,32 @@ +import { describe, it, expect } from "vitest"; +import { getPageItems } from "../components/pagination/getPageItems"; + +describe("getPageItems", () => { + it("shows every page when there are few pages", () => { + expect(getPageItems(1, 1)).toEqual([1]); + expect(getPageItems(3, 7)).toEqual([1, 2, 3, 4, 5, 6, 7]); + }); + + it("shows the first pages and the last page near the start", () => { + expect(getPageItems(1, 10)).toEqual([1, 2, 3, 4, 5, "ellipsis-end", 10]); + // Page 4 is still near the start, so "…" never hides just one page + expect(getPageItems(4, 10)).toEqual([1, 2, 3, 4, 5, "ellipsis-end", 10]); + }); + + it("shows the first page and the last pages near the end", () => { + expect(getPageItems(10, 10)).toEqual([1, "ellipsis-start", 6, 7, 8, 9, 10]); + expect(getPageItems(7, 10)).toEqual([1, "ellipsis-start", 6, 7, 8, 9, 10]); + }); + + it("shows the current page and its neighbours in the middle", () => { + expect(getPageItems(5, 10)).toEqual([ + 1, "ellipsis-start", 4, 5, 6, "ellipsis-end", 10, + ]); + }); + + it("never shows more than seven items, however many pages there are", () => { + for (const page of [1, 250, 500, 999, 1000]) { + expect(getPageItems(page, 1000)).toHaveLength(7); + } + }); +}); \ No newline at end of file From 487fdb5050ddbcce9da4b1249cc432710e136733 Mon Sep 17 00:00:00 2001 From: Helene Lotsberg Date: Mon, 9 Nov 2026 13:05:09 +0100 Subject: [PATCH 03/13] =?UTF-8?q?make=20the=20=E2=9C=BF=20button=20on=20Ex?= =?UTF-8?q?plore=20Plants=20a=20toggle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add and remove plants from My Matches with the same button. Update component and e2e tests and snapshots, and use English consistently in the changed test files. --- e2e/uiAccessibility.spec.ts | 2 +- e2e/uiMatchAndRemovePlant.spec.ts | 31 +++++-- frontend/src/i18n/locales/en/translation.json | 2 +- frontend/src/i18n/locales/no/translation.json | 2 +- .../src/pages/explorePlants/ExplorePlants.css | 18 ++-- .../src/pages/explorePlants/ExplorePlants.tsx | 17 ++-- frontend/src/tests/ExplorePage.test.tsx | 92 +++++++++++++++---- .../__snapshots__/ExplorePage.test.tsx.snap | 30 +++--- 8 files changed, 133 insertions(+), 61 deletions(-) diff --git a/e2e/uiAccessibility.spec.ts b/e2e/uiAccessibility.spec.ts index 7147b5bf..78165e65 100644 --- a/e2e/uiAccessibility.spec.ts +++ b/e2e/uiAccessibility.spec.ts @@ -101,7 +101,7 @@ test.describe("after interaction", () => { .first() .locator(".add-match-button"); await addButton.click(); - await expect(addButton).toBeDisabled(); + await expect(addButton).toHaveClass(/add-match-button--matched/); await page.goto("#/my-matches"); await expect(page.locator(".plant-card-match")).toHaveCount(1); diff --git a/e2e/uiMatchAndRemovePlant.spec.ts b/e2e/uiMatchAndRemovePlant.spec.ts index 5b7854f4..b70d6435 100644 --- a/e2e/uiMatchAndRemovePlant.spec.ts +++ b/e2e/uiMatchAndRemovePlant.spec.ts @@ -2,7 +2,8 @@ import { test, expect } from "@playwright/test"; import { openSidebar } from "./helpers/navigation"; // User journeys for matching plants: from PlantMatch and from ExplorePlants, -// and that matches show up in MyMatches and can be removed there. +// and that matches show up in MyMatches and can be removed from both MyMatches +// and ExplorePlants. // Each test gets a new browser and therefore a new user with no matches. test("user can like a plant in PlantMatch, find it in MyMatches and remove the match", async ({ @@ -35,7 +36,7 @@ test("user can like a plant in PlantMatch, find it in MyMatches and remove the m ); }); -test("user can add a plant from ExplorePlants and find it in MyMatches", async ({ +test("user can add a plant from ExplorePlants, find it in MyMatches and remove it again from ExplorePlants", async ({ page, }) => { await page.goto("#/explorePlants"); @@ -44,17 +45,29 @@ test("user can add a plant from ExplorePlants and find it in MyMatches", async ( const firstCard = page.locator(".plant-grid > li").first(); await expect(firstCard).toContainText("Aloe Vera"); - const addButton = firstCard.locator(".add-match-button"); - await expect(addButton).toBeEnabled(); - await addButton.click(); + const matchButton = firstCard.locator(".add-match-button"); + const matchCards = page.locator(".plant-card-match"); + await expect(matchButton).not.toHaveClass(/add-match-button--matched/); + await matchButton.click(); - // The button is disabled once the plant is in MyMatches - await expect(addButton).toBeDisabled(); + // The button shows that the plant is in MyMatches, and can still be clicked + await expect(matchButton).toHaveClass(/add-match-button--matched/); + await expect(matchButton).toBeEnabled(); await openSidebar(page); await page.locator('a[href$="/my-matches"]').click(); - - const matchCards = page.locator(".plant-card-match"); await expect(matchCards).toHaveCount(1); await expect(matchCards.first()).toContainText("Aloe Vera"); + + // Clicking the button again on ExplorePlants removes the match + await openSidebar(page); + await page.locator('a[href$="/explorePlants"]').click(); + await expect(firstCard).toContainText("Aloe Vera"); + await expect(matchButton).toHaveClass(/add-match-button--matched/); + await matchButton.click(); + await expect(matchButton).not.toHaveClass(/add-match-button--matched/); + + await openSidebar(page); + await page.locator('a[href$="/my-matches"]').click(); + await expect(matchCards).toHaveCount(0); }); diff --git a/frontend/src/i18n/locales/en/translation.json b/frontend/src/i18n/locales/en/translation.json index b21dce85..1b27ba93 100644 --- a/frontend/src/i18n/locales/en/translation.json +++ b/frontend/src/i18n/locales/en/translation.json @@ -69,7 +69,7 @@ "medium": "Medium", "high": "High", "addMatch": "Add to My Matches", - "alreadyMatched": "Already in My Matches" + "removeMatch": "Remove from My Matches" }, "pagination": { "label": "Page navigation", diff --git a/frontend/src/i18n/locales/no/translation.json b/frontend/src/i18n/locales/no/translation.json index db07f1b2..6696bc25 100644 --- a/frontend/src/i18n/locales/no/translation.json +++ b/frontend/src/i18n/locales/no/translation.json @@ -69,7 +69,7 @@ "medium": "Middels", "high": "Høy", "addMatch": "Legg til i Mine Matches", - "alreadyMatched": "Allerede i Mine Matches" + "removeMatch": "Fjern fra Mine Matches" }, "pagination": { "label": "Sidenavigasjon", diff --git a/frontend/src/pages/explorePlants/ExplorePlants.css b/frontend/src/pages/explorePlants/ExplorePlants.css index 15270dd3..be582c2b 100644 --- a/frontend/src/pages/explorePlants/ExplorePlants.css +++ b/frontend/src/pages/explorePlants/ExplorePlants.css @@ -275,13 +275,14 @@ visibility: visible; } +/* Not matched: a filled dark pink button with a white flower */ .add-match-button { width: 50px; height: 50px; display: flex; align-items: center; justify-content: center; - border: none; + border: 2px solid var(--dark-pink); border-radius: 50%; background-color: var(--dark-pink); color: var(--text-light); @@ -291,14 +292,19 @@ box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15); } -.add-match-button:not(:disabled):hover { +/* Matched: white with a dark pink border and flower */ +.add-match-button--matched { + background-color: var(--light-background); + color: var(--dark-pink); +} + +.add-match-button:hover { transform: scale(1.1); } -.add-match-button:disabled { - opacity: 0.5; - cursor: default; - pointer-events: none; +.add-match-button:focus-visible { + outline: none; + box-shadow: 0 0 0 3px var(--dark-pink); } @media (max-width: 767px) { diff --git a/frontend/src/pages/explorePlants/ExplorePlants.tsx b/frontend/src/pages/explorePlants/ExplorePlants.tsx index 8613de40..7f02e184 100644 --- a/frontend/src/pages/explorePlants/ExplorePlants.tsx +++ b/frontend/src/pages/explorePlants/ExplorePlants.tsx @@ -28,7 +28,7 @@ export default function ExplorePlants() { const [searchParams, setSearchParams] = useSearchParams(); // Matches come from the user in the database, so every page sees the same list - const { matches, addMatch } = useMatchedPlants(); + const { matches, addMatch, removeMatch } = useMatchedPlants(); const search = searchParams.get("search") ?? ""; const debouncedSearch = useDebounce(search, 300); @@ -328,8 +328,8 @@ export default function ExplorePlants() { {plants.map((plant) => { // Disable the button if the plant is already in MyMatches const isMatched = matches.some((match) => match.id === plant.id); - const addLabel = isMatched - ? t("ExplorePlants.alreadyMatched") + const matchLabel = isMatched + ? t("ExplorePlants.removeMatch") : t("ExplorePlants.addMatch"); return ( @@ -339,15 +339,16 @@ export default function ExplorePlants() { diff --git a/frontend/src/tests/ExplorePage.test.tsx b/frontend/src/tests/ExplorePage.test.tsx index 8c74ba75..d863abe2 100644 --- a/frontend/src/tests/ExplorePage.test.tsx +++ b/frontend/src/tests/ExplorePage.test.tsx @@ -27,6 +27,19 @@ vi.mock("../components/plantCard/PlantCard", () => ({ ), })); +// Matches come from the user in the database, so the hook is replaced here. +// Tests can set `matches` to decide which plants are already matched. +const { matchedPlants } = vi.hoisted(() => ({ + matchedPlants: { + matches: [] as { id: string }[], + addMatch: vi.fn(), + removeMatch: vi.fn(), + }, +})); +vi.mock("../hooks/useMatchedPlants", () => ({ + useMatchedPlants: () => matchedPlants, +})); + function LocationProbe() { const location = useLocation(); return {location.search}; @@ -54,7 +67,7 @@ const DEFAULT_VARIABLES: Variables = { }; // Made-up plants, named " " so tests can tell result sets apart -function makePlants(count: number, start = 1, prefix = "Testplante") { +function makePlants(count: number, start = 1, prefix = "Plant") { return Array.from({ length: count }, (_, i) => ({ __typename: "Plant", id: `${prefix}-${start + i}`, @@ -123,6 +136,9 @@ describe("ExplorePlants", () => { beforeEach(() => { // shouldAdvanceTime keeps userEvent and findBy* from hanging with fake timers vi.useFakeTimers({ shouldAdvanceTime: true }); + matchedPlants.matches = []; + matchedPlants.addMatch.mockReset(); + matchedPlants.removeMatch.mockReset(); }); // Restore real timers after each test @@ -142,9 +158,9 @@ describe("ExplorePlants", () => { screen.queryByText("ExplorePlants.loading"), ).not.toBeInTheDocument(); expect(cardNames()).toEqual([ - "Testplante 1", - "Testplante 2", - "Testplante 3", + "Plant 1", + "Plant 2", + "Plant 3", ]); }); @@ -207,14 +223,14 @@ describe("ExplorePlants", () => { async (variable, label, value) => { const filtered = mockResponse( { [variable]: value } as Partial, - makePlants(2, 1, "Filtrert"), + makePlants(2, 1, "Filtered"), ); const { user } = setup([mockResponse({}), filtered]); await screen.findAllByTestId("plant-card"); await user.selectOptions(screen.getByLabelText(label), value); - expect(await screen.findByText("Filtrert 1")).toBeInTheDocument(); + expect(await screen.findByText("Filtered 1")).toBeInTheDocument(); expect(filtered.result).toHaveBeenCalledTimes(1); }, ); @@ -222,7 +238,7 @@ describe("ExplorePlants", () => { it("sends the chosen sort order and closes the sort menu", async () => { const sorted = mockResponse( { sort: "watering_asc" }, - makePlants(2, 1, "Sortert"), + makePlants(2, 1, "Sorted"), ); const { user } = setup([mockResponse({}), sorted]); await screen.findAllByTestId("plant-card"); @@ -243,7 +259,7 @@ describe("ExplorePlants", () => { screen.getByRole("button", { name: "ExplorePlants.watering_asc" }), ); - expect(await screen.findByText("Sortert 1")).toBeInTheDocument(); + expect(await screen.findByText("Sorted 1")).toBeInTheDocument(); expect( screen.queryByRole("button", { name: "ExplorePlants.watering_asc" }), ).not.toBeInTheDocument(); @@ -294,24 +310,24 @@ describe("ExplorePlants", () => { expect(next()).toBeEnabled(); await user.click(next()); - expect(await screen.findByText("Testplante 13")).toBeInTheDocument(); + expect(await screen.findByText("Plant 13")).toBeInTheDocument(); expect(screen.getByText("pagination.pageOf 2/3")).toBeInTheDocument(); await user.click(next()); - expect(await screen.findByText("Testplante 25")).toBeInTheDocument(); + expect(await screen.findByText("Plant 25")).toBeInTheDocument(); expect(cards()).toHaveLength(6); expect(screen.getByText("pagination.pageOf 3/3")).toBeInTheDocument(); expect(next()).toBeDisabled(); await user.click(previous()); - expect(await screen.findByText("Testplante 13")).toBeInTheDocument(); + expect(await screen.findByText("Plant 13")).toBeInTheDocument(); expect(screen.getByText("pagination.pageOf 2/3")).toBeInTheDocument(); }); it("goes back to page 1 when a filter changes", async () => { const filtered = mockResponse( { careLevel: "high" }, - makePlants(5, 1, "Høy"), + makePlants(5, 1, "High"), ); const { user } = setup([ mockResponse({}, makePlants(12), 30), @@ -333,7 +349,7 @@ describe("ExplorePlants", () => { ); // The request has offset 0, not 12, and the page counter starts over - expect(await screen.findByText("Høy 1")).toBeInTheDocument(); + expect(await screen.findByText("High 1")).toBeInTheDocument(); expect(filtered.result).toHaveBeenCalledTimes(1); expect(screen.getByText("pagination.pageOf 1/1")).toBeInTheDocument(); }); @@ -377,7 +393,7 @@ describe("ExplorePlants", () => { sort: "name_desc", offset: 12, }, - makePlants(2, 13, "Gjenopprettet"), + makePlants(2, 13, "Restored"), 30, ); @@ -397,7 +413,7 @@ describe("ExplorePlants", () => { expect(screen.getByLabelText("ExplorePlants.careLevel")).toHaveValue( "high", ); - expect(await screen.findByText("Gjenopprettet 13")).toBeInTheDocument(); + expect(await screen.findByText("Restored 13")).toBeInTheDocument(); expect(screen.getByText("pagination.pageOf 2/3")).toBeInTheDocument(); expect(restored.result).toHaveBeenCalledTimes(1); expect(screen.getByTestId("location-search")).toHaveTextContent( @@ -409,10 +425,10 @@ describe("ExplorePlants", () => { const { user } = setup( [ mockResponse({}), - mockResponse({ watering: "minimum" }, makePlants(2, 1, "Filtrert")), + mockResponse({ watering: "minimum" }, makePlants(2, 1, "Filtered")), mockResponse( { watering: "minimum", careLevel: "high" }, - makePlants(1, 1, "Filtrert to"), + makePlants(1, 1, "Filtered again"), ), ], "/explorePlants", @@ -425,12 +441,12 @@ describe("ExplorePlants", () => { screen.getByLabelText("ExplorePlants.watering"), "minimum", ); - await screen.findByText("Filtrert 1"); + await screen.findByText("Filtered 1"); await user.selectOptions( screen.getByLabelText("ExplorePlants.careLevel"), "high", ); - await screen.findByText("Filtrert to 1"); + await screen.findByText("Filtered again 1"); expect(screen.getByTestId("location-search")).toHaveTextContent( "?search=ro&watering=minimum&careLevel=high", ); @@ -442,11 +458,47 @@ describe("ExplorePlants", () => { expect(screen.getByRole("searchbox")).toHaveValue(""); expect(screen.getByLabelText("ExplorePlants.watering")).toHaveValue(""); expect(screen.getByLabelText("ExplorePlants.careLevel")).toHaveValue(""); - expect(await screen.findByText("Testplante 1")).toBeInTheDocument(); + expect(await screen.findByText("Plant 1")).toBeInTheDocument(); expect(screen.getByTestId("location-search")).toHaveTextContent(""); }); }); + // The ✿ button works as a toggle: it adds a plant that is not matched, + // and removes one that is already in My Matches + describe("adding and removing matches", () => { + it("adds a plant that is not matched", async () => { + const { user } = setup([mockResponse({})]); + await screen.findAllByTestId("plant-card"); + + await user.click( + screen.getAllByRole("button", { name: "ExplorePlants.addMatch" })[0], + ); + + expect(matchedPlants.addMatch).toHaveBeenCalledWith( + expect.objectContaining({ id: "Plant-1" }), + ); + expect(matchedPlants.removeMatch).not.toHaveBeenCalled(); + }); + + it("removes a plant that is already matched", async () => { + matchedPlants.matches = [{ id: "Plant-1" }]; + const { user } = setup([mockResponse({})]); + await screen.findAllByTestId("plant-card"); + + // Still clickable, and shown as filled + const removeButton = screen.getByRole("button", { + name: "ExplorePlants.removeMatch", + }); + expect(removeButton).toBeEnabled(); + expect(removeButton).toHaveClass("add-match-button--matched"); + + await user.click(removeButton); + + expect(matchedPlants.removeMatch).toHaveBeenCalledWith("Plant-1"); + expect(matchedPlants.addMatch).not.toHaveBeenCalled(); + }); + }); + // Accessibility: the page has a search landmark, a heading, a labelled // page navigation, and every input and filter has an accessible name. describe("accessibility", () => { diff --git a/frontend/src/tests/__snapshots__/ExplorePage.test.tsx.snap b/frontend/src/tests/__snapshots__/ExplorePage.test.tsx.snap index cc44c838..980c6546 100644 --- a/frontend/src/tests/__snapshots__/ExplorePage.test.tsx.snap +++ b/frontend/src/tests/__snapshots__/ExplorePage.test.tsx.snap @@ -424,7 +424,7 @@ exports[`ExplorePlants > snapshots > matches the snapshot of the page with resul
- Testplante 1 + Plant 1
snapshots > matches the snapshot of the page with resul
- Testplante 2 + Plant 2
snapshots > matches the snapshot of the page with resul
- Testplante 3 + Plant 3
snapshots > matches the snapshot of the page with resul
- Testplante 4 + Plant 4
snapshots > matches the snapshot of the page with resul
- Testplante 5 + Plant 5
snapshots > matches the snapshot of the page with resul
- Testplante 6 + Plant 6
snapshots > matches the snapshot of the page with resul
- Testplante 7 + Plant 7
snapshots > matches the snapshot of the page with resul
- Testplante 8 + Plant 8
snapshots > matches the snapshot of the page with resul
- Testplante 9 + Plant 9
snapshots > matches the snapshot of the page with resul
- Testplante 10 + Plant 10
snapshots > matches the snapshot of the page with resul
- Testplante 11 + Plant 11
snapshots > matches the snapshot of the page with resul
- Testplante 12 + Plant 12
snapshots > matches the snapshot of the page with the s
- Testplante 1 + Plant 1
snapshots > matches the snapshot of the page with the s
- Testplante 2 + Plant 2
snapshots > matches the snapshot of the page with the s
- Testplante 3 + Plant 3
Date: Mon, 9 Nov 2026 13:17:22 +0100 Subject: [PATCH 04/13] combine Explore Plants filters into a reusable FilterSelect component Move the three filter dropdowns into FilterSelect in components/filterSelect, defined from one FILTERS list. The markup is unchanged, so existing tests and snapshots still pass. Add FilterSelect tests. --- .../components/filterSelect/FilterSelect.css | 22 +++++ .../components/filterSelect/FilterSelect.tsx | 35 +++++++ .../src/pages/explorePlants/ExplorePlants.css | 23 ----- .../src/pages/explorePlants/ExplorePlants.tsx | 93 +++++++------------ frontend/src/tests/FilterSelect.test.tsx | 51 ++++++++++ 5 files changed, 144 insertions(+), 80 deletions(-) create mode 100644 frontend/src/components/filterSelect/FilterSelect.css create mode 100644 frontend/src/components/filterSelect/FilterSelect.tsx create mode 100644 frontend/src/tests/FilterSelect.test.tsx diff --git a/frontend/src/components/filterSelect/FilterSelect.css b/frontend/src/components/filterSelect/FilterSelect.css new file mode 100644 index 00000000..b7b94226 --- /dev/null +++ b/frontend/src/components/filterSelect/FilterSelect.css @@ -0,0 +1,22 @@ +.filter { + display: flex; + flex-direction: column; + gap: 0.25rem; + font-size: 1rem; +} + +.filter select { + padding: 0.5rem; + border: 1px solid var(--dark-pink); + border-radius: 8px; + min-width: 160px; + font-size: 15px; + background-color: var(--light-background); + color: var(--text-dark); +} + +.filter select:focus { + outline: none; + border-color: var(--dark-pink); + box-shadow: 0 0 0 2px var(--dark-pink); +} \ No newline at end of file diff --git a/frontend/src/components/filterSelect/FilterSelect.tsx b/frontend/src/components/filterSelect/FilterSelect.tsx new file mode 100644 index 00000000..d1698efc --- /dev/null +++ b/frontend/src/components/filterSelect/FilterSelect.tsx @@ -0,0 +1,35 @@ +import "./FilterSelect.css"; + +type FilterOption = { value: string; label: string }; + +type FilterSelectProps = { + label: string; + value: string; + allLabel: string; + options: FilterOption[]; + onChange: (value: string) => void; +}; + +// A labelled dropdown for one filter, with an "All" option that clears it. +// The texts come in already translated, so the component can be used for any filter. +export default function FilterSelect({ + label, + value, + allLabel, + options, + onChange, +}: FilterSelectProps) { + return ( + + ); +} \ No newline at end of file diff --git a/frontend/src/pages/explorePlants/ExplorePlants.css b/frontend/src/pages/explorePlants/ExplorePlants.css index be582c2b..7f954a2e 100644 --- a/frontend/src/pages/explorePlants/ExplorePlants.css +++ b/frontend/src/pages/explorePlants/ExplorePlants.css @@ -72,29 +72,6 @@ border: 0; } -.filter { - display: flex; - flex-direction: column; - gap: 0.25rem; - font-size: 1rem; -} - -.filter select { - padding: 0.5rem; - border: 1px solid var(--dark-pink); - border-radius: 8px; - min-width: 160px; - font-size: 15px; - background-color: var(--light-pink); - color: var(--text-dark); -} - -.filter select:focus { - outline: none; - border-color: var(--dark-pink); - box-shadow: 0 0 0 2px var(--dark-pink); -} - .reset-button { align-self: flex-start; width: 74px; diff --git a/frontend/src/pages/explorePlants/ExplorePlants.tsx b/frontend/src/pages/explorePlants/ExplorePlants.tsx index 7f02e184..087ae879 100644 --- a/frontend/src/pages/explorePlants/ExplorePlants.tsx +++ b/frontend/src/pages/explorePlants/ExplorePlants.tsx @@ -16,6 +16,7 @@ import { } from "./explorePlantsQuery.ts"; import PlantCard from "../../components/plantCard/PlantCard.tsx"; import Pagination from "../../components/pagination/Pagination.tsx"; +import FilterSelect from "../../components/filterSelect/FilterSelect.tsx"; import { useMatchedPlants } from "../../hooks/useMatchedPlants.ts"; import "./ExplorePlants.css"; @@ -23,6 +24,26 @@ const PAGE_SIZE = 12; const SORT_OPTIONS = ["name_asc", "name_desc", "watering_asc", "careLevel_asc"]; +// The filters on the page: the URL parameter, the translation key for the label, +// and the values to choose from. A new filter only needs a new line here. +const FILTERS = [ + { + param: "watering", + label: "ExplorePlants.watering", + options: ["minimum", "average", "frequent"], + }, + { + param: "sunlight", + label: "ExplorePlants.sunlight", + options: ["full_sun", "part_shade", "filtered_shade"], + }, + { + param: "careLevel", + label: "ExplorePlants.careLevel", + options: ["low", "medium", "high"], + }, +] as const; + export default function ExplorePlants() { const { t } = useTranslation(); const [searchParams, setSearchParams] = useSearchParams(); @@ -179,63 +200,21 @@ export default function ExplorePlants() { {t("ExplorePlants.filters")} - - - - - + {FILTERS.map((filter) => ( + ({ + value: option, + label: t(`ExplorePlants.${option}`), + }))} + onChange={(value) => + updateExploreParams({ [filter.param]: value, page: null }) + } + /> + ))}
+ + {open && ( +
    + {options.map((option) => ( +
  • + +
  • + ))} +
+ )} +
+ ); +} \ No newline at end of file diff --git a/frontend/src/pages/explorePlants/ExplorePlants.css b/frontend/src/pages/explorePlants/ExplorePlants.css index 7f954a2e..c600c5d5 100644 --- a/frontend/src/pages/explorePlants/ExplorePlants.css +++ b/frontend/src/pages/explorePlants/ExplorePlants.css @@ -133,92 +133,6 @@ position: relative; } -.sort-menu { - position: relative; - align-self: flex-end; -} - -.sort-button { - display: flex; - align-items: center; - gap: 0.5rem; - height: 40px; - padding: 0 0.75rem; - border: 1px solid var(--dark-pink); - border-radius: 8px; - background-color: var(--light-pink); - color: var(--text-dark); - font: inherit; - font-size: 15px; - white-space: nowrap; - cursor: pointer; -} - -.sort-button-icon { - font-size: 1.5rem; - flex-shrink: 0; -} - -/* All labels share one grid cell, so the button always fits the longest one */ -.sort-button-label { - display: grid; - text-align: left; -} - -.sort-button-label > span { - grid-area: 1 / 1; -} - -.sort-button-label--hidden { - visibility: hidden; -} - -.sort-button:hover { - background-color: var(--dark-pink); - color: var(--text-light); -} - -.sort-button:focus-visible, -.sort-option:focus-visible { - outline: none; - box-shadow: 0 0 0 2px var(--dark-pink); -} - -.sort-options { - position: absolute; - top: calc(100% + 6px); - left: 0; - z-index: 10; - min-width: 100%; - margin: 0; - padding: 0.25rem; - list-style: none; - background-color: var(--light-background); - border: 1px solid var(--dark-pink); - border-radius: 8px; - box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12); -} - -.sort-option { - width: 100%; - padding: 0.5rem 0.75rem; - border: none; - border-radius: 6px; - background: none; - color: var(--text-dark); - text-align: left; - cursor: pointer; -} - -.sort-option:hover { - background-color: var(--light-pink); -} - -.sort-option--active { - background-color: var(--light-pink); - font-weight: 700; -} - .add-match { position: absolute; top: -15px; diff --git a/frontend/src/pages/explorePlants/ExplorePlants.tsx b/frontend/src/pages/explorePlants/ExplorePlants.tsx index 087ae879..6e79145f 100644 --- a/frontend/src/pages/explorePlants/ExplorePlants.tsx +++ b/frontend/src/pages/explorePlants/ExplorePlants.tsx @@ -1,10 +1,3 @@ -import { - useEffect, - useRef, - useState, - type KeyboardEvent as ReactKeyboardEvent, -} from "react"; -import { BiSortAlt2 } from "react-icons/bi"; import { FaSearch } from "react-icons/fa"; import { useTranslation } from "react-i18next"; import { useQuery } from "@apollo/client/react"; @@ -17,6 +10,7 @@ import { import PlantCard from "../../components/plantCard/PlantCard.tsx"; import Pagination from "../../components/pagination/Pagination.tsx"; import FilterSelect from "../../components/filterSelect/FilterSelect.tsx"; +import SortMenu from "../../components/sortMenu/SortMenu.tsx"; import { useMatchedPlants } from "../../hooks/useMatchedPlants.ts"; import "./ExplorePlants.css"; @@ -59,10 +53,6 @@ export default function ExplorePlants() { const sort = searchParams.get("sort") ?? ""; const parsedPage = Number.parseInt(searchParams.get("page") ?? "", 10); const page = Number.isInteger(parsedPage) && parsedPage > 0 ? parsedPage : 1; - const [sortOpen, setSortOpen] = useState(false); - const sortRef = useRef(null); - const sortButtonRef = useRef(null); - const sortListRef = useRef(null); const currentSort = sort || "name_asc"; const updateExploreParams = (updates: Record) => { @@ -84,79 +74,6 @@ export default function ExplorePlants() { ); }; - // Close the sort menu on outside click or Escape - useEffect(() => { - if (!sortOpen) return; - // Move focus into the menu when it opens (to the active option) - sortListRef.current - ?.querySelector(".sort-option--active") - ?.focus(); - - const handleClick = (e: MouseEvent) => { - if (sortRef.current && !sortRef.current.contains(e.target as Node)) { - setSortOpen(false); - } - }; - const handleKey = (e: KeyboardEvent) => { - if (e.key === "Escape") { - setSortOpen(false); - // Return focus to the sort button so keyboard users don't lose their place - sortButtonRef.current?.focus(); - } - }; - - document.addEventListener("mousedown", handleClick); - document.addEventListener("keydown", handleKey); - return () => { - document.removeEventListener("mousedown", handleClick); - document.removeEventListener("keydown", handleKey); - }; - }, [sortOpen]); - - // Keyboard navigation inside the open sort menu: arrows, Home/End, - // and Tab cycles through the options instead of leaving the menu - const handleSortListKeyDown = (e: ReactKeyboardEvent) => { - const options = Array.from( - sortListRef.current?.querySelectorAll( - ".sort-option", - ) ?? [], - ); - if (options.length === 0) return; - - const current = options.indexOf( - document.activeElement as HTMLButtonElement, - ); - const last = options.length - 1; - let next: number; - - switch (e.key) { - case "ArrowDown": - next = current >= last ? 0 : current + 1; - break; - case "ArrowUp": - next = current <= 0 ? last : current - 1; - break; - case "Home": - next = 0; - break; - case "End": - next = last; - break; - case "Tab": - if (e.shiftKey) { - next = current <= 0 ? last : current - 1; - } else { - next = current >= last ? 0 : current + 1; - } - break; - default: - return; // Let Enter, Escape etc. behave as before - } - - e.preventDefault(); - options[next].focus(); - }; - const { data, loading, error } = useQuery(EXPLORE_PLANTS, { variables: { search: debouncedSearch || null, @@ -216,60 +133,17 @@ export default function ExplorePlants() { /> ))} -
- - - {sortOpen && ( -
    - {SORT_OPTIONS.map((option) => ( -
  • - -
  • - ))} -
- )} -
+ ({ + value: option, + label: t(`ExplorePlants.${option}`), + }))} + onChange={(option) => + updateExploreParams({ sort: option, page: null }) + } + /> @@ -305,7 +179,7 @@ export default function ExplorePlants() {
    {plants.map((plant) => { - // Disable the button if the plant is already in MyMatches + // The button adds the plant to My Matches, or removes it if it is already there const isMatched = matches.some((match) => match.id === plant.id); const matchLabel = isMatched ? t("ExplorePlants.removeMatch") diff --git a/frontend/src/tests/SortMenu.test.tsx b/frontend/src/tests/SortMenu.test.tsx new file mode 100644 index 00000000..026a6b7a --- /dev/null +++ b/frontend/src/tests/SortMenu.test.tsx @@ -0,0 +1,104 @@ +import { render, screen } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import { describe, it, expect, vi } from "vitest"; +import SortMenu from "../components/sortMenu/SortMenu"; + +const options = [ + { value: "name_asc", label: "Name (A-Z)" }, + { value: "name_desc", label: "Name (Z-A)" }, + { value: "watering_asc", label: "Watering" }, +]; + +function setup(value = "name_asc") { + const onChange = vi.fn(); + const user = userEvent.setup(); + render( + , + ); + const sortButton = screen.getByRole("button", { + name: `Sort: ${options.find((option) => option.value === value)?.label}`, + }); + const option = (name: string) => screen.queryByRole("button", { name }); + return { onChange, user, sortButton, option }; +} + +describe("SortMenu", () => { + it("shows the selected option in the button's accessible name", () => { + const { sortButton } = setup("watering_asc"); + + expect(sortButton).toHaveAccessibleName("Sort: Watering"); + expect(sortButton).toHaveAttribute("aria-expanded", "false"); + }); + + it("opens the menu with focus on the selected option", async () => { + const { user, sortButton, option } = setup("name_desc"); + + await user.click(sortButton); + + expect(sortButton).toHaveAttribute("aria-expanded", "true"); + expect(option("Name (Z-A)")).toHaveFocus(); + expect(option("Name (Z-A)")).toHaveAttribute("aria-pressed", "true"); + expect(option("Name (A-Z)")).toHaveAttribute("aria-pressed", "false"); + }); + + it("moves between the options with the arrow keys, Home, End and Tab", async () => { + const { user, sortButton, option } = setup(); + await user.click(sortButton); + expect(option("Name (A-Z)")).toHaveFocus(); + + await user.keyboard("{ArrowDown}"); + expect(option("Name (Z-A)")).toHaveFocus(); + + await user.keyboard("{End}"); + expect(option("Watering")).toHaveFocus(); + + // From the last option, down goes back to the first + await user.keyboard("{ArrowDown}"); + expect(option("Name (A-Z)")).toHaveFocus(); + + // From the first option, up goes to the last + await user.keyboard("{ArrowUp}"); + expect(option("Watering")).toHaveFocus(); + + await user.keyboard("{Home}"); + expect(option("Name (A-Z)")).toHaveFocus(); + + // Tab and Shift+Tab stay inside the menu + await user.keyboard("{Tab}"); + expect(option("Name (Z-A)")).toHaveFocus(); + await user.keyboard("{Shift>}{Tab}{/Shift}"); + expect(option("Name (A-Z)")).toHaveFocus(); + }); + + it("chooses an option, closes the menu and returns focus to the button", async () => { + const { onChange, user, sortButton, option } = setup(); + await user.click(sortButton); + + await user.click(option("Name (Z-A)")!); + + expect(onChange).toHaveBeenCalledWith("name_desc"); + expect(option("Name (Z-A)")).not.toBeInTheDocument(); + expect(sortButton).toHaveFocus(); + }); + + it("closes with Escape without choosing, and returns focus to the button", async () => { + const { onChange, user, sortButton, option } = setup(); + await user.click(sortButton); + + await user.keyboard("{Escape}"); + + expect(option("Name (A-Z)")).not.toBeInTheDocument(); + expect(sortButton).toHaveFocus(); + expect(onChange).not.toHaveBeenCalled(); + }); + + it("closes when the user clicks outside the menu", async () => { + const { onChange, user, sortButton, option } = setup(); + await user.click(sortButton); + + await user.click(document.body); + + expect(option("Name (A-Z)")).not.toBeInTheDocument(); + expect(onChange).not.toHaveBeenCalled(); + }); +}); \ No newline at end of file From 65e0bf7400fbb6092b4cb51c74d1dba79bfe7a90 Mon Sep 17 00:00:00 2001 From: Helene Lotsberg Date: Mon, 9 Nov 2026 15:45:30 +0100 Subject: [PATCH 10/13] move the URL state from ExplorePlants into a useExploreParams hook, add tests, update the documentation accordingly and run prettier --- docs/ai-usage.md | 2 +- docs/architecture.md | 20 ++-- docs/tests.md | 2 + frontend/src/components/sortMenu/SortMenu.css | 2 +- frontend/src/components/sortMenu/SortMenu.tsx | 6 +- frontend/src/hooks/useExploreParams.ts | 66 +++++++++++ .../src/pages/explorePlants/ExplorePlants.tsx | 89 +++++---------- frontend/src/tests/SortMenu.test.tsx | 9 +- frontend/src/tests/useExploreParams.test.tsx | 106 ++++++++++++++++++ 9 files changed, 223 insertions(+), 79 deletions(-) create mode 100644 frontend/src/hooks/useExploreParams.ts create mode 100644 frontend/src/tests/useExploreParams.test.tsx diff --git a/docs/ai-usage.md b/docs/ai-usage.md index 51e56a61..1b59bdc4 100644 --- a/docs/ai-usage.md +++ b/docs/ai-usage.md @@ -33,7 +33,7 @@ AI drafted many of the Vitest tests and the Playwright e2e and API tests, and su ### Improvements to Explore Plants -After the peer reviews, we used AI to work through the feedback on Explore Plants. We decided that the pagination, the filter dropdowns and the sort menu should be their own reusable components, `Pagination`, `FilterSelect` and `SortMenu`, and AI helped us move the right parts out of `ExplorePlants.tsx`, which had a lot of logic in one file. AI also made us aware of the trade-offs between offset- and cursor-based pagination, and between a text index and the regular expression search. Based on that, we chose to keep offset-based pagination so users can jump to any page, to keep the search on parts of names instead of using a text index, and to only add a database index where it is useful. The design was decided by the team. We reviewed and ran all tests before committing. +After the peer reviews, we used AI to work through the feedback on Explore Plants. We decided that the pagination, the filter dropdowns and the sort menu should be their own reusable components, `Pagination`, `FilterSelect` and `SortMenu`, and that the URL state should be moved into its own hook, `useExploreParams`. AI helped us move the right parts out of `ExplorePlants.tsx`, which had a lot of logic in one file. AI also made us aware of the trade-offs between offset- and cursor-based pagination, and between a text index and the regular expression search. Based on that, we chose to keep offset-based pagination so users can jump to any page, to keep the search on parts of names instead of using a text index, and to only add a database index where it is useful. The design was decided by the team. We reviewed and ran all tests before committing. ## How we kept control diff --git a/docs/architecture.md b/docs/architecture.md index 7721847d..2772d244 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -48,7 +48,7 @@ The frontend is built with React and TypeScript (Vite). | `*` | `NotFound` | 404 page for unknown paths, with a link back to Plant Match | - **User state:** `UserProvider` (`context/UserContext.tsx`) loads the current user from the backend and makes it available through `useUser()`. The hooks `useProfile` and `useMatchedPlants` wrap the user mutations, so pages do not call GraphQL directly for user data. All user queries and mutations live in `context/userQueries.ts`. -- **Reusable logic in hooks:** Logic without UI is kept in hooks. `useDebounce` delays updates while the user is typing (used for search and for saving the profile text), `useSearchParams` keeps Explore search, filters, sorting and page in the URL, and `useSessionState` stores state in `sessionStorage` for features that still use it. +- **Reusable logic in hooks:** Logic without UI is kept in hooks. `useDebounce` delays updates while the user is typing (used for search and for saving the profile text), `useExploreParams` keeps Explore search, filters, sorting and page in the URL (with React Router's `useSearchParams`) and sends the user back to page 1 when the search, a filter or the sort order changes, and `useSessionState` stores state in `sessionStorage` for features that still use it. - **Reusable components:** Shared UI is kept in `components/`. `Pagination` shows previous/next and numbered pages, and always shows the first and last page with "…" in between, so it works for any number of pages (`getPageItems`). `FilterSelect` is a labelled dropdown for one filter. `SortMenu` is a sort button that shows the selected option and opens a menu that can be used with the keyboard. All three take already translated texts, so they can be used on other pages. - **Internationalisation:** Text is stored in translation files for Norwegian and English (i18next). - **Shared types:** `Plant` and `Preference` are defined in `types/`. @@ -175,14 +175,14 @@ MongoDB runs on the course VM and only listens on `127.0.0.1`, so it cannot be r ## Where state is kept -| Where | What | Why | -| ---------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | -| MongoDB `users` | Profile (name, description, picture), preferences and matched plants | Persistent user data that should survive closing the browser | -| `localStorage` | Only the key `userId` | Lets the browser find its user again on the next visit, without a login | -| URL parameters | Explore page search, filters, sort and page (`search`, `watering`, `sunlight`, `carelevel`, `sort`, `page`) | The view survives navigation and refresh and can be shared as a link | -| `sessionStorage` | Features that still use `useSessionState`, such as the language switcher | The value is kept for the kurrent browser session | -| Apollo in-memory cache | Query results (plants and the current user) | Avoids asking the backend again for data the app already has, and keeps all pages in sync | -| React state | Short-lived UI state, such as the current plant on the match page and unsaved profile text | Only matters while the component is shown | +| Where | What | Why | +| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | +| MongoDB `users` | Profile (name, description, picture), preferences and matched plants | Persistent user data that should survive closing the browser | +| `localStorage` | Only the key `userId` | Lets the browser find its user again on the next visit, without a login | +| URL parameters | Explore page search, filters, sort and page (`search`, `watering`, `sunlight`, `careLevel`, `sort`, `page`), via `useExploreParams` | The view survives navigation and refresh and can be shared as a link | +| `sessionStorage` | Features that still use `useSessionState`, such as the language switcher | The value is kept for the kurrent browser session | +| Apollo in-memory cache | Query results (plants and the current user) | Avoids asking the backend again for data the app already has, and keeps all pages in sync | +| React state | Short-lived UI state, such as the current plant on the match page and unsaved profile text | Only matters while the component is shown | User data used to be stored in `localStorage`. `UserProvider` now removes the old keys (`plantPreferences`, `matchedPlants`, `profileName`, `description`, `profileAvatar`) on start-up, so old data does not lie around in the browser. @@ -245,7 +245,7 @@ T03-Project-2/ │ │ ├── assets/ # Static images │ │ ├── components/ # Reusable UI components, each in its own folder with a matching .css file │ │ ├── context/ # UserProvider and the GraphQL queries and mutations for the user -│ │ ├── hooks/ # Reusable logic without UI (useDebounce, useSessionState, useProfile, useMatchedPlants, usePlantDeck) +│ │ ├── hooks/ # Reusable logic without UI (useDebounce, useExploreParams, useSessionState, useProfile, useMatchedPlants, usePlantDeck) │ │ ├── i18n/ # Translation setup and locale files (no, en) │ │ ├── pages/ # One folder per page/route with a matching .css file │ │ ├── tests/ # Unit and component tests, including test setup (see tests.md) diff --git a/docs/tests.md b/docs/tests.md index aa87260b..f0aa11c6 100644 --- a/docs/tests.md +++ b/docs/tests.md @@ -162,6 +162,8 @@ The tests are in `frontend/src/tests`. Snapshot tests are used for the explore p - No user without a provider, loading the user saved in the browser, creating and saving a new user on the first visit, creating a new user when the saved one no longer exists, keeping the saved user when the backend is down, working on when creating a user fails, and removing old user data left in the browser. - `useDebounce.test.ts` - The initial value is returned at once, updates only come after the delay, the delay restarts on quick changes, and the default delay is 300 ms. +- `useExploreParams.test.tsx` + - Default values when the URL has no parameters, reading search, filters, sorting and page from the URL, page 1 for an invalid page number, going back to page 1 when the search, a filter or the sort order changes, keeping the other parameters when the page changes, removing a parameter that is set to an empty value, and clearing all Explore parameters on reset. - `useSessionState.test.ts` - Default and initial values, reading and saving in `sessionStorage`, keeping the value when the hook is mounted again, and working on when reading or saving fails. diff --git a/frontend/src/components/sortMenu/SortMenu.css b/frontend/src/components/sortMenu/SortMenu.css index 8373dfb1..de9f9dff 100644 --- a/frontend/src/components/sortMenu/SortMenu.css +++ b/frontend/src/components/sortMenu/SortMenu.css @@ -82,4 +82,4 @@ .sort-option--active { background-color: var(--light-pink); font-weight: 700; -} \ No newline at end of file +} diff --git a/frontend/src/components/sortMenu/SortMenu.tsx b/frontend/src/components/sortMenu/SortMenu.tsx index 7c06277c..7f6fe2ca 100644 --- a/frontend/src/components/sortMenu/SortMenu.tsx +++ b/frontend/src/components/sortMenu/SortMenu.tsx @@ -74,7 +74,9 @@ export default function SortMenu({ ); if (buttons.length === 0) return; - const current = buttons.indexOf(document.activeElement as HTMLButtonElement); + const current = buttons.indexOf( + document.activeElement as HTMLButtonElement, + ); const last = buttons.length - 1; let next: number; @@ -159,4 +161,4 @@ export default function SortMenu({ )} ); -} \ No newline at end of file +} diff --git a/frontend/src/hooks/useExploreParams.ts b/frontend/src/hooks/useExploreParams.ts new file mode 100644 index 00000000..c2347bfc --- /dev/null +++ b/frontend/src/hooks/useExploreParams.ts @@ -0,0 +1,66 @@ +import { useSearchParams } from "react-router-dom"; + +// The filters on Explore Plants, as they are named in the URL +export type FilterParam = "watering" | "sunlight" | "careLevel"; + +const DEFAULT_SORT = "name_asc"; + +// Keeps the Explore Plants state (search, filters, sorting and page) in the URL, +// so it survives refresh and can be shared as a link. The page only gets the +// values and functions to change them, and does not need to know about the URL. +export function useExploreParams() { + const [searchParams, setSearchParams] = useSearchParams(); + + const get = (key: string) => searchParams.get(key) ?? ""; + + // A missing or invalid page number (e.g. "abc" or "0") means page 1 + const parsedPage = Number.parseInt(get("page"), 10); + const page = Number.isInteger(parsedPage) && parsedPage > 0 ? parsedPage : 1; + + // Sets the given parameters, and removes the ones that are empty or null. + // replace: true, so changing a filter does not add a new step to the browser history. + const update = (updates: Record) => { + setSearchParams( + (currentParams) => { + const nextParams = new URLSearchParams(currentParams); + Object.entries(updates).forEach(([key, value]) => { + if (value) { + nextParams.set(key, value); + } else { + nextParams.delete(key); + } + }); + return nextParams; + }, + { replace: true }, + ); + }; + + return { + search: get("search"), + filters: { + watering: get("watering"), + sunlight: get("sunlight"), + careLevel: get("careLevel"), + }, + sort: get("sort") || DEFAULT_SORT, + page, + + // A new search, filter or sort order goes back to page 1, + // so the user never ends up on a page that no longer exists + setSearch: (value: string) => update({ search: value, page: null }), + setFilter: (param: FilterParam, value: string) => + update({ [param]: value, page: null }), + setSort: (value: string) => update({ sort: value, page: null }), + setPage: (value: number) => update({ page: String(value) }), + reset: () => + update({ + search: null, + watering: null, + sunlight: null, + careLevel: null, + sort: null, + page: null, + }), + }; +} diff --git a/frontend/src/pages/explorePlants/ExplorePlants.tsx b/frontend/src/pages/explorePlants/ExplorePlants.tsx index 6e79145f..eb6b1a4d 100644 --- a/frontend/src/pages/explorePlants/ExplorePlants.tsx +++ b/frontend/src/pages/explorePlants/ExplorePlants.tsx @@ -1,8 +1,8 @@ import { FaSearch } from "react-icons/fa"; import { useTranslation } from "react-i18next"; import { useQuery } from "@apollo/client/react"; -import { useSearchParams } from "react-router-dom"; import { useDebounce } from "../../hooks/useDebounce"; +import { useExploreParams } from "../../hooks/useExploreParams.ts"; import { EXPLORE_PLANTS, type ExplorePlantsData, @@ -40,47 +40,31 @@ const FILTERS = [ export default function ExplorePlants() { const { t } = useTranslation(); - const [searchParams, setSearchParams] = useSearchParams(); + + // Search, filters, sorting and page are kept in the URL + const { + search, + filters, + sort, + page, + setSearch, + setFilter, + setSort, + setPage, + reset, + } = useExploreParams(); + const debouncedSearch = useDebounce(search, 300); // Matches come from the user in the database, so every page sees the same list const { matches, addMatch, removeMatch } = useMatchedPlants(); - const search = searchParams.get("search") ?? ""; - const debouncedSearch = useDebounce(search, 300); - const watering = searchParams.get("watering") ?? ""; - const sunlight = searchParams.get("sunlight") ?? ""; - const careLevel = searchParams.get("careLevel") ?? ""; - const sort = searchParams.get("sort") ?? ""; - const parsedPage = Number.parseInt(searchParams.get("page") ?? "", 10); - const page = Number.isInteger(parsedPage) && parsedPage > 0 ? parsedPage : 1; - const currentSort = sort || "name_asc"; - - const updateExploreParams = (updates: Record) => { - setSearchParams( - (currentParams) => { - const nextParams = new URLSearchParams(currentParams); - - Object.entries(updates).forEach(([key, value]) => { - if (value) { - nextParams.set(key, value); - } else { - nextParams.delete(key); - } - }); - - return nextParams; - }, - { replace: true }, - ); - }; - const { data, loading, error } = useQuery(EXPLORE_PLANTS, { variables: { search: debouncedSearch || null, - watering: watering || null, - sunlight: sunlight || null, - careLevel: careLevel || null, - sort: currentSort, + watering: filters.watering || null, + sunlight: filters.sunlight || null, + careLevel: filters.careLevel || null, + sort, limit: PAGE_SIZE, offset: (page - 1) * PAGE_SIZE, }, @@ -106,9 +90,7 @@ export default function ExplorePlants() { type="search" placeholder={t("ExplorePlants.search")} value={search} - onChange={(e) => { - updateExploreParams({ search: e.target.value, page: null }); - }} + onChange={(e) => setSearch(e.target.value)} /> @@ -121,46 +103,29 @@ export default function ExplorePlants() { ({ value: option, label: t(`ExplorePlants.${option}`), }))} - onChange={(value) => - updateExploreParams({ [filter.param]: value, page: null }) - } + onChange={(value) => setFilter(filter.param, value)} /> ))} ({ value: option, label: t(`ExplorePlants.${option}`), }))} - onChange={(option) => - updateExploreParams({ sort: option, page: null }) - } + onChange={setSort} /> - @@ -213,9 +178,7 @@ export default function ExplorePlants() { - updateExploreParams({ page: String(target) }) - } + onPageChange={setPage} /> )} diff --git a/frontend/src/tests/SortMenu.test.tsx b/frontend/src/tests/SortMenu.test.tsx index 026a6b7a..893d3313 100644 --- a/frontend/src/tests/SortMenu.test.tsx +++ b/frontend/src/tests/SortMenu.test.tsx @@ -13,7 +13,12 @@ function setup(value = "name_asc") { const onChange = vi.fn(); const user = userEvent.setup(); render( - , + , ); const sortButton = screen.getByRole("button", { name: `Sort: ${options.find((option) => option.value === value)?.label}`, @@ -101,4 +106,4 @@ describe("SortMenu", () => { expect(option("Name (A-Z)")).not.toBeInTheDocument(); expect(onChange).not.toHaveBeenCalled(); }); -}); \ No newline at end of file +}); diff --git a/frontend/src/tests/useExploreParams.test.tsx b/frontend/src/tests/useExploreParams.test.tsx new file mode 100644 index 00000000..627d35d8 --- /dev/null +++ b/frontend/src/tests/useExploreParams.test.tsx @@ -0,0 +1,106 @@ +import type { ReactNode } from "react"; +import { act, renderHook } from "@testing-library/react"; +import { MemoryRouter, useLocation } from "react-router-dom"; +import { describe, it, expect } from "vitest"; +import { useExploreParams } from "../hooks/useExploreParams"; + +// Runs the hook inside a router that starts at the given URL, and also returns +// the location so the tests can check what is written to the URL +function setup(initialUrl = "/explorePlants") { + const wrapper = ({ children }: { children: ReactNode }) => ( + {children} + ); + return renderHook( + () => ({ explore: useExploreParams(), location: useLocation() }), + { wrapper }, + ); +} + +describe("useExploreParams", () => { + it("uses empty values, name A–Z and page 1 when the URL has no parameters", () => { + const { result } = setup(); + + expect(result.current.explore).toMatchObject({ + search: "", + filters: { watering: "", sunlight: "", careLevel: "" }, + sort: "name_asc", + page: 1, + }); + }); + + it("reads search, filters, sorting and page from the URL", () => { + const { result } = setup( + "/explorePlants?search=rose&watering=minimum&sunlight=part_shade&careLevel=high&sort=name_desc&page=3", + ); + + expect(result.current.explore).toMatchObject({ + search: "rose", + filters: { + watering: "minimum", + sunlight: "part_shade", + careLevel: "high", + }, + sort: "name_desc", + page: 3, + }); + }); + + it.each(["abc", "0", "-2"])( + "uses page 1 for an invalid page (%s)", + (value) => { + const { result } = setup(`/explorePlants?page=${value}`); + + expect(result.current.explore.page).toBe(1); + }, + ); + + it("goes back to page 1 when the search, a filter or the sort order changes", () => { + const { result } = setup("/explorePlants?page=3"); + + act(() => result.current.explore.setSearch("rose")); + expect(result.current.location.search).toBe("?search=rose"); + + act(() => result.current.explore.setPage(2)); + act(() => result.current.explore.setFilter("careLevel", "high")); + expect(result.current.location.search).toBe("?search=rose&careLevel=high"); + + act(() => result.current.explore.setPage(2)); + act(() => result.current.explore.setSort("name_desc")); + expect(result.current.location.search).toBe( + "?search=rose&careLevel=high&sort=name_desc", + ); + }); + + it("keeps the other parameters when the page changes", () => { + const { result } = setup("/explorePlants?search=rose"); + + act(() => result.current.explore.setPage(2)); + + expect(result.current.location.search).toBe("?search=rose&page=2"); + expect(result.current.explore.page).toBe(2); + }); + + it("removes a parameter when it is set to an empty value", () => { + const { result } = setup("/explorePlants?watering=minimum&search=rose"); + + act(() => result.current.explore.setFilter("watering", "")); + + expect(result.current.location.search).toBe("?search=rose"); + expect(result.current.explore.filters.watering).toBe(""); + }); + + it("clears all Explore parameters on reset", () => { + const { result } = setup( + "/explorePlants?search=rose&watering=minimum&sort=name_desc&page=2", + ); + + act(() => result.current.explore.reset()); + + expect(result.current.location.search).toBe(""); + expect(result.current.explore).toMatchObject({ + search: "", + sort: "name_asc", + page: 1, + }); + }); +}); From bae56381403056cdb95d2d51b9db35fdc2a7c4f2 Mon Sep 17 00:00:00 2001 From: Helene Lotsberg Date: Tue, 10 Nov 2026 11:45:43 +0100 Subject: [PATCH 11/13] rewrite AI usage example as refactoring after peer review --- docs/ai-usage.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/ai-usage.md b/docs/ai-usage.md index 1b59bdc4..87fe8f34 100644 --- a/docs/ai-usage.md +++ b/docs/ai-usage.md @@ -10,6 +10,7 @@ AI was used as an assistant throughout the development of the web application. T - **Writing and reviewing tests:** drafting test files with mocked dependencies, and explaining the reasoning behind the test structure and snapshot testing. AI also suggested what should be tested to get better test coverage. - **Writing documentation:** drafting and refining documentation and comments in the code. - **Generating pictures:** the avatar pictures on the profile page were made with AI. +- **Refactoring:** splitting large files containing a lot of logic into smaller components and hooks. ## Examples @@ -31,9 +32,9 @@ The avatar pictures that the user can choose between on the profile page were ge AI drafted many of the Vitest tests and the Playwright e2e and API tests, and suggested atypical cases to test, such as special characters in the search, too long names and invalid ids. The team reviewed the tests, adjusted them, and ran them to check that they pass and fail for the right reasons. The accessibility tests found a real problem with the language button (see [tests.md](tests.md)), which we then fixed. -### Improvements to Explore Plants +### Refactoring after peer review -After the peer reviews, we used AI to work through the feedback on Explore Plants. We decided that the pagination, the filter dropdowns and the sort menu should be their own reusable components, `Pagination`, `FilterSelect` and `SortMenu`, and that the URL state should be moved into its own hook, `useExploreParams`. AI helped us move the right parts out of `ExplorePlants.tsx`, which had a lot of logic in one file. AI also made us aware of the trade-offs between offset- and cursor-based pagination, and between a text index and the regular expression search. Based on that, we chose to keep offset-based pagination so users can jump to any page, to keep the search on parts of names instead of using a text index, and to only add a database index where it is useful. The design was decided by the team. We reviewed and ran all tests before committing. +After the peer reviews, we used AI to help us split up `ExplorePlants.tsx`, which contained a lot of logic in one file. The team decided which parts should become reusable components and hooks, and AI helped us move the right code out of the file without changing how the page works. ## How we kept control From 1611acf7e804184a0ade6bf7a10cf3ce21755e75 Mon Sep 17 00:00:00 2001 From: Helene Lotsberg Date: Tue, 10 Nov 2026 12:45:21 +0100 Subject: [PATCH 12/13] move fonts into CSS variables --- frontend/src/components/header/Header.css | 1 - .../src/components/pagination/Pagination.css | 3 ++- .../src/components/plantCard/PlantCard.css | 2 +- .../sidebarButtons/SideBarButton.css | 2 +- frontend/src/components/sortMenu/SortMenu.css | 2 +- frontend/src/index.css | 18 ++++++++++++++++++ .../src/pages/explorePlants/ExplorePlants.css | 3 --- frontend/src/pages/myMatches/MyMatchesPage.css | 3 --- frontend/src/pages/notFound/NotFound.css | 1 - .../src/pages/plantMatch/PlantMatchPage.css | 1 - .../pages/plantOwnerTest/PlantOwnerTest.css | 4 ++-- frontend/src/pages/profile/Profile.css | 3 ++- 12 files changed, 27 insertions(+), 16 deletions(-) diff --git a/frontend/src/components/header/Header.css b/frontend/src/components/header/Header.css index 4109c1f2..fd88d289 100644 --- a/frontend/src/components/header/Header.css +++ b/frontend/src/components/header/Header.css @@ -19,7 +19,6 @@ .header h1 { margin: 0; font-size: 45px; - font-family: Georgia, serif; font-weight: 400; letter-spacing: -0.3px; } diff --git a/frontend/src/components/pagination/Pagination.css b/frontend/src/components/pagination/Pagination.css index bd50832e..f324bb5f 100644 --- a/frontend/src/components/pagination/Pagination.css +++ b/frontend/src/components/pagination/Pagination.css @@ -24,7 +24,8 @@ border-radius: 8px; background-color: var(--light-green); color: var(--text-dark); - font: inherit; + font-family: var(--font-ui); + font-size: 1rem; cursor: pointer; } diff --git a/frontend/src/components/plantCard/PlantCard.css b/frontend/src/components/plantCard/PlantCard.css index 6308c0c8..9878818a 100644 --- a/frontend/src/components/plantCard/PlantCard.css +++ b/frontend/src/components/plantCard/PlantCard.css @@ -93,7 +93,7 @@ overflow: hidden; - font-family: Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif; + font-family: var(--font-card); } .plant-card-face > .plant-card { diff --git a/frontend/src/components/sidebarButtons/SideBarButton.css b/frontend/src/components/sidebarButtons/SideBarButton.css index 839cf076..1bdccba9 100644 --- a/frontend/src/components/sidebarButtons/SideBarButton.css +++ b/frontend/src/components/sidebarButtons/SideBarButton.css @@ -10,7 +10,7 @@ } .language-button { - font-family: Arial, sans-serif; + font-family: var(--font-ui); font-size: 19px; font-weight: 600; } diff --git a/frontend/src/components/sortMenu/SortMenu.css b/frontend/src/components/sortMenu/SortMenu.css index de9f9dff..4513cddd 100644 --- a/frontend/src/components/sortMenu/SortMenu.css +++ b/frontend/src/components/sortMenu/SortMenu.css @@ -13,7 +13,7 @@ border-radius: 8px; background-color: var(--light-pink); color: var(--text-dark); - font: inherit; + font-family: var(--font-ui); font-size: 15px; white-space: nowrap; cursor: pointer; diff --git a/frontend/src/index.css b/frontend/src/index.css index 68312d8c..959bf88b 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -10,11 +10,29 @@ body, body { min-height: 100vh; background: var(--bg); + font-family: var(--font-text); color: var(--text-dark); } +/* Form controls don't inherit the font from the page, so they get --font-ui here */ +button, +input, +select, +textarea { + font-family: var(--font-ui); +} + :root { --sidebar-width: 16rem; + /* Fonts: serif for all pages, and a separate font for the plant cards */ + --font-text: Georgia, serif; + --font-card: Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif; + /* Font for buttons and form fields. Test the options by commenting one line in: + the system font (default), Georgia like the text, or Arial */ + /* --font-ui: system-ui, sans-serif; */ + --font-ui: var(--font-text); + /* --font-ui: Arial, sans-serif; */ + /* Colors: */ --text-dark: #44403c; --text-light: #ffffff; --light-background: #ffffff; diff --git a/frontend/src/pages/explorePlants/ExplorePlants.css b/frontend/src/pages/explorePlants/ExplorePlants.css index c600c5d5..0891d75f 100644 --- a/frontend/src/pages/explorePlants/ExplorePlants.css +++ b/frontend/src/pages/explorePlants/ExplorePlants.css @@ -9,8 +9,6 @@ flex-direction: column; align-items: center; gap: 30px; - - font-family: Georgia, serif; } .visually-hidden { @@ -106,7 +104,6 @@ .explore-results > p { font-size: 20px; text-align: center; - font-family: Georgia, serif; } .explore-results .results-count { diff --git a/frontend/src/pages/myMatches/MyMatchesPage.css b/frontend/src/pages/myMatches/MyMatchesPage.css index dd06c9e0..b9438cc1 100644 --- a/frontend/src/pages/myMatches/MyMatchesPage.css +++ b/frontend/src/pages/myMatches/MyMatchesPage.css @@ -9,8 +9,6 @@ flex-direction: column; align-items: center; gap: 30px; - - font-family: Georgia, serif; } .matches-grid { @@ -34,7 +32,6 @@ text-align: center; font-size: 20px; text-align: center; - font-family: Georgia, serif; } .plant-card-match { diff --git a/frontend/src/pages/notFound/NotFound.css b/frontend/src/pages/notFound/NotFound.css index a62a0553..63848144 100644 --- a/frontend/src/pages/notFound/NotFound.css +++ b/frontend/src/pages/notFound/NotFound.css @@ -11,7 +11,6 @@ justify-content: center; gap: 1rem; text-align: center; - font-family: Georgia, serif; } .not-found-code { diff --git a/frontend/src/pages/plantMatch/PlantMatchPage.css b/frontend/src/pages/plantMatch/PlantMatchPage.css index c6347d8c..b77cc0e6 100644 --- a/frontend/src/pages/plantMatch/PlantMatchPage.css +++ b/frontend/src/pages/plantMatch/PlantMatchPage.css @@ -54,7 +54,6 @@ border-radius: 50%; background-color: var(--dark-pink); color: var(--text-light); - font-family: serif; font-size: 22px; font-weight: 700; cursor: pointer; diff --git a/frontend/src/pages/plantOwnerTest/PlantOwnerTest.css b/frontend/src/pages/plantOwnerTest/PlantOwnerTest.css index c0e97569..7faaf0db 100644 --- a/frontend/src/pages/plantOwnerTest/PlantOwnerTest.css +++ b/frontend/src/pages/plantOwnerTest/PlantOwnerTest.css @@ -55,7 +55,7 @@ border-radius: 16px; background: var(--light-sage); color: var(--text-dark); - font: inherit; + font-family: var(--font-text); font-size: 1.15rem; font-weight: 500; line-height: 1.7; @@ -94,7 +94,7 @@ border-radius: 999px; background: var(--dark-green); color: var(--text-on-green); - font: inherit; + font-family: var(--font-ui); font-size: 1.05rem; font-weight: 600; cursor: pointer; diff --git a/frontend/src/pages/profile/Profile.css b/frontend/src/pages/profile/Profile.css index e5b5ebff..d0ffbfc5 100644 --- a/frontend/src/pages/profile/Profile.css +++ b/frontend/src/pages/profile/Profile.css @@ -107,7 +107,8 @@ border: 1px solid var(--dark-green); border-radius: 8px; box-sizing: border-box; - font: inherit; + font-family: var(--font-ui); + font-size: 1rem; } .edit-profile-form input::placeholder { From 6d937b0c86ff09cb6062487676b92ea312bb83b6 Mon Sep 17 00:00:00 2001 From: Helene Lotsberg Date: Tue, 10 Nov 2026 12:50:48 +0100 Subject: [PATCH 13/13] run prettier and remove a comment --- frontend/src/index.css | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/frontend/src/index.css b/frontend/src/index.css index 959bf88b..c2e2e16b 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -24,11 +24,9 @@ textarea { :root { --sidebar-width: 16rem; - /* Fonts: serif for all pages, and a separate font for the plant cards */ + /* Fonts: serif for all pages, and a separate font for the plant cards */ --font-text: Georgia, serif; --font-card: Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif; - /* Font for buttons and form fields. Test the options by commenting one line in: - the system font (default), Georgia like the text, or Arial */ /* --font-ui: system-ui, sans-serif; */ --font-ui: var(--font-text); /* --font-ui: Arial, sans-serif; */