From fa44e9f1949ac1db7e560ea8bce6591d33882d3d Mon Sep 17 00:00:00 2001 From: Linde Vrenne Date: Tue, 20 Oct 2026 11:37:59 +0200 Subject: [PATCH 1/4] Laget checkbox komponenten --- frontend/src/components/checkbox/Checkbox.tsx | 24 +++++++++++ .../src/pages/SearchResults/SearchFilters.tsx | 7 ++-- .../pages/SearchResults/SearchResultsPage.css | 40 ------------------- frontend/src/pages/home/HomePage.tsx | 8 +--- 4 files changed, 29 insertions(+), 50 deletions(-) create mode 100644 frontend/src/components/checkbox/Checkbox.tsx diff --git a/frontend/src/components/checkbox/Checkbox.tsx b/frontend/src/components/checkbox/Checkbox.tsx new file mode 100644 index 0000000..f39d9e2 --- /dev/null +++ b/frontend/src/components/checkbox/Checkbox.tsx @@ -0,0 +1,24 @@ +import type { InputHTMLAttributes } from "react"; +import "./Checkbox.css"; + +// En ekte , så den virker med tastatur og skjermleser. +// Alle vanlige input-props (checked, onChange, id, aria-label ...) sendes rett videre. +type CheckboxProps = Omit, "type" | "size"> & { + size?: "normal" | "large"; +}; + +export default function Checkbox({ + size = "normal", + className = "", + ...rest +}: CheckboxProps) { + const sizeClass = size === "large" ? "checkbox--large" : ""; + + return ( + + ); +} diff --git a/frontend/src/pages/SearchResults/SearchFilters.tsx b/frontend/src/pages/SearchResults/SearchFilters.tsx index f7eb772..4138693 100644 --- a/frontend/src/pages/SearchResults/SearchFilters.tsx +++ b/frontend/src/pages/SearchResults/SearchFilters.tsx @@ -1,5 +1,6 @@ import type { FilterCount } from "./searchTypes"; +import Checkbox from "../../components/checkbox/Checkbox"; type SearchFiltersProps = { categories: FilterCount[]; @@ -73,8 +74,7 @@ export default function SearchFilters({ key={category.value} > - - toggle( diff --git a/frontend/src/pages/SearchResults/SearchResultsPage.css b/frontend/src/pages/SearchResults/SearchResultsPage.css index cbb78df..99150ca 100644 --- a/frontend/src/pages/SearchResults/SearchResultsPage.css +++ b/frontend/src/pages/SearchResults/SearchResultsPage.css @@ -533,46 +533,6 @@ color: var(--text-accent); } -/* ---- Avkrysningsboksen ---- - Samme visuelle prinsipp som Lindes Checkbox. - Standard utseende fjernes (appearance: none) og tegnes på nytt. */ - -.search-filter-option input { - appearance: none; - display: inline-grid; - place-items: center; - flex-shrink: 0; - width: 16px; - height: 16px; - margin: 0; - background: var(--bg-surface); - border: 1.25px solid var(--border-brand); - border-radius: 3px; - cursor: pointer; -} - -/* Valgt: fylt bakgrunn */ -.search-filter-option input:checked { - background: var(--bg-brand); - border-color: var(--bg-brand); -} - -/* Valgt: haken tegnes med to kanter på et lite element som roteres */ -.search-filter-option input:checked::after { - content: ""; - width: 8px; - height: 4px; - border-left: 1.8px solid var(--text-on-dark); - border-bottom: 1.8px solid var(--text-on-dark); - transform: translateY(-1px) rotate(-45deg); -} - -/* Synlig fokus for tastaturbrukere */ -.search-filter-option input:focus-visible { - outline: 2px solid var(--text-accent); - outline-offset: 2px; -} - /* Knappen som åpner filtrene på mobil. Skjult på desktop, vises igjen i seksjon 14 (mobil). */ .search-mobile-filter-toggle { diff --git a/frontend/src/pages/home/HomePage.tsx b/frontend/src/pages/home/HomePage.tsx index c1c709e..2d27cd9 100644 --- a/frontend/src/pages/home/HomePage.tsx +++ b/frontend/src/pages/home/HomePage.tsx @@ -11,7 +11,7 @@ import "./HomePage.css"; import "../../components/searchfield/Searchfield.css"; import "../../components/button/Button.css"; import "../../components/noteItem/NoteItem.css"; -import "../../components/checkbox/Checkbox.css"; +import Checkbox from "../../components/checkbox/Checkbox"; import "../../components/categoryCard/CategoryCard.css"; // ========================================== @@ -226,11 +226,7 @@ function HomePage({ {noteItems.map((item) => (