diff --git a/frontend/src/components/cartIllustration/CartIllustration.css b/frontend/src/components/cartIllustration/CartIllustration.css new file mode 100644 index 0000000..6af12f7 --- /dev/null +++ b/frontend/src/components/cartIllustration/CartIllustration.css @@ -0,0 +1,82 @@ +/* CartIllustration – handlevogna på startsiden */ + +/* ---------- Oppsett ---------- */ + +.cart-illustration { + margin: 24px 0 0; +} + +/* «Veien» handlevogna ruller på. container-type gjør at vi kan bruke + bredden (cqw) i animasjonen under. */ +.cart-illustration__track { + container-type: inline-size; + border-bottom: 1px dashed var(--border-hairline); +} + +.cart-illustration__cart { + display: block; + width: 13.75rem; + max-width: 60%; + height: auto; + color: var(--text-primary); + overflow: visible; +} + +.cart-illustration__grid { + stroke: var(--border-brand); + stroke-width: 1.4; + opacity: 0.55; +} + +/* Hjulene roterer rundt sitt eget midtpunkt */ +.cart-illustration__wheel { + transform-box: fill-box; + transform-origin: center; +} + +/* ---------- Ruller når man blar ---------- + Scroll-drevet animasjon: framdriften følger hvor langt siden er blått, + ikke tid. Ren CSS, ingen JavaScript. + - Nettlesere uten støtte (f.eks. Firefox): handlevogna står til venstre. + - Redusert bevegelse i systemet: handlevogna står stille. */ + +@supports (animation-timeline: scroll()) { + @media (prefers-reduced-motion: no-preference) { + .cart-illustration__cart { + animation: cart-roll linear both; + animation-timeline: scroll(root); + animation-range: 0 60vh; + } + + .cart-illustration__wheel { + animation: cart-wheel linear both; + animation-timeline: scroll(root); + animation-range: 0 60vh; + } + } +} + +@keyframes cart-roll { + from { + translate: 0 0; + } + to { + /* Helt til høyre: bredden på veien minus bredden på handlevogna */ + translate: calc(100cqw - 100%) 0; + } +} + +@keyframes cart-wheel { + to { + rotate: 720deg; + } +} + +/* ---------- Mobil ---------- + Skjules på smale skjermer, så søket ikke skyves langt ned. */ + +@media (max-width: 600px) { + .cart-illustration { + display: none; + } +} diff --git a/frontend/src/components/cartIllustration/CartIllustration.tsx b/frontend/src/components/cartIllustration/CartIllustration.tsx new file mode 100644 index 0000000..fddc578 --- /dev/null +++ b/frontend/src/components/cartIllustration/CartIllustration.tsx @@ -0,0 +1,71 @@ +import "./CartIllustration.css"; + +// Håndtegnet handlevogn på startsiden, i samme strek som lappen ved siden av. +// Den ruller mot høyre når man blar nedover (se CartIllustration.css). +// +// Ren pynt: aria-hidden, så skjermlesere hopper over den. +// Fargene kommer fra theme.css, så den virker i lys og mørk modus. + +export default function CartIllustration() { + return ( +
+ ); +} diff --git a/frontend/src/pages/home/HomePage.tsx b/frontend/src/pages/home/HomePage.tsx index 8fb3602..30ba085 100644 --- a/frontend/src/pages/home/HomePage.tsx +++ b/frontend/src/pages/home/HomePage.tsx @@ -5,6 +5,7 @@ import SearchField from "../../components/searchfield/SearchField"; import Button from "../../components/button/Button"; import NoteItem from "../../components/noteItem/NoteItem"; import CategoryCard from "../../components/categoryCard/CategoryCard"; +import CartIllustration from "../../components/cartIllustration/CartIllustration"; // ========================================== // MIDLERTIDIG HANDLELAPP @@ -73,6 +74,8 @@ function HomePage({ onSearch, onCategorySelect }: HomePageProps) {12 400 VARER · 6 KJEDER · OPPDATERT DAGLIG
+ +