feat: 기능 추가 과정중

This commit is contained in:
donghyeon-ka
2026-07-30 15:58:20 +09:00
parent d3ef801fe6
commit 6c52cdb916
648 changed files with 126325 additions and 6680 deletions
@@ -1,11 +1,12 @@
import { useId } from "react";
import { useId, type ReactNode } from "react";
import { errorMessage } from "./error-copy.js";
import { Button } from "./ui/button.jsx";
import { useLocale } from "../i18n/index.js";
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";
/** @param {{ label?: string }} props */
export function LoadingSurface({ label }) {
export function LoadingSurface({ label }: Readonly<{ label?: string }>) {
const { message } = useLocale();
const accessibleLabel = label ?? message("async.loading");
return (
@@ -22,18 +23,17 @@ export function LoadingSurface({ label }) {
);
}
/**
* @param {{
* title?: string,
* description?: string,
* action?: React.ReactNode
* }} props
*/
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">
@@ -44,18 +44,22 @@ export function EmptySurface({
);
}
/**
* @param {{
* userMessageKey: string,
* action: "retry" | "reauth" | "navigate" | "reload-once" |
* "contact-support" | "none",
* onAction?: () => void
* }} props
*/
export function TerminalErrorSurface({ userMessageKey, action, onAction }) {
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 = Object.freeze({
const actionLabels: Readonly<
Record<Exclude<AppFailure["action"], "none">, string>
> = Object.freeze({
retry: message("action.retry"),
reauth: message("action.reauth"),
navigate: message("action.navigateSafe"),
@@ -77,22 +81,21 @@ export function TerminalErrorSurface({ userMessageKey, action, onAction }) {
);
}
/**
* @param {{
* state: ReturnType<typeof import("../../application/view-models/async-state.js").deriveAsyncState>,
* children?: React.ReactNode,
* onAction?: () => void,
* onRetry?: () => void,
* onResolveConflict?: () => void
* }} props
*/
export type AsyncSurfaceProps = Readonly<{
state: AsyncState;
children?: ReactNode;
onAction?: () => void;
onRetry?: () => void;
onResolveConflict?: () => void;
}>;
export function AsyncSurface({
state,
children,
onAction,
onRetry,
onResolveConflict,
}) {
}: AsyncSurfaceProps) {
const { message } = useLocale();
if (state.base === "initial-loading") return <LoadingSurface />;
if (state.base === "empty") return <EmptySurface />;
@@ -101,7 +104,11 @@ export function AsyncSurface({
<TerminalErrorSurface
userMessageKey={state.failure.userMessageKey}
action={state.failure.action}
onAction={onRetry ?? onAction}
onAction={
state.failure.action === "retry"
? onRetry ?? onAction
: onAction
}
/>
);
}
@@ -1,6 +0,0 @@
import { resolveMessage } from "../i18n/index.js";
/** @param {string} messageKey @param {string} [locale] */
export function errorMessage(messageKey, locale = "ko-KR") {
return resolveMessage(locale, messageKey);
}
@@ -0,0 +1,8 @@
import { resolveMessage } from "../i18n/index.ts";
export function errorMessage(
messageKey: string,
locale: string = "ko-KR",
): string {
return resolveMessage(locale, messageKey);
}
@@ -1,26 +0,0 @@
import { useEffect, useRef } from "react";
/**
* @param {{
* title: string,
* description?: string,
* eyebrow?: string
* }} props
*/
export function PageHeader({ title, description, eyebrow }) {
const headingRef = useRef(/** @type {HTMLHeadingElement | null} */ (null));
useEffect(() => {
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,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>
);
}
@@ -1,16 +1,15 @@
import { Button } from "./ui/button.jsx";
import { useLocale } from "../i18n/index.js";
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";
}>;
/**
* @param {{
* eyebrow: string,
* title: string,
* description: string,
* actionLabel?: string,
* onAction?: () => void,
* tone?: "neutral" | "danger" | "warning"
* }} props
*/
function StateSurface({
eyebrow,
title,
@@ -18,7 +17,7 @@ function StateSurface({
actionLabel,
onAction,
tone = "neutral",
}) {
}: StateSurfaceProps) {
return (
<section className={`state-surface state-surface--${tone}`}>
<p className="state-surface__eyebrow">{eyebrow}</p>
@@ -29,8 +28,9 @@ function StateSurface({
);
}
/** @param {{ onSignIn?: () => void }} props */
export function AuthRequiredSurface({ onSignIn }) {
export function AuthRequiredSurface({
onSignIn,
}: Readonly<{ onSignIn?: () => void }>) {
const { message } = useLocale();
return (
<StateSurface
@@ -43,8 +43,9 @@ export function AuthRequiredSurface({ onSignIn }) {
);
}
/** @param {{ onNavigate?: () => void }} props */
export function ForbiddenSurface({ onNavigate }) {
export function ForbiddenSurface({
onNavigate,
}: Readonly<{ onNavigate?: () => void }>) {
const { message } = useLocale();
return (
<StateSurface
@@ -58,8 +59,9 @@ export function ForbiddenSurface({ onNavigate }) {
);
}
/** @param {{ onNavigate?: () => void }} props */
export function NotFoundSurface({ onNavigate }) {
export function NotFoundSurface({
onNavigate,
}: Readonly<{ onNavigate?: () => void }>) {
const { message } = useLocale();
return (
<StateSurface
-1
View File
@@ -1 +0,0 @@
export { Alert } from "../../design-system/primitives/core.js";
+1
View File
@@ -0,0 +1 @@
export { Alert, type AlertProps } from "../../design-system/primitives/core.tsx";
-1
View File
@@ -1 +0,0 @@
export { Badge } from "../../design-system/primitives/core.js";
+1
View File
@@ -0,0 +1 @@
export { Badge, type BadgeProps } from "../../design-system/primitives/core.tsx";
@@ -1 +0,0 @@
export { Button } from "../../design-system/primitives/core.js";
+6
View File
@@ -0,0 +1,6 @@
export {
Button,
type ButtonProps,
type ButtonSize,
type ButtonVariant,
} from "../../design-system/primitives/core.tsx";
-1
View File
@@ -1 +0,0 @@
export { Card } from "../../design-system/primitives/core.js";
+1
View File
@@ -0,0 +1 @@
export { Card, type CardProps } from "../../design-system/primitives/core.tsx";
@@ -1 +0,0 @@
export { Dialog } from "../../design-system/primitives/core.js";
+1
View File
@@ -0,0 +1 @@
export { Dialog, type DialogProps } from "../../design-system/primitives/core.tsx";
@@ -1 +0,0 @@
export { TextField } from "../../design-system/primitives/core.js";
@@ -0,0 +1,4 @@
export {
TextField,
type TextFieldProps,
} from "../../design-system/primitives/core.tsx";