From 7689ce756403b0655276c27a4ca06cb9f03ae90d Mon Sep 17 00:00:00 2001 From: Oscar Bakkeng Date: Fri, 6 Nov 2026 19:10:59 +0100 Subject: [PATCH 1/4] refactor(ui): share error notice, skeleton and wine list (#26) The search page needs the same parts as the landing page, so they move from the landing feature to components/ui. Co-Authored-By: Claude Opus 5.5 --- .../src/components/ui/ErrorNotice.module.css | 18 ++++++ frontend/src/components/ui/ErrorNotice.tsx | 21 +++++++ .../src/components/ui/Skeleton.module.css | 31 ++++++++++ frontend/src/components/ui/Skeleton.tsx | 13 ++++ frontend/src/components/ui/WineCard.tsx | 2 +- .../src/components/ui/WineList.module.css | 13 ++++ frontend/src/components/ui/WineList.tsx | 24 +++++++ frontend/src/components/ui/index.ts | 3 + .../features/landing/LandingView.module.css | 62 ------------------- frontend/src/features/landing/LandingView.tsx | 35 +++-------- 10 files changed, 133 insertions(+), 89 deletions(-) create mode 100644 frontend/src/components/ui/ErrorNotice.module.css create mode 100644 frontend/src/components/ui/ErrorNotice.tsx create mode 100644 frontend/src/components/ui/Skeleton.module.css create mode 100644 frontend/src/components/ui/Skeleton.tsx create mode 100644 frontend/src/components/ui/WineList.module.css create mode 100644 frontend/src/components/ui/WineList.tsx diff --git a/frontend/src/components/ui/ErrorNotice.module.css b/frontend/src/components/ui/ErrorNotice.module.css new file mode 100644 index 0000000..2fa8492 --- /dev/null +++ b/frontend/src/components/ui/ErrorNotice.module.css @@ -0,0 +1,18 @@ +.notice { + display: grid; + justify-items: start; + gap: var(--space-3); + padding-block: var(--space-5); + border-left: 4px solid var(--color-danger); +} + +.retry { + min-height: var(--tap-target); + padding: 0 var(--space-5); + border: 0; + border-radius: var(--radius-pill); + background: var(--color-brand); + color: var(--color-on-brand); + font-weight: 700; + cursor: pointer; +} diff --git a/frontend/src/components/ui/ErrorNotice.tsx b/frontend/src/components/ui/ErrorNotice.tsx new file mode 100644 index 0000000..26ecc12 --- /dev/null +++ b/frontend/src/components/ui/ErrorNotice.tsx @@ -0,0 +1,21 @@ +import styles from './ErrorNotice.module.css'; + +interface ErrorNoticeProps { + message: string; + onRetry?: () => void; + className?: string; +} + +/** Error message that is announced at once, with a way to try again. */ +export function ErrorNotice({ message, onRetry, className = '' }: ErrorNoticeProps) { + return ( +
+

{message}

+ {onRetry && ( + + )} +
+ ); +} diff --git a/frontend/src/components/ui/Skeleton.module.css b/frontend/src/components/ui/Skeleton.module.css new file mode 100644 index 0000000..f0e50ad --- /dev/null +++ b/frontend/src/components/ui/Skeleton.module.css @@ -0,0 +1,31 @@ +.skeleton { + height: 5.5rem; + border-radius: var(--radius-md); + background: linear-gradient( + 90deg, + var(--color-surface-muted), + var(--color-border), + var(--color-surface-muted) + ); + background-size: 200% 100%; + animation: shimmer 1.4s ease-in-out infinite; +} + +.tall { + height: 10rem; +} + +@keyframes shimmer { + from { + background-position: 100% 0; + } + to { + background-position: -100% 0; + } +} + +@media (prefers-reduced-motion: reduce) { + .skeleton { + animation: none; + } +} diff --git a/frontend/src/components/ui/Skeleton.tsx b/frontend/src/components/ui/Skeleton.tsx new file mode 100644 index 0000000..20bde89 --- /dev/null +++ b/frontend/src/components/ui/Skeleton.tsx @@ -0,0 +1,13 @@ +import gridStyles from './WineList.module.css'; +import styles from './Skeleton.module.css'; + +/** Grey placeholders while data loads. Hidden from screen readers, which get a status text. */ +export function Skeleton({ rows, tall = true }: { rows: number; tall?: boolean }) { + return ( +