import { clsx } from 'clsx'; import { HTMLAttributes, ReactNode } from 'react'; type WindowSurfaceElement = 'div' | 'section' | 'article' | 'aside' | 'main'; interface WindowSurfaceProps extends Omit, 'title'> { as?: WindowSurfaceElement; title?: ReactNode; subtitle?: ReactNode; controls?: ReactNode; showTrafficLights?: boolean; bodyClassName?: string; } export default function WindowSurface({ as: Component = 'section', title, subtitle, controls, showTrafficLights = true, className, bodyClassName, children, ...props }: WindowSurfaceProps) { const hasTitlebar = Boolean(title || subtitle || controls || showTrafficLights); return ( {hasTitlebar && (
{showTrafficLights && ( )} {(title || subtitle) && (
{title && (
{title}
)} {subtitle && (
{subtitle}
)}
)}
{controls &&
{controls}
}
)}
{children}
); }