chore: initialize from frontend template 4dc033c

This commit is contained in:
DongHyeonka
2026-08-13 18:23:26 +09:00
commit 40107eec84
897 changed files with 234824 additions and 0 deletions
@@ -0,0 +1,165 @@
import { useId, type ReactNode } from "react";
import type { AsyncState } from "../../application/view-models/async-state.ts";
import type { AppFailure } from "../../contracts/errors.ts";
import { useLocale } from "../i18n/index.ts";
import { errorMessage } from "./error-copy.ts";
import { Button } from "./ui/button.ts";
export function LoadingSurface({ label }: Readonly<{ label?: string }>) {
const { message } = useLocale();
const accessibleLabel = label ?? message("async.loading");
return (
<section
className="state-surface state-surface--loading"
aria-busy="true"
aria-label={accessibleLabel}
aria-live="polite"
aria-atomic="true"
>
<div className="ui-skeleton" aria-hidden="true" />
<span className="visually-hidden">{accessibleLabel}</span>
</section>
);
}
export type EmptySurfaceProps = Readonly<{
title?: string;
description?: string;
action?: ReactNode;
}>;
export function EmptySurface({
title,
description,
action,
}: EmptySurfaceProps) {
const { message } = useLocale();
return (
<section className="ui-empty state-surface" aria-live="polite">
<h2>{title ?? message("async.empty")}</h2>
{description ? <p>{description}</p> : null}
{action}
</section>
);
}
export type TerminalErrorSurfaceProps = Readonly<{
userMessageKey: string;
action: AppFailure["action"];
onAction?: () => void;
}>;
export function TerminalErrorSurface({
userMessageKey,
action,
onAction,
}: TerminalErrorSurfaceProps) {
const { locale, message } = useLocale();
const messageId = useId();
const actionLabels: Readonly<
Record<Exclude<AppFailure["action"], "none">, string>
> = Object.freeze({
retry: message("action.retry"),
reauth: message("action.reauth"),
navigate: message("action.navigateSafe"),
"reload-once": message("action.reloadOnce"),
"contact-support": message("action.contactSupport"),
});
return (
<section
className="ui-terminal-error state-surface state-surface--danger"
role="alert"
aria-labelledby={messageId}
data-message-key={userMessageKey}
>
<h2 id={messageId}>{errorMessage(userMessageKey, locale)}</h2>
{action !== "none" && onAction && (
<Button onClick={onAction}>{actionLabels[action]}</Button>
)}
</section>
);
}
export type AsyncSurfaceProps = Readonly<{
state: AsyncState;
children?: ReactNode;
onAction?: () => void;
onRetry?: () => void;
onResolveConflict?: () => void;
onReconcileUnknownEffect?: (
resolution: "APPLIED" | "NOT_APPLIED",
) => void;
}>;
export function AsyncSurface({
state,
children,
onAction,
onRetry,
onResolveConflict,
onReconcileUnknownEffect,
}: AsyncSurfaceProps) {
const { message } = useLocale();
if (state.base === "initial-loading") return <LoadingSurface />;
if (state.base === "empty") return <EmptySurface />;
if (state.base === "terminal-error" && state.failure) {
return (
<TerminalErrorSurface
userMessageKey={state.failure.userMessageKey}
action={state.failure.action}
onAction={
state.failure.action === "retry"
? onRetry ?? onAction
: onAction
}
/>
);
}
return (
<section aria-busy={state.overlay.refreshing || state.overlay.mutationPending}>
{state.indicator ? (
<div role="status" aria-live="polite">
<span>
{message(
state.indicator === "stale-degraded"
? "async.staleDegraded"
: state.indicator === "mutation-effect-unknown"
? "async.mutationEffectUnknown"
: state.indicator === "mutation-conflict"
? "async.mutationConflict"
: state.indicator === "mutation-pending"
? "async.mutationPending"
: "async.refreshing",
)}
</span>
{state.indicator === "stale-degraded" && onRetry ? (
<Button onClick={onRetry}>{message("action.retry")}</Button>
) : null}
{state.indicator === "mutation-conflict" && onResolveConflict ? (
<Button onClick={onResolveConflict}>
{message("action.resolveConflict")}
</Button>
) : null}
{state.indicator === "mutation-effect-unknown" &&
onReconcileUnknownEffect ? (
<>
<Button
onClick={() => onReconcileUnknownEffect("APPLIED")}
>
{message("action.confirmMutationApplied")}
</Button>
<Button
onClick={() => onReconcileUnknownEffect("NOT_APPLIED")}
>
{message("action.confirmMutationNotApplied")}
</Button>
</>
) : null}
</div>
) : null}
{children}
</section>
);
}
@@ -0,0 +1,8 @@
import { resolveMessage } from "../i18n/index.ts";
export function errorMessage(
messageKey: string,
locale: string = "ko-KR",
): string {
return resolveMessage(locale, messageKey);
}
@@ -0,0 +1,40 @@
import { useEffect, useRef } from "react";
export type PageHeaderProps = Readonly<{
title: string;
description?: string;
eyebrow?: string;
}>;
export function PageHeader({
title,
description,
eyebrow,
}: PageHeaderProps) {
const headingRef = useRef<HTMLHeadingElement | null>(null);
useEffect(() => {
const activeElement = document.activeElement;
const main = document.getElementById("main-content");
const routeOwnsFocus =
activeElement === null ||
activeElement === document.body ||
activeElement === document.documentElement ||
activeElement === main;
if (routeOwnsFocus) {
headingRef.current?.focus();
}
}, [title]);
return (
<header className="page-header">
{eyebrow ? <p className="page-header__eyebrow">{eyebrow}</p> : null}
<h1 ref={headingRef} tabIndex={-1} data-route-heading>
{title}
</h1>
{description ? (
<p className="page-header__description">{description}</p>
) : null}
</header>
);
}
@@ -0,0 +1,75 @@
import { useLocale } from "../i18n/index.ts";
import { Button } from "./ui/button.ts";
type StateSurfaceProps = Readonly<{
eyebrow: string;
title: string;
description: string;
actionLabel?: string;
onAction?: () => void;
tone?: "neutral" | "danger" | "warning";
}>;
function StateSurface({
eyebrow,
title,
description,
actionLabel,
onAction,
tone = "neutral",
}: StateSurfaceProps) {
return (
<section className={`state-surface state-surface--${tone}`}>
<p className="state-surface__eyebrow">{eyebrow}</p>
<h2>{title}</h2>
<p>{description}</p>
{actionLabel ? <Button onClick={onAction}>{actionLabel}</Button> : null}
</section>
);
}
export function AuthRequiredSurface({
onSignIn,
}: Readonly<{ onSignIn?: () => void }>) {
const { message } = useLocale();
return (
<StateSurface
eyebrow={message("access.auth.eyebrow")}
title={message("access.auth.title")}
description={message("access.auth.description")}
actionLabel={message("action.signIn")}
onAction={onSignIn}
/>
);
}
export function ForbiddenSurface({
onNavigate,
}: Readonly<{ onNavigate?: () => void }>) {
const { message } = useLocale();
return (
<StateSurface
eyebrow={message("access.forbidden.eyebrow")}
title={message("access.forbidden.title")}
description={message("access.forbidden.description")}
actionLabel={message("action.navigateSafe")}
onAction={onNavigate}
tone="warning"
/>
);
}
export function NotFoundSurface({
onNavigate,
}: Readonly<{ onNavigate?: () => void }>) {
const { message } = useLocale();
return (
<StateSurface
eyebrow={message("access.notFound.eyebrow")}
title={message("access.notFound.title")}
description={message("access.notFound.description")}
actionLabel={message("action.goHome")}
onAction={onNavigate}
/>
);
}
+1
View File
@@ -0,0 +1 @@
export { Alert, type AlertProps } from "../../design-system/primitives/core.tsx";
+1
View File
@@ -0,0 +1 @@
export { Badge, type BadgeProps } from "../../design-system/primitives/core.tsx";
+6
View File
@@ -0,0 +1,6 @@
export {
Button,
type ButtonProps,
type ButtonSize,
type ButtonVariant,
} from "../../design-system/primitives/core.tsx";
+1
View File
@@ -0,0 +1 @@
export { Card, type CardProps } from "../../design-system/primitives/core.tsx";
+1
View File
@@ -0,0 +1 @@
export { Dialog, type DialogProps } from "../../design-system/primitives/core.tsx";
@@ -0,0 +1,4 @@
export {
TextField,
type TextFieldProps,
} from "../../design-system/primitives/core.tsx";