Carries the 11 page drafts plus the shared SiteNav and SiteFooter onto the project's own design system: tier-2 tokens, the published type roles, logical properties throughout, and both locales. Surfaces - The page stands on #0B0B0A with #1D1D1B bands lifted off it, as the drafts do; the body previously painted the band colour, so every band was a step too light. - A card is drawn one step off whatever it stands on (#1D1D1B on the ground, #141413 inside a band). Components paint --surface-card and a band re-points it for its subtree, so a card can never come out the same colour as its band. Shell - Nav: translucent ground with a blur, chevrons on group triggers, an accent rule under the current section, the drafts' compact dropdown card, and an EN | AR toggle in place of the globe menu. - Footer: the drafts' four-column grid, one-line brand text, Facebook as a bordered button, the EU lockup, the implemented-by row and the funding disclaimer. Pages - Home: hero with counting figures, launch band, three areas of change, newsroom, FAQ accordion and the consortium band. - The nine interior pages rebuilt and then audited section by section against their drafts. - Applications: the three-step application form now posts real submissions to the Strapi `application` type, validated server-side and working without JavaScript. Motion - Every animation in the drafts, as classes in _page-kit/motion.css: staggered entrances, scroll-driven reveals, the drifting washes (each page carries its own geometry), the sheen, the counting figures and the accordion. The drafts' coloured hover glow is deliberately not shipped. CMS - New `faq` collection type behind the home page's accordion. - `role` added to the consortium member component so an editor can supply the chip and the deliverable separately. Content - No invented figure, date, name or commitment ships: the five-working-day reply, the placeholder email and Facebook handle, the sample news, events, publications and FAQs, the invented application rules and the TBD counters are all withheld pending real content. Figures that survived (3 consortium partners, 4 areas of work, 16 human security sub-projects, Dec 2025 - Dec 2027) are verified against docs/ and the bundled draft copy. Verified: pnpm typecheck (web + CMS) and pnpm --filter web build pass; all 20 page/locale URLs render 200 through the built SSR handler, including with the CMS unreachable; no raw hex or physical-direction utility in components or routes. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
117 lines
4.1 KiB
TypeScript
117 lines
4.1 KiB
TypeScript
import { Link } from "react-router";
|
|
|
|
import {
|
|
getCounterpartLocale,
|
|
getCounterpartPath,
|
|
getDirection,
|
|
LOCALE_ENDONYM,
|
|
LOCALE_SHORT_LABEL,
|
|
type Locale,
|
|
} from "./locale-path";
|
|
|
|
/* Reinforces the global :focus-visible rule in app.css with the same tier-2
|
|
focus tokens, so the ring is visible even if a caller overrides `outline`. */
|
|
const FOCUS_RING =
|
|
"focus-visible:outline-[color:var(--focus-ring-color)] " +
|
|
"focus-visible:outline-[length:var(--focus-ring-width)] " +
|
|
"focus-visible:outline-offset-[var(--focus-ring-offset)]";
|
|
|
|
/** Padding presets. Kept as a prop rather than an overridable class, because
|
|
two padding utilities on one element are resolved by the order Tailwind
|
|
emits them in, not by the order they appear in the class attribute. */
|
|
const SIZE_CLASSES = {
|
|
sm: "px-sm py-2xs",
|
|
md: "min-h-[44px] px-md py-xs",
|
|
} as const;
|
|
|
|
export type LanguageSwitcherSize = keyof typeof SIZE_CLASSES;
|
|
|
|
export interface LanguageSwitcherProps {
|
|
/** The locale the reader is currently on. */
|
|
locale: Locale;
|
|
/** Current pathname, e.g. "/en/news-and-updates". */
|
|
pathname: string;
|
|
/** Query string to carry across the switch. Usually `location.search`. */
|
|
search?: string;
|
|
/** Fragment to carry across the switch. Usually `location.hash`. */
|
|
hash?: string;
|
|
/**
|
|
* Navigate with a full document request instead of a client transition.
|
|
* Off by default: the root route re-renders <html lang>/<html dir> on a
|
|
* client navigation, so a soft transition already lands on a correct
|
|
* document. Turn it on if a page needs the server to re-render first.
|
|
*/
|
|
reloadDocument?: boolean;
|
|
/** "sm" for a compact pill, "md" for a 44px touch target in the drawer. */
|
|
size?: LanguageSwitcherSize;
|
|
className?: string;
|
|
}
|
|
|
|
/**
|
|
* Compact language toggle: shows the two-letter code of the OTHER language
|
|
* ("AR" while reading English, "EN" while reading Arabic) and links to the
|
|
* same page under that locale, preserving the rest of the path.
|
|
*
|
|
* The mobile drawer uses this, where a spelled-out target is clearer than an
|
|
* icon. The desktop bar uses <LanguageMenu />, the globe with a dropdown.
|
|
*/
|
|
export function LanguageSwitcher({
|
|
locale,
|
|
pathname,
|
|
search,
|
|
hash,
|
|
reloadDocument = false,
|
|
size = "sm",
|
|
className = "",
|
|
}: LanguageSwitcherProps) {
|
|
const target = getCounterpartLocale(locale);
|
|
const href = getCounterpartPath(pathname, locale, { search, hash });
|
|
|
|
return (
|
|
<Link
|
|
to={href}
|
|
reloadDocument={reloadDocument}
|
|
hrefLang={target}
|
|
lang={target}
|
|
dir={getDirection(target)}
|
|
aria-label={LOCALE_ENDONYM[target]}
|
|
title={LOCALE_ENDONYM[target]}
|
|
data-language-switcher={target}
|
|
className={[
|
|
"label-md inline-flex shrink-0 items-center justify-center rounded-pill",
|
|
"border border-[var(--border-default)]",
|
|
SIZE_CLASSES[size],
|
|
"text-[var(--text-primary)] no-underline",
|
|
"transition-colors duration-[var(--motion-duration-fast)]",
|
|
"ease-[var(--motion-ease-standard)]",
|
|
"hover:border-[var(--border-strong)] hover:bg-[var(--surface-muted)]",
|
|
FOCUS_RING,
|
|
className,
|
|
]
|
|
.filter(Boolean)
|
|
.join(" ")}
|
|
>
|
|
<span aria-hidden="true">{LOCALE_SHORT_LABEL[target]}</span>
|
|
</Link>
|
|
);
|
|
}
|
|
|
|
export default LanguageSwitcher;
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
USAGE
|
|
---------------------------------------------------------------------------
|
|
// Reading English at /en/news-and-updates?page=2 -> links to
|
|
// /ar/news-and-updates?page=2 and renders the pill "AR".
|
|
<LanguageSwitcher locale="en" pathname="/en/news-and-updates" search="?page=2" />
|
|
|
|
// Reading Arabic -> renders "EN", links to /en/...
|
|
<LanguageSwitcher locale="ar" pathname="/ar/contact" />
|
|
|
|
// Inside the mobile drawer, where a 44px touch target is wanted:
|
|
<LanguageSwitcher locale={locale} pathname={pathname} size="md" />
|
|
|
|
// Force a document navigation (server re-renders <html lang>/<html dir>):
|
|
<LanguageSwitcher locale={locale} pathname={pathname} reloadDocument />
|
|
------------------------------------------------------------------------ */
|