- cn() 유틸 신규 (clsx + tailwind-merge, 시맨틱 토큰 classGroup 등록) - theme.css @layer utilities로 직접 정의 (Tailwind v4 복합 이름 매핑 실패 대응): text-heading/label/hint/on-vivid/on-bright, bg-surface-raised/overlay - badgeVariants (CVA) 재구축: 8 intent x 4 size, rem 기반, !important 제거 - Badge 컴포넌트가 cn(badgeVariants, className)로 override 허용 - DataTable width 의미 변경: 고정 -> 선호 최소 너비 (minWidth), truncate + title 툴팁 - dateFormat.ts sv-SE 로케일로 YYYY-MM-DD HH:mm:ss 일관된 KST 출력 - ColorPicker 신규 (팔레트 + native color + hex 입력) - shared/constants/ 19개 카탈로그: violation/alert/event/enforcement/patrol/ engine/userRole/device/parentResolution/modelDeployment/gearGroup/darkVessel/ httpStatus/userAccount/loginResult/permission/vesselAnalysis/connection/trainingZone + kpiUiMap. 백엔드 enum/code_master 기반 SSOT - i18n ko/en common.json에 카테고리 섹션 추가 - adminApi.fetchRoles()가 updateRoleColorCache 자동 호출 - 공통 컴포넌트 (ExcelExport/NotificationBanner/Pagination/SaveButton) 시맨틱 토큰 적용
53 lines
1.4 KiB
TypeScript
53 lines
1.4 KiB
TypeScript
/**
|
|
* 데이터 연결/신호 상태 카탈로그
|
|
*
|
|
* 사용처: DataHub signal heatmap
|
|
*/
|
|
|
|
import type { BadgeIntent } from '@lib/theme/variants';
|
|
|
|
export type ConnectionStatus = 'OK' | 'WARNING' | 'ERROR';
|
|
|
|
export const CONNECTION_STATUSES: Record<ConnectionStatus, { i18nKey: string; fallback: { ko: string; en: string }; intent: BadgeIntent; hex: string }> = {
|
|
OK: {
|
|
i18nKey: 'connectionStatus.OK',
|
|
fallback: { ko: '정상', en: 'OK' },
|
|
intent: 'success',
|
|
hex: '#22c55e',
|
|
},
|
|
WARNING: {
|
|
i18nKey: 'connectionStatus.WARNING',
|
|
fallback: { ko: '경고', en: 'Warning' },
|
|
intent: 'warning',
|
|
hex: '#eab308',
|
|
},
|
|
ERROR: {
|
|
i18nKey: 'connectionStatus.ERROR',
|
|
fallback: { ko: '오류', en: 'Error' },
|
|
intent: 'critical',
|
|
hex: '#ef4444',
|
|
},
|
|
};
|
|
|
|
/** 소문자 호환 (DataHub 'ok' | 'warn' | 'error') */
|
|
const LEGACY: Record<string, ConnectionStatus> = {
|
|
ok: 'OK',
|
|
warn: 'WARNING',
|
|
warning: 'WARNING',
|
|
error: 'ERROR',
|
|
};
|
|
|
|
export function getConnectionStatusMeta(s: string) {
|
|
if (CONNECTION_STATUSES[s as ConnectionStatus]) return CONNECTION_STATUSES[s as ConnectionStatus];
|
|
const code = LEGACY[s.toLowerCase()];
|
|
return code ? CONNECTION_STATUSES[code] : CONNECTION_STATUSES.OK;
|
|
}
|
|
|
|
export function getConnectionStatusHex(s: string): string {
|
|
return getConnectionStatusMeta(s).hex;
|
|
}
|
|
|
|
export function getConnectionStatusIntent(s: string): BadgeIntent {
|
|
return getConnectionStatusMeta(s).intent;
|
|
}
|