Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
20 changes: 20 additions & 0 deletions frontend/src/components/resultRow/ResultRow.css
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,23 @@
min-height: 44px;
}
}

/* Produktlenken beholder samme styling som vanlige produktnavn. */
.result-row__link {
color: var(--text-primary);
text-decoration: none;
cursor: pointer;
}

/* Vis at produktnavnet er klikkbart. */
.result-row__link:hover {
color: var(--text-brand);
text-decoration: underline;
}

/* Tydelig fokus ved tastaturnavigasjon. */
.result-row__link:focus-visible {
outline: 2px solid var(--text-accent);
outline-offset: 3px;
border-radius: 2px;
}
18 changes: 17 additions & 1 deletion frontend/src/components/resultRow/ResultRow.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Button from "../button/Button";
import "./ResultRow.css";
import { Link } from "react-router";

// Fra Figma: Components → ResultRow. Én vare i søkeresultatet.
// Kolonner: nummer · navn og detaljer · kr per kg · pris og butikk · knapp.
Expand All @@ -15,6 +16,8 @@ type ResultRowProps = {
quantityOnList?: number;
onIncrease?: () => void;
onDecrease?: () => void;
// Valgfri lenke til produktdetaljsiden.
to?: string;
};

export default function ResultRow({
Expand All @@ -24,6 +27,7 @@ export default function ResultRow({
pricePerKg,
price,
chain,
to,
onAdd,
quantityOnList = 0,
onIncrease,
Expand All @@ -34,7 +38,19 @@ export default function ResultRow({
<span className="result-row__number">{number}</span>

<div className="result-row__info">
<span className="result-row__name">{name}</span>
{/* Vis lenke dersom produktet har en detaljside. */}
{to ? (
<Link
to={to}
className="result-row__name result-row__link"
>
{name}
</Link>
) : (
<span className="result-row__name">{name}</span>
)}

{/* Behold eksisterende produktinformasjon. */}
{details && <span className="result-row__details">{details}</span>}
</div>

Expand Down
4 changes: 3 additions & 1 deletion frontend/src/pages/SearchResults/SearchProductList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export default function SearchProductList({
return (
<ResultRow
key={product.ean}
to={`/product/${encodeURIComponent(product.ean)}`}
number={String(startIndex + index + 1).padStart(3, "0")}
name={product.name}
details={product.brand ?? undefined}
Expand All @@ -93,7 +94,8 @@ export default function SearchProductList({
displayPrice.storeCode)
: undefined
}
onAdd={onAddProduct ? () => onAddProduct(product) : undefined}
onAdd={onAddProduct ? () => onAddProduct(product) : undefined
}
/>
);
})}
Expand Down