import type { HTMLAttributes, ReactNode } from 'react';
type PlatformRuntimeStatusTone =
| 'error'
| 'success'
| 'info'
| 'warning'
| 'neutral';
type PlatformRuntimeStatusSurface = 'light' | 'dark' | 'solid';
type PlatformRuntimeStatusSize = 'xs' | 'sm' | 'md';
type PlatformRuntimeStatusShape = 'pill' | 'rounded';
type PlatformRuntimeStatusToastProps = Omit<
HTMLAttributes,
'children'
> & {
tone: PlatformRuntimeStatusTone;
surface?: PlatformRuntimeStatusSurface;
size?: PlatformRuntimeStatusSize;
shape?: PlatformRuntimeStatusShape;
children: ReactNode;
};
const PLATFORM_RUNTIME_STATUS_SURFACE_CLASS: Record<
PlatformRuntimeStatusSurface,
Record
> = {
light: {
error:
'border-white/70 bg-white/86 text-[var(--platform-button-danger-text)]',
success:
'border-white/70 bg-white/86 text-[var(--platform-success-text)]',
info: 'border-white/70 bg-white/86 text-[var(--platform-cool-text)]',
warning: 'border-white/70 bg-white/86 text-[var(--platform-warm-text)]',
neutral: 'border-white/70 bg-white/86 text-[var(--platform-text-base)]',
},
dark: {
error: 'border-rose-200/35 bg-rose-400/18 text-rose-50',
success: 'border-emerald-200/35 bg-emerald-400/18 text-emerald-50',
info: 'border-sky-200/30 bg-sky-400/16 text-sky-50',
warning: 'border-amber-200/35 bg-amber-400/18 text-amber-50',
neutral: 'border-white/15 bg-white/12 text-white/82',
},
solid: {
error: 'border-transparent bg-rose-600 text-white',
success: 'border-transparent bg-emerald-600 text-white',
info: 'border-transparent bg-sky-600 text-white',
warning: 'border-transparent bg-amber-500 text-amber-950',
neutral: 'border-transparent bg-slate-800 text-white',
},
};
const PLATFORM_RUNTIME_STATUS_SIZE_CLASS: Record<
PlatformRuntimeStatusSize,
string
> = {
xs: 'px-3 py-1 text-xs leading-5',
sm: 'px-3 py-2 text-sm leading-5',
md: 'px-4 py-3 text-sm leading-6',
};
const PLATFORM_RUNTIME_STATUS_SHAPE_CLASS: Record<
PlatformRuntimeStatusShape,
string
> = {
pill: 'rounded-full',
rounded: 'rounded-[1.2rem]',
};
/**
* 运行态 HUD 状态提示。
* 收口游戏内短错误、成功和反馈 chip,位置与玩法强品牌视觉仍由调用方控制。
*/
export function PlatformRuntimeStatusToast({
tone,
surface = 'light',
size = 'sm',
shape = 'pill',
children,
className,
role,
...divProps
}: PlatformRuntimeStatusToastProps) {
const ariaLive = divProps['aria-live'];
return (
{children}
);
}