An open-source, self-hosted system for apps built with web technologies.
Use React UI window header in Desktop
zohayrslileh0ad1931e7a1d
diff --git a/source/client/view/structure/desktop/windows/window-header.tsx b/source/client/view/structure/desktop/windows/window-header.tsxindex bb838a5..6a74b3a 100644--- a/source/client/view/structure/desktop/windows/window-header.tsx+++ b/source/client/view/structure/desktop/windows/window-header.tsx@@ -1,142 +1,26 @@-import { PointerEvent as ReactPointerEvent, ReactNode } from "react"-import { motion } from "motion/react"-import { motionTransition } from "@client/view/appearance/motion"-import { Button, type ButtonColor, useAppearance, useThemedValue } from "@phreshos/react-ui"--/** The visible chrome above an ordinary window's content. */-export default function WindowHeader({ title, icon, active, whole, reducedMotion, stopping, onGrab, onMinimize, onMaximize, onClose }: WindowHeaderProps) {-- const appearance = useAppearance()-- const transition = motionTransition(appearance.transaction, reducedMotion)-- const foreground = useThemedValue(appearance.colors).foreground-- return <div-- onPointerDown={onGrab}-- onDoubleClick={onMaximize}-- className="relative grid h-10 shrink-0 touch-none cursor-grab grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-3 px-3.5 select-none active:cursor-grabbing"-- >-- <motion.img-- src={icon}-- alt=""-- draggable={false}-- className="size-4 rounded-sm object-contain"-- initial={false}-- animate={{ opacity: active ? 1 : 0.6 }}-- transition={transition}-- />-- {/* Focus is said on the chrome and nowhere else. Content stays- equally legible when another window owns the keyboard. */}- <motion.span- className="truncate text-window-title font-medium"- initial={false}- animate={{ opacity: active ? 1 : 0.6 }}- transition={transition}- >{title}</motion.span>-- <div className="grid shrink-0 grid-flow-col auto-cols-max gap-1" onPointerDown={event => event.stopPropagation()} onDoubleClick={event => event.stopPropagation()}>-- {onMinimize && <Control label="Minimise" foreground={foreground} preventFocusOnPress onPress={onMinimize}>-- <path d="M1.5 7.5h7" />-- </Control>}-- {onMaximize && <Control label={whole ? "Restore" : "Fill"} foreground={foreground} onPress={onMaximize}>-- {whole-- ? <path d="M1 4h5v5H1zM4 1h5v5H6.5" strokeWidth="1.3" strokeLinejoin="round" />-- : <path d="M1.5 1.5h7v7h-7z" strokeWidth="1.3" strokeLinejoin="round" />}-- </Control>}-- {onClose && <Control label="Close" foreground={foreground} color="danger:base" preventFocusOnPress onPress={onClose} disabled={stopping}>-- <path d="M1.5 1.5 8.5 8.5M8.5 1.5 1.5 8.5" />-- </Control>}-- </div>-- </div>-}--function Control({ label, foreground, children, ...props }: ControlProps) {-- return <Button-- {...props}-- aria-label={label}-- size="xsmall"-- style={{ color: foreground }}-- >-- <svg viewBox="0 0 10 10" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" className="size-2.5">-- {children}-- </svg>-- </Button>+import type { PointerEvent as ReactPointerEvent, ReactNode } from "react"+import { WindowHeader as Header } from "@phreshos/react-ui"++/** Connects Desktop Window behavior to React UI's shared header. */+export default function WindowHeader({ title, icon, active, whole, stopping, onGrab, onMinimize, onMaximize, onClose }: WindowHeaderProps) {+ return <Header active={active} onPointerDown={onGrab} onDoubleClick={onMaximize}>+ <Header.Identity icon={icon} title={title} />+ <Header.Actions>+ {onMinimize && <Header.Minimize onPress={onMinimize} />}+ {onMaximize && <Header.Maximize maximized={whole} onPress={onMaximize} />}+ {onClose && <Header.Close onPress={onClose} disabled={stopping} />}+ </Header.Actions>+ </Header>}interface WindowHeaderProps {-title?: ReactNode-icon: string-active: boolean-whole: boolean-- reducedMotion: boolean-stopping: boolean-onGrab: (event: ReactPointerEvent<HTMLElement>) => void-onMinimize?: () => void-onMaximize?: () => void-onClose?: () => void}--interface ControlProps {-- label: string-- foreground: string-- color?: ButtonColor-- preventFocusOnPress?: boolean-- disabled?: boolean-- onPress: () => void-- children: ReactNode-}diff --git a/source/client/view/structure/desktop/windows/window.tsx b/source/client/view/structure/desktop/windows/window.tsxindex 23e74bc..7f2735b 100644--- a/source/client/view/structure/desktop/windows/window.tsx+++ b/source/client/view/structure/desktop/windows/window.tsx@@ -506,8 +506,6 @@ export default function ({ title, header = true, icon, children, onClose, onCloswhole={whole}- reducedMotion={reducedMotion}-onGrab={event => grab(event, null)}onMinimize={onMinimize}