Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,4 @@ See [quality.md](docs/quality.md) for work practices, accessibility, sustainable
## Known issues

- The plant information on the plant cards is not translated to Norwegian.
- The plant images are stored as base64 in the database and sent inside the GraphQL responses. This makes the responses larger, and the browser can't cache the images or load them lazily. See [Limitations of the architecture](docs/architecture.md#limitations-of-the-architecture) for why we chose it and how it could be improved.
2 changes: 1 addition & 1 deletion docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ T03-Project-2/
### Naming conventions

- **PascalCase** for React components and their files (`PlantCard.tsx`, `SortMenu.css`), and for TypeScript types (`Plant`, `PlantCardProps`). Every page component ends in `Page` (`ExplorePlantsPage`), and test files are named after what they test (`ExplorePlantsPage.test.tsx`).
- **camelCase** for variables, functions, hooks (`useMatchedPlants`), folders, routes (`/myMatches`), translation sections and keys (`explorePlantsPage.search`), and all other files, including images and e2e helpers (`snakePlant.png`, `globalSetup.ts`).
- **camelCase** for variables, functions, hooks (`useMatchedPlants`), folders, routes (`/myMatches`), translation sections and keys (`explorePlantsPage.search`), and all other files, including images and e2e helpers (`snakePlant.webp`, `globalSetup.ts`).
- **UPPER_SNAKE_CASE** for module-level constants that never change (`ROUTES`, `PAGE_SIZE`, `GET_PLANTS`, `LANGUAGE_STORAGE_KEY`).

## How to start the backend if it stops
Expand Down
10 changes: 10 additions & 0 deletions docs/quality.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ We considered sustainability through both our design choices and our approach to

- **Filter counts in one query:** The number of plants for every filter value on Explore Plants is counted in the same request as the results, in one database query, instead of one request per value. Values that would give no plants can't be chosen, so the user does not send requests that only return an empty list.

- **Pictures in WebP:** The avatars, the pictures from the plant owner test and the placeholder for plants without an image were PNG files. We converted them to WebP, which gives much smaller files for the same picture. The avatars and the placeholder use lossy WebP at quality 85, with no visible difference. The plant owner test pictures are simple drawings with few colours, where lossy WebP became larger than the PNG, so they use lossless WebP instead. We measured the effect on the build (`npm run build`) and on the Profile page with the avatar chooser open (DevTools, Network, cache disabled):

| | PNG | WebP | Change |
| ------------------------------------ | ------ | ------ | ------ |
| All 15 pictures in the app | 395 kB | 156 kB | −60 % |
| Profile page, pictures (8) | 260 kB | 84 kB | −68 % |
| Profile page, everything transferred | 444 kB | 268 kB | −40 % |

The pictures were more than half of what the Profile page downloads, so this was the biggest single saving for that page.

## Design choices

- **Color palette and contrast:** We used a limited color palette to maintain a consistent visual identity across the application. We also checked the contrast between our chosen colors to help ensure that text and other interface elements remain distinguishable and in line with accessibility requirements. See [Accessibility](#accessibility).
Expand Down
2 changes: 1 addition & 1 deletion e2e/uiImages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ test("the placeholder picture loads on plant cards without an image", async ({
(element) => getComputedStyle(element, "::before").backgroundImage,
);
const url = backgroundImage.match(/url\("?(.*?)"?\)/)?.[1];
// Vite adds a hash to the file name in the build, for example plantPlaceholder-a1b2c3.png
// Vite adds a hash to the file name in the build, for example plantPlaceholder-a1b2c3.webp
expect(url).toContain("plantPlaceholder");

expect(await loadImageWidth(page, url!)).toBeGreaterThan(0);
Expand Down
Binary file removed frontend/src/assets/avatars/anthurium.png
Binary file not shown.
Binary file added frontend/src/assets/avatars/anthurium.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed frontend/src/assets/avatars/fern.png
Binary file not shown.
Binary file added frontend/src/assets/avatars/fern.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed frontend/src/assets/avatars/monstera.png
Binary file not shown.
Binary file added frontend/src/assets/avatars/monstera.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed frontend/src/assets/avatars/orchid.png
Binary file not shown.
Binary file added frontend/src/assets/avatars/orchid.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed frontend/src/assets/avatars/pothos.png
Binary file not shown.
Binary file added frontend/src/assets/avatars/pothos.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed frontend/src/assets/avatars/profile.png
Binary file not shown.
Binary file added frontend/src/assets/avatars/profile.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed frontend/src/assets/avatars/snakePlant.png
Binary file not shown.
Binary file added frontend/src/assets/avatars/snakePlant.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed frontend/src/assets/avatars/succulent.png
Binary file not shown.
Binary file added frontend/src/assets/avatars/succulent.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed frontend/src/assets/plantPlaceholder.png
Binary file not shown.
Binary file added frontend/src/assets/plantPlaceholder.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed frontend/src/assets/plantQuiz/cityMinimalist.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed frontend/src/assets/plantQuiz/gardenExpert.png
Binary file not shown.
Binary file added frontend/src/assets/plantQuiz/gardenExpert.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion frontend/src/components/plantCard/PlantCard.css
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
content: "";
position: absolute;
inset: 0;
background: url("../../assets/plantPlaceholder.png") center / cover no-repeat;
background: url("../../assets/plantPlaceholder.webp") center / cover no-repeat;
}

.plant-card-front .plant-card-preferences {
Expand Down
14 changes: 7 additions & 7 deletions frontend/src/components/walkthrough/walkthroughSteps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
// The text for each step is in translation.json under walkthrough.steps.<id>.

import { ROUTES } from "../../AppRoutes";
import monstera from "../../assets/avatars/monstera.png";
import pothos from "../../assets/avatars/pothos.png";
import fern from "../../assets/avatars/fern.png";
import anthurium from "../../assets/avatars/anthurium.png";
import orchid from "../../assets/avatars/orchid.png";
import succulent from "../../assets/avatars/succulent.png";
import snakePlant from "../../assets/avatars/snakePlant.png";
import monstera from "../../assets/avatars/monstera.webp";
import pothos from "../../assets/avatars/pothos.webp";
import fern from "../../assets/avatars/fern.webp";
import anthurium from "../../assets/avatars/anthurium.webp";
import orchid from "../../assets/avatars/orchid.webp";
import succulent from "../../assets/avatars/succulent.webp";
import snakePlant from "../../assets/avatars/snakePlant.webp";

export type WalkthroughStep = {
id: string;
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/pages/plantOwnerTest/plantOwnerTest.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// The questions and results of the plant owner test

import cityMinimalist from "../../assets/plantQuiz/cityMinimalist.png";
import averageCityGardener from "../../assets/plantQuiz/averageCityGardener.png";
import cityGardenerDreaming from "../../assets/plantQuiz/cityGardenerDreaming.png";
import countryMinimalist from "../../assets/plantQuiz/countryMinimalist.png";
import averageCountryGardener from "../../assets/plantQuiz/averageCountryGardener.png";
import gardenExpert from "../../assets/plantQuiz/gardenExpert.png";
import cityMinimalist from "../../assets/plantQuiz/cityMinimalist.webp";
import averageCityGardener from "../../assets/plantQuiz/averageCityGardener.webp";
import cityGardenerDreaming from "../../assets/plantQuiz/cityGardenerDreaming.webp";
import countryMinimalist from "../../assets/plantQuiz/countryMinimalist.webp";
import averageCountryGardener from "../../assets/plantQuiz/averageCountryGardener.webp";
import gardenExpert from "../../assets/plantQuiz/gardenExpert.webp";

export type PlantOwnerType =
| "cityMinimalist"
Expand Down
16 changes: 8 additions & 8 deletions frontend/src/pages/profile/ProfilePage.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import "./ProfilePage.css";
import profileImg from "../../assets/avatars/profile.png";
import profileImg from "../../assets/avatars/profile.webp";
import type { Preference } from "../../types/Preference.ts";
import { useTranslation } from "react-i18next";
import { useState } from "react";
import PlantPreferences from "../../components/plantPreferences/PlantPreferences.tsx";
import monstera from "../../assets/avatars/monstera.png";
import anthurium from "../../assets/avatars/anthurium.png";
import fern from "../../assets/avatars/fern.png";
import orchid from "../../assets/avatars/orchid.png";
import pothos from "../../assets/avatars/pothos.png";
import snakePlant from "../../assets/avatars/snakePlant.png";
import succulent from "../../assets/avatars/succulent.png";
import monstera from "../../assets/avatars/monstera.webp";
import anthurium from "../../assets/avatars/anthurium.webp";
import fern from "../../assets/avatars/fern.webp";
import orchid from "../../assets/avatars/orchid.webp";
import pothos from "../../assets/avatars/pothos.webp";
import snakePlant from "../../assets/avatars/snakePlant.webp";
import succulent from "../../assets/avatars/succulent.webp";
import { useProfile } from "../../hooks/useProfile.ts";
import { useDismissibleTooltip } from "../../hooks/useDismissibleTooltip.ts";
import {
Expand Down
Loading