Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 | 11x 11x 11x 172x 59x 59x 59x 96x 96x 96x 96x 96x 288x 179x 179x 179x 169x 96x 73x 73x 73x 73x 169x 10x 63x 10x 4x 6x 179x 179x 179x 179x 126x 20x 20x 11x 20x 179x 49x 39x 179x 179x 179x 179x 179x 179x | "use client";
/**
* WalletFlow — a generic animated phone mock-up that auto-cycles a list of
* `WalletStep`s. Extracted from the old WalletSimulation so register / returning-login /
* EHR-transfer flows share one phone frame (see ui/src/components/wallet/flows.tsx).
* Illustrative only; synthetic data. See docs/planning/eudi-wallet-flows-2026.md.
*
* Two looks. `theme="dyou"` draws the chrome of the German national EUDI wallet,
* d-you, as its published source renders it (2026-09-16 mirror, logic-ui design
* system, checked against the app on the simulator): white surface, a header
* with a back arrow and a close cross (`HeaderContentView`), the secondary and
* the primary button side by side (`DSSecondaryButton` outlined,
* `DSPrimaryButton` in the mint `primaryContainer` #96F5AF with dark text), and
* on the dashboard the tab bar (Overview · Activity · Settings) with the round
* scanner button. The licensed EUDI Diatype typeface is not in the mirror, so
* the real app falls back to the system font, and so does this. The classic
* theme keeps the generic phone with a brand chip, used for the insurer's app.
*/
import { useEffect, useState } from "react";
import {
Wifi,
BatteryFull,
SignalHigh,
ArrowLeft,
X,
LayoutGrid,
History,
Settings,
ScanLine,
} from "lucide-react";
import { useT } from "@/lib/i18n/translate";
export interface WalletStep {
/** the step's body content */
body: React.ReactNode;
/** primary button label */
primary: string;
/** secondary button label (d-you: shown beside the primary; classic: Cancel) */
secondary?: string;
/** dwell time in ms before advancing */
ms: number;
/** progress-bar + button-ring accent (default EUDI purple) */
accent?: string;
/** in interactive mode, auto-advance this (transitional) step after `ms` — e.g. a spinner */
auto?: boolean;
/**
* d-you only. "flow": a screen in a flow (header, buttons at the bottom).
* "dashboard": the wallet's start screen with the tab bar; the scanner
* button is the primary action. "final": a result screen with one button.
*/
layout?: "flow" | "dashboard" | "final";
/** d-you only: which icons the header shows (default back and close) */
header?: "close" | "back-close" | "none";
}
export interface BrandChip {
name: string;
color: string;
}
export type WalletTheme = "classic" | "dyou";
const DEFAULT_ACCENT = "#5b3df5";
/** The d-you palette, from logic-ui `Colors.swift` (light scheme). */
export const DYOU = {
surface: "#FFFFFF",
onSurface: "#1D1D1E",
onSurfaceVariant: "#49454F",
surfaceContainer: "#F4F4F4",
surfaceContainerHighest: "#DEDEDE",
outlineVariant: "#B9B9BD",
primaryContainer: "#96F5AF",
primaryOutline: "#329D77",
onSuccess: "#0C4A37",
pid: "#02818B",
} as const;
function StatusBar() {
return (
<div className="flex items-center justify-between px-4 pt-2 pb-1 text-[10px] font-semibold text-gray-800">
<span>10:55</span>
<div className="flex items-center gap-1">
<SignalHigh size={11} />
<Wifi size={11} />
<BatteryFull size={13} />
</div>
</div>
);
}
/** d-you's `HeaderContentView`: an optional back arrow on the left, the close cross on the right. */
function DyouHeader({
variant,
interactive,
onCancel,
}: {
variant: "close" | "back-close";
interactive: boolean;
onCancel?: () => void;
}) {
const t = useT("patient");
const close = interactive ? (
<button
type="button"
onClick={onCancel}
aria-label={t("Dismiss request")}
className="p-1 rounded-full hover:bg-gray-100"
style={{ color: DYOU.onSurface }}
>
<X size={18} strokeWidth={1.75} />
</button>
) : (
<span className="p-1" style={{ color: DYOU.onSurface }}>
<X size={18} strokeWidth={1.75} />
</span>
);
return (
<div className="flex items-center justify-between px-4 pt-1 pb-2">
<span
className="p-1"
style={{
color: DYOU.onSurface,
visibility: variant === "back-close" ? "visible" : "hidden",
}}
aria-hidden="true"
>
<ArrowLeft size={18} strokeWidth={1.75} />
</span>
{close}
</div>
);
}
/** d-you's tab bar (Overview · Activity · Settings) with the round scanner button. */
function DyouTabBar({
primary,
interactive,
onPrimary,
}: {
primary: string;
interactive: boolean;
onPrimary?: () => void;
}) {
const t = useT("patient");
const tabs = [
{ label: "Overview", Icon: LayoutGrid, active: true },
{ label: "Activity", Icon: History, active: false },
{ label: "Settings", Icon: Settings, active: false },
];
const scanner = (
<>
<ScanLine size={18} strokeWidth={1.75} />
<span className="sr-only">{primary}</span>
</>
);
const ring = (
<span
className="absolute inset-0 rounded-full animate-ping pointer-events-none"
style={{ border: `2px solid ${DYOU.primaryOutline}99` }}
/>
);
return (
<div className="flex items-center gap-2 px-3 pb-3 pt-2">
<div
className="flex-1 flex items-center justify-around rounded-full py-1.5 px-1"
style={{ background: DYOU.surfaceContainer }}
>
{tabs.map(({ label, Icon, active }) => (
<span
key={label}
className="flex flex-col items-center gap-0.5 text-[8px] font-semibold px-2 py-1 rounded-full"
style={{
color: DYOU.onSurface,
background: active ? DYOU.surfaceContainerHighest : "transparent",
}}
>
<Icon size={14} strokeWidth={1.75} />
{t(label)}
</span>
))}
</div>
{interactive ? (
<button
type="button"
onClick={onPrimary}
className="relative grid place-items-center w-11 h-11 rounded-full shrink-0 hover:bg-gray-50 active:scale-95 transition-transform"
style={{
background: DYOU.surface,
color: DYOU.onSurface,
border: `1px solid ${DYOU.outlineVariant}`,
}}
>
{scanner}
{ring}
</button>
) : (
<span
className="relative grid place-items-center w-11 h-11 rounded-full shrink-0"
style={{
background: DYOU.surface,
color: DYOU.onSurface,
border: `1px solid ${DYOU.outlineVariant}`,
}}
>
{scanner}
{ring}
</span>
)}
</div>
);
}
function Buttons({
primary,
secondary,
accent,
interactive = false,
atEnd = false,
theme = "classic",
layout = "flow",
onPrimary,
onCancel,
}: {
primary: string;
secondary?: string;
accent: string;
interactive?: boolean;
atEnd?: boolean;
theme?: WalletTheme;
layout?: "flow" | "dashboard" | "final";
onPrimary?: () => void;
onCancel?: () => void;
}) {
const t = useT("patient");
const tc = useT("common");
if (theme === "dyou") {
if (layout === "dashboard") {
return (
<DyouTabBar
primary={primary}
interactive={interactive}
onPrimary={onPrimary}
/>
);
}
// DSPrimaryButton (mint, dark text) and DSSecondaryButton (outlined) side
// by side, as the request and consent screens lay them out; a result
// screen has the primary alone.
const primaryStyle = {
background: DYOU.primaryContainer,
color: DYOU.onSurface,
};
const secondaryStyle = {
background: DYOU.surface,
color: DYOU.onSurface,
border: `1.5px solid ${DYOU.onSurface}`,
};
const ring = (
<span
className="absolute inset-0 rounded-full animate-ping pointer-events-none"
style={{ border: `2px solid ${DYOU.primaryOutline}99` }}
/>
);
const withSecondary = layout !== "final" && Boolean(secondary);
if (!interactive) {
return (
<div className="flex gap-2 px-3 pb-3 pt-2">
{withSecondary && (
<div
className="flex-1 text-center rounded-full text-[12px] font-semibold py-2.5"
style={secondaryStyle}
>
{secondary}
</div>
)}
<div
className="flex-1 text-center rounded-full text-[12px] font-semibold py-2.5 relative"
style={primaryStyle}
>
{primary}
{ring}
</div>
</div>
);
}
return (
<div className="flex gap-2 px-3 pb-3 pt-2">
{withSecondary && (
<button
type="button"
onClick={onCancel}
className="flex-1 rounded-full text-[12px] font-semibold py-2.5 hover:bg-gray-50 transition-colors"
style={secondaryStyle}
>
{secondary}
</button>
)}
<button
type="button"
onClick={onPrimary}
className="flex-1 rounded-full text-[12px] font-semibold py-2.5 relative transition-transform active:scale-95 hover:brightness-95"
style={primaryStyle}
>
{primary}
{ring}
</button>
</div>
);
}
// Presentation mode: decorative, non-clickable (unchanged).
if (!interactive) {
return (
<div className="flex gap-2 px-3 pb-3 pt-2">
<div className="flex-1 text-center rounded-xl bg-gray-100 text-gray-600 text-sm font-semibold py-2.5">
{t("Stop")}
</div>
<div className="flex-1 text-center rounded-xl bg-gray-900 text-white text-sm font-semibold py-2.5 relative">
{primary}
<span
className="absolute inset-0 rounded-xl animate-ping"
style={{ border: `2px solid ${accent}99` }}
/>
</div>
</div>
);
}
// Interactive mode: the user drives the approval with real buttons.
return (
<div className="flex gap-2 px-3 pb-3 pt-2">
<button
type="button"
onClick={onCancel}
className="flex-1 rounded-xl bg-gray-100 text-gray-600 text-sm font-semibold py-2.5 hover:bg-gray-200 transition-colors"
>
{atEnd ? tc("Close") : t("Cancel")}
</button>
<button
type="button"
onClick={onPrimary}
className="flex-1 rounded-xl bg-gray-900 text-white text-sm font-semibold py-2.5 relative hover:bg-black transition-colors active:scale-95"
>
{primary}
<span
className="absolute inset-0 rounded-xl animate-ping pointer-events-none"
style={{ border: `2px solid ${accent}99` }}
/>
</button>
</div>
);
}
export function WalletFlow({
steps,
loop = true,
ariaLabel,
brand,
theme = "classic",
interactive = false,
onComplete,
onCancel,
}: {
steps: WalletStep[];
loop?: boolean;
ariaLabel?: string;
brand?: BrandChip;
/** "dyou" draws the German wallet's chrome; "classic" the generic phone with a brand chip */
theme?: WalletTheme;
/** when true, the user advances each step via the primary button; the last
* step's button fires onComplete. Steps flagged `auto` still self-advance. */
interactive?: boolean;
onComplete?: () => void;
onCancel?: () => void;
}) {
const t = useT("patient");
const [step, setStep] = useState(0);
const atEnd = step >= steps.length - 1;
useEffect(() => {
// Interactive steps wait for a click, except transitional `auto` steps.
if (interactive && !steps[step].auto) return;
Iif (atEnd && !loop) return;
const timer = setTimeout(
() => setStep((s) => (s + 1) % steps.length),
steps[step].ms,
);
return () => clearTimeout(timer);
}, [step, steps, loop, interactive, atEnd]);
const onPrimary = () => {
if (atEnd) onComplete?.();
else setStep((s) => s + 1);
};
const current = steps[step];
const accent = current.accent ?? brand?.color ?? DEFAULT_ACCENT;
const dyou = theme === "dyou";
const layout = current.layout ?? "flow";
const header =
current.header ??
(layout === "dashboard" || layout === "final" ? "none" : "back-close");
return (
<div
role="group"
aria-label={ariaLabel}
data-theme={theme}
data-step={step}
className="relative w-[clamp(228px,27vw,268px)] aspect-9/19.5 rounded-[2.6rem] border-[7px] border-gray-900 bg-white shadow-2xl overflow-hidden flex flex-col"
style={dyou ? { color: DYOU.onSurface } : undefined}
>
<style>{`
@keyframes wsimReveal { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.wsim-step { opacity: 0; animation: wsimReveal 0.45s ease forwards; }
`}</style>
{/* Dynamic Island */}
<div className="pointer-events-none absolute top-[7px] left-1/2 -translate-x-1/2 w-[32%] h-[15px] rounded-full bg-gray-900 z-20" />
<StatusBar />
{dyou ? (
header !== "none" && (
<DyouHeader
variant={header}
interactive={interactive}
onCancel={onCancel}
/>
)
) : (
<>
{brand && (
<div className="px-4 pt-0.5 pb-1.5">
<span
className="inline-flex items-center text-[10px] font-bold px-2.5 py-1 rounded-full text-white"
style={{ background: brand.color }}
>
{brand.name}
</span>
</div>
)}
<div className="px-4">
<div className="h-1.5 rounded-full bg-gray-200 overflow-hidden">
<div
className="h-full transition-all duration-500"
style={{
width: `${((step + 1) / steps.length) * 100}%`,
background: accent,
}}
/>
</div>
</div>
</>
)}
<div
key={step}
className="flex-1 min-h-0 overflow-y-auto px-4 pt-3 wsim-step"
>
{current.body}
</div>
<Buttons
primary={t(current.primary)}
secondary={current.secondary && t(current.secondary)}
accent={accent}
interactive={interactive}
atEnd={atEnd}
theme={theme}
layout={layout}
onPrimary={onPrimary}
onCancel={onCancel}
/>
</div>
);
}
|