Component boundaries, interfaces, services and dependencies for the shell: footer, back-to-top, skip link, status pages, page intro, shared RouterLink, content folder and navigation module. Includes the answered design questions and the revised site content requirement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
80 lines
3.7 KiB
Markdown
80 lines
3.7 KiB
Markdown
# Component Methods and Interfaces — frontend-shell
|
|
|
|
Signatures are TypeScript sketches; exact typing is settled in Code Generation. Behaviour rules (thresholds, copy, edge cases) are detailed in Functional Design.
|
|
|
|
## Content types — `content/types.ts`
|
|
|
|
```ts
|
|
import type { SocialPlatform } from './socialPlatforms';
|
|
|
|
export interface SocialLink {
|
|
platform: SocialPlatform;
|
|
href: string; // leeg = niet tonen
|
|
}
|
|
|
|
export interface SiteContent {
|
|
footerIntro: string;
|
|
socials: SocialLink[];
|
|
email: string;
|
|
}
|
|
|
|
export interface HeroSlide { id: string; src: string; alt: string }
|
|
export interface HeroCta { label: string; to: string }
|
|
export interface HeroContent {
|
|
title: string;
|
|
tagline: string;
|
|
cta: HeroCta;
|
|
slides: HeroSlide[];
|
|
// socials verhuist naar SiteContent
|
|
}
|
|
```
|
|
|
|
## Navigation — `navigation.ts`
|
|
|
|
```ts
|
|
// Typed on registered routes, so a typo in `to` is a type error
|
|
type NavItem = { to: '/' | '/over-mij' | ...; label: string };
|
|
|
|
export const mainNav: readonly NavItem[];
|
|
export const footerNav: readonly NavItem[];
|
|
```
|
|
|
|
## Components
|
|
|
|
| Component | Props | Notes |
|
|
|---|---|---|
|
|
| `AppShell` | none | Composes SkipNavLink, NavigationBar, main, Footer, BackToTop |
|
|
| `NavigationBar` | none | Reads `mainNav`; logo `RouterLink to="/"` |
|
|
| `NavLink` | `ComponentProps<typeof RouterLink>` | Unchanged API |
|
|
| `MobileNav` | `{ id: string; open: boolean; onClose: () => void }` | Unchanged API |
|
|
| `Footer` | `{ content: SiteContent }` | |
|
|
| `FooterColumn` (local) | `{ title: string; children: ReactNode }` | Eyebrow heading + vertical list |
|
|
| `BackToTop` | none | |
|
|
| `PageIntro` | `{ title: string; eyebrow?: string; children?: ReactNode }` | Exactly one `h1` |
|
|
| `StatusPage` | `{ title: string; children: ReactNode; action?: { label: string; to: string } }` | Default action: "Terug naar home" → `/` |
|
|
| `NotFound` | `NotFoundRouteProps` (ignored) | Router `notFoundComponent` |
|
|
| `ErrorPage` | `ErrorComponentProps` (`error`, `reset`) | Never renders `error`; logs it |
|
|
| `Hero` | `{ content: HeroContent; socials: SocialLink[] }` | `socials` split off |
|
|
| `HeroSocials` | `{ socials: SocialLink[] }` | Type renamed from `HeroSocial` |
|
|
| `HeroArrows` | `{ onPrev: () => void; onNext: () => void }` | Unchanged API |
|
|
| `LinkButton` | `ComponentProps<typeof RouterLink> & RecipeVariantProps<linkButton>` | Unchanged API |
|
|
| `RouterLink` | `ComponentProps<typeof chakra(Link)>` | `export const RouterLink = chakra(Link)` |
|
|
|
|
## Hooks and helpers
|
|
|
|
| Name | Signature | Purpose |
|
|
|---|---|---|
|
|
| `useScrolledPast` (existing) | `(getThreshold: () => number) => boolean` | Reused by BackToTop; threshold function defined at module level so it is referentially stable |
|
|
| `backToTopThreshold` (new, pure) | `(viewportHeight: number) => number` | 60% of viewport height; pure for property-based testing |
|
|
| `visibleSocials` (new, pure) | `(socials: SocialLink[]) => SocialLink[]` | Drops entries with empty `href`; shared by HeroSocials and Footer (today's filter in HeroSocials is lifted out) |
|
|
| `copyrightLine` (new, pure) | `(year: number) => string` | `"© {year} Andrea Slop Fotografie"` |
|
|
| `pageHead` (existing) | `({ title, description }) => HeadOption` | Used by the new routes |
|
|
|
|
## Theme additions
|
|
|
|
| Key | Kind | Definition (summary) |
|
|
|---|---|---|
|
|
| `link.variants.variant.subtle` | Recipe variant (extends Chakra built-in `link`) | `color: ink.soft`, `textDecoration: none`, `_hover/_focusVisible: { color: accent.deep }`, transition tokens |
|
|
| `skipNavLink` | Recipe override (Chakra built-in) | `bg: ink`, `color: white`, `rounded: none`, design padding, `textStyle: eyebrow` |
|
|
| `iconControl` | New recipe | `opacity: 0.6`, `_hover/_focusVisible: { opacity: 1 }`, `interaction`/`smooth` transitions |
|