import { type ReactNode } from 'react';
import { TrkSectionHeader, Trk } from '../lib/Trk';
import { Badge } from '@shared/components/ui/badge';
import type { BadgeIntent } from '@lib/theme/variants';
import { CATALOG_REGISTRY, type CatalogEntry } from '@shared/constants/catalogRegistry';
/**
* 카탈로그 섹션 — `CATALOG_REGISTRY`를 자동 열거.
* 새 카탈로그 추가는 `catalogRegistry.ts`에 한 줄 추가하면 끝.
* 여기는 렌더링 로직만 담당.
*/
interface AnyMeta {
code: string;
intent?: BadgeIntent;
fallback?: { ko: string; en: string };
classes?: string | { bg?: string; text?: string; border?: string };
label?: string;
}
function getKoLabel(meta: AnyMeta): string {
return meta.fallback?.ko ?? meta.label ?? meta.code;
}
function getEnLabel(meta: AnyMeta): string | undefined {
return meta.fallback?.en;
}
function getFallbackClasses(meta: AnyMeta): string | undefined {
if (typeof meta.classes === 'string') return meta.classes;
if (typeof meta.classes === 'object' && meta.classes) {
return [meta.classes.bg, meta.classes.text, meta.classes.border].filter(Boolean).join(' ');
}
return undefined;
}
function renderBadge(meta: AnyMeta, label: string): ReactNode {
if (meta.intent) {
return (
{meta.code}
페이지에서 배지를 렌더할 때는 반드시 카탈로그 API를 사용한다 (라벨/intent/색상 단일 관리):
{`import { getAlertLevelIntent, getAlertLevelLabel } from '@shared/constants/alertLevels';
{getAlertLevelLabel(event.level, t, lang)}
`}
새 카탈로그 추가: shared/constants/catalogRegistry.ts에
항목을 추가하면 이 쇼케이스에 자동 노출됩니다.
{entry.showcaseId}
{entry.description}
{entry.source && (출처: {entry.source}
)}