62 lines
2.3 KiB
TypeScript
62 lines
2.3 KiB
TypeScript
import { createGlassMaterialVariables, type GlassMaterialSettings } from "@nodedc/ui-core";
|
|
import type { CSSProperties, HTMLAttributes, ReactNode } from "react";
|
|
import { cn } from "./cn.js";
|
|
|
|
export type GlassTone = "default" | "strong" | "soft" | "group";
|
|
export type GlassRadius = "card" | "panel" | "modal" | "pill";
|
|
export type GlassPadding = "none" | "sm" | "md" | "lg";
|
|
|
|
export interface GlassSurfaceProps extends HTMLAttributes<HTMLDivElement> {
|
|
children: ReactNode;
|
|
tone?: GlassTone;
|
|
radius?: GlassRadius;
|
|
padding?: GlassPadding;
|
|
materialRim?: boolean;
|
|
}
|
|
|
|
export function GlassSurface({
|
|
children,
|
|
className,
|
|
tone = "default",
|
|
radius = "card",
|
|
padding = "none",
|
|
materialRim = true,
|
|
...props
|
|
}: GlassSurfaceProps) {
|
|
return (
|
|
<div
|
|
className={cn("nodedc-glass", materialRim && "nodedc-material-rim", className)}
|
|
data-tone={tone}
|
|
data-radius={radius}
|
|
data-padding={padding === "none" ? undefined : padding}
|
|
{...props}
|
|
>
|
|
{children}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export interface GlassMaterialSurfaceProps extends HTMLAttributes<HTMLDivElement> {
|
|
children: ReactNode;
|
|
/** Scene telemetry uses the translucent V4 material, independent of modal density. */
|
|
context?: "floating" | "scene";
|
|
radius?: GlassRadius;
|
|
/** Per-instance appearance; never changes the global theme or other surfaces. */
|
|
material?: GlassMaterialSettings;
|
|
radiusPx?: number;
|
|
}
|
|
|
|
/** Canonical floating/scene-overlay material. Ordinary application panels stay matte. */
|
|
export function GlassMaterialSurface({ children, className, context = "floating", radius = "modal", material, radiusPx, style, ...props }: GlassMaterialSurfaceProps) {
|
|
return <div className={cn("nodedc-glass-material", className)} data-glass-context={context} data-radius={radius} style={{ ...material && createGlassMaterialVariables(material, context), ...Number.isFinite(radiusPx) && {borderRadius: Math.max(0, Math.min(120, radiusPx!))}, ...style } as CSSProperties} {...props}>{children}</div>;
|
|
}
|
|
|
|
export interface MapGlassSurfaceProps extends HTMLAttributes<HTMLDivElement> {
|
|
children: ReactNode;
|
|
}
|
|
|
|
/** Light translucent surface used only over Cesium/map imagery. */
|
|
export function MapGlassSurface({ children, className, ...props }: MapGlassSurfaceProps) {
|
|
return <div className={cn("nodedc-map-glass", className)} {...props}>{children}</div>;
|
|
}
|