Skip to content

An open-source, self-hosted system for apps built with web technologies.

refactor(view): use shared Surface material

zohayrslilehcc2e4ebfd271
diff --git a/bun.lock b/bun.lock
index 7ba16a5..6faeaeb 100644
--- a/bun.lock
+++ b/bun.lock
@@ -25,7 +25,7 @@
"@babel/core": "^7.29.7",
"@babel/plugin-proposal-decorators": "^7.29.7",
"@phreshos/core": "^0.1.6",
- "@phreshos/react-ui": "^0.1.1",
+ "@phreshos/react-ui": "^0.1.2",
"@rolldown/plugin-babel": "^0.2.3",
"@tailwindcss/vite": "^4.3.3",
"@types/adm-zip": "^0.5.8",
@@ -232,7 +232,7 @@
"@phreshos/core": ["@phreshos/[email protected]", "", {}, "sha512-x6xB/cNTyYa1BGvug4+eWxBJb0Y3dFEO1tP3VUX/1mCxzH6EoaH3d1w9L0GgZ19/DY+zKP9I2dXztLEkE78sfg=="],
- "@phreshos/react-ui": ["@phreshos/[email protected]", "", { "dependencies": { "react-aria-components": "^1.20.0" }, "peerDependencies": { "@phreshos/core": "^0.1.4", "react": "^19.2.0", "react-dom": "^19.2.0" } }, "sha512-mj6+xizG/mlPOsEPydI4vlxeeFcu836/lHs7fxK169Jbhnc7oM3xsdV+tUpFaYcPtl4oDZdjMD4UDuW5jr+hhQ=="],
+ "@phreshos/react-ui": ["@phreshos/[email protected]", "", { "dependencies": { "react-aria-components": "^1.20.0" }, "peerDependencies": { "@phreshos/core": "^0.1.4", "react": "^19.2.0", "react-dom": "^19.2.0" } }, "sha512-koH3+QTSGQoMsgdKe2UUAZoNLZhe34V5gNBpdr/qGO+llP9w4ay50+rj3BSY/2Cf9xe8LXvRDjKejhTeEiOIEQ=="],
"@react-types/shared": ["@react-types/[email protected]", "", { "peerDependencies": { "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" } }, "sha512-AzsuD9OfxTOZMMvTRhlN3oHBwOmFN7tDh27LzqmHt4+uOgPhJT7ZM7/kVs/8/o0WxayMUIk3hBmCFRHv1FUoag=="],
diff --git a/package.json b/package.json
index 3df2367..1577315 100644
--- a/package.json
+++ b/package.json
@@ -55,7 +55,7 @@
"@babel/core": "^7.29.7",
"@babel/plugin-proposal-decorators": "^7.29.7",
"@phreshos/core": "^0.1.6",
- "@phreshos/react-ui": "^0.1.1",
+ "@phreshos/react-ui": "^0.1.2",
"@rolldown/plugin-babel": "^0.2.3",
"@tailwindcss/vite": "^4.3.3",
"@types/adm-zip": "^0.5.8",
diff --git a/source/client/view/appearance/surface-presence.ts b/source/client/view/appearance/surface-presence.ts
index 9f7cbaf..a319dd0 100644
--- a/source/client/view/appearance/surface-presence.ts
+++ b/source/client/view/appearance/surface-presence.ts
@@ -4,7 +4,7 @@ const entered = { scale: 1, y: 0 }
const entering = { scale: 0.92, y: 14 }
-/** Establish the first frame before a glass surface becomes visible. */
+/** Establish the first frame before a surface becomes visible. */
export function prepareSurfaceEntrance(surface: HTMLElement | null, reducedMotion: boolean) {
if (!surface) return
@@ -14,7 +14,7 @@ export function prepareSurfaceEntrance(surface: HTMLElement | null, reducedMotio
gsap.set(surface, reducedMotion ? entered : entering)
}
-/** Give every system glass surface the same entrance motion. */
+/** Give every system surface the same entrance motion. */
export function enterSurface(surface: HTMLElement | null, reducedMotion: boolean) {
if (!surface) return null
diff --git a/source/client/view/desktop/taskbar/launcher.tsx b/source/client/view/desktop/taskbar/launcher.tsx
index 455a494..35f3722 100644
--- a/source/client/view/desktop/taskbar/launcher.tsx
+++ b/source/client/view/desktop/taskbar/launcher.tsx
@@ -89,7 +89,7 @@ export default function ({ label, trigger, children, className, style, ...props
style={{ ...style, borderRadius: radius }}
- className={`${taskbarSurfaceClassName} hidden grid-rows-[auto_minmax(0,1fr)] open:grid ${className ?? ""}`}
+ className={`${taskbarSurfaceClassName} hidden open:block ${className ?? ""}`}
onBeforeToggle={event => {
diff --git a/source/client/view/desktop/taskbar/system-dialogs.tsx b/source/client/view/desktop/taskbar/system-dialogs.tsx
index ac6e850..9126e5c 100644
--- a/source/client/view/desktop/taskbar/system-dialogs.tsx
+++ b/source/client/view/desktop/taskbar/system-dialogs.tsx
@@ -74,7 +74,7 @@ export default function SystemDialogs() {
onCancel={event => event.preventDefault()}
- className={`${taskbarSurfaceClassName} grid grid-rows-[auto_minmax(0,1fr)] backdrop:bg-transparent`}
+ className={`${taskbarSurfaceClassName} backdrop:bg-transparent`}
>
diff --git a/source/client/view/desktop/taskbar/taskbar-surface.tsx b/source/client/view/desktop/taskbar/taskbar-surface.tsx
index e4afdeb..7b6f0ef 100644
--- a/source/client/view/desktop/taskbar/taskbar-surface.tsx
+++ b/source/client/view/desktop/taskbar/taskbar-surface.tsx
@@ -1,17 +1,15 @@
import { ReactNode } from "react"
-import { GlassSurface, useTheme } from "@phreshos/react-ui"
+import { Surface, useTheme } from "@phreshos/react-ui"
import { numericScale } from "@phreshos/core"
/** The window-material shell shared by surfaces opened from the taskbar. */
-export const taskbarSurfaceClassName = "m-0 isolate overflow-hidden border-0 bg-transparent p-0 text-slate-800 shadow-window-active outline-none"
+export const taskbarSurfaceClassName = "m-0 isolate overflow-hidden border-0 bg-transparent p-0 shadow-window-active outline-none"
export default function TaskbarSurface({ label, labelId, children }: TaskbarSurfaceProps) {
const contentRadius = numericScale(useTheme().radius).medium
- return <>
-
- <GlassSurface aria-hidden="true" radius="inherit" className="pointer-events-none absolute inset-0" />
+ return <Surface style={{ borderRadius: "inherit" }} className="grid min-h-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden">
<h2 id={labelId} className="relative grid h-10 items-center px-3.5 text-window-title font-medium text-shadow-chrome select-none">{label}</h2>
@@ -21,7 +19,7 @@ export default function TaskbarSurface({ label, labelId, children }: TaskbarSurf
</div>
- </>
+ </Surface>
}
interface TaskbarSurfaceProps {
diff --git a/source/client/view/desktop/taskbar/taskbar.tsx b/source/client/view/desktop/taskbar/taskbar.tsx
index 1aa489f..afcedb0 100644
--- a/source/client/view/desktop/taskbar/taskbar.tsx
+++ b/source/client/view/desktop/taskbar/taskbar.tsx
@@ -1,5 +1,5 @@
import { ComponentProps, ReactNode } from "react"
-import { GlassSurface, useTheme } from "@phreshos/react-ui"
+import { Surface, useTheme } from "@phreshos/react-ui"
import { numericScale } from "@phreshos/core"
import { taskbarAnchorName } from "../geometry"
import TaskbarSeparator from "./taskbar-separator"
@@ -12,9 +12,9 @@ export default function Taskbar({ leading, trailing, dialogs, className, style,
const radius = numericScale(useTheme().radius).large
- return <section
+ return <Surface
- className={`relative isolate h-taskbar border border-white/30 shadow-taskbar ${className ?? ""}`}
+ className={`relative isolate h-taskbar overflow-hidden shadow-taskbar ${className ?? ""}`}
style={{ anchorName: taskbarAnchorName, ...style, borderRadius: radius }}
@@ -22,8 +22,6 @@ export default function Taskbar({ leading, trailing, dialogs, className, style,
>
- <GlassSurface aria-hidden="true" radius="inherit" className="pointer-events-none absolute inset-0" />
-
<div className="relative grid h-full min-w-0 grid-cols-[auto_auto_minmax(0,1fr)_auto_auto] items-center gap-1.5 p-2">
{leading}
@@ -40,10 +38,10 @@ export default function Taskbar({ leading, trailing, dialogs, className, style,
{dialogs}
- </section>
+ </Surface>
}
-interface TaskbarProps extends ComponentProps<"section"> {
+interface TaskbarProps extends ComponentProps<"div"> {
leading: ReactNode
diff --git a/source/client/view/desktop/window-manager/window-surface.tsx b/source/client/view/desktop/window-manager/window-surface.tsx
index 7f5da30..6efd8a7 100644
--- a/source/client/view/desktop/window-manager/window-surface.tsx
+++ b/source/client/view/desktop/window-manager/window-surface.tsx
@@ -1,6 +1,6 @@
import { useReducedMotion } from "@libs/react-motion"
import { isScaleLevel, scale, type Easing, type SurfaceSettings } from "@phreshos/core"
-import { GlassSurface, useTheme } from "@phreshos/react-ui"
+import { Surface, useTheme } from "@phreshos/react-ui"
import { useLayoutEffect, useRef, useState } from "react"
import { type LocalSurfaceState } from "../client-host/local-window"
@@ -99,7 +99,7 @@ export default function WindowSurface({ state, onComplete }: WindowSurfaceProps)
const target = values(rendered, themeRadius)
- return <GlassSurface
+ return <Surface
ref={element}
diff --git a/source/client/view/desktop/window-manager/window.tsx b/source/client/view/desktop/window-manager/window.tsx
index 110e3cb..8afa136 100644
--- a/source/client/view/desktop/window-manager/window.tsx
+++ b/source/client/view/desktop/window-manager/window.tsx
@@ -1,7 +1,7 @@
import { ComponentProps, PointerEvent as ReactPointerEvent, ReactNode, useLayoutEffect, useRef, useState } from "react"
import { useReducedMotion } from "@libs/react-motion"
import { enterSurface, prepareSurfaceEntrance, restSurface } from "../../appearance/surface-presence"
-import { GlassSurface, useTheme } from "@phreshos/react-ui"
+import { Surface, useTheme } from "@phreshos/react-ui"
import { absoluteWindowGeometry, resolveWindowValue, wholeWindowGeometry, windowPaintInsets, type WindowRegion, type WindowSurfaceSize } from "./window-geometry"
import { numericScale, type Position, type Size } from "@phreshos/core"
import WindowHeader from "./window-header"
@@ -27,12 +27,12 @@ import gsap from "gsap"
* onSnap with the shares a zone names) and drops the gesture in the same
* batch the record updates, so nothing jumps.
*
- * GSAP keeps exactly one duty: presence — the scale and drift of
- * entering, minimising and closing, on the glass, never the frame.
+ * GSAP keeps exactly one duty: presence — the scale and drift of entering,
+ * minimising and closing on the painted surface, never the frame.
*
- * The chrome is the liquid material: refraction, frost, specular shell;
- * content sits on an inset sheet. The close control requests — the
- * window leaves only when the truth drops its process.
+ * The chrome uses the shared system material and content sits on an inset
+ * sheet. The close control requests — the window leaves only when the truth
+ * drops its process.
*/
const edges: { edge: WindowEdge, className: string }[] = [
@@ -54,7 +54,7 @@ export default function ({ title, icon, children, onClose, onClosed, onMinimize,
const frame = useRef<HTMLDivElement>(null)
- const glass = useRef<HTMLDivElement>(null)
+ const surfaceElement = useRef<HTMLDivElement>(null)
const reducedMotion = useReducedMotion()
@@ -64,6 +64,8 @@ export default function ({ title, icon, children, onClose, onClosed, onMinimize,
const innerRadius = radius.medium
+ const WindowContainer = bare ? "div" : Surface
+
const [gesture, setGesture] = useState<Gesture | null>(null)
useLayoutEffect(function () {
@@ -149,7 +151,7 @@ export default function ({ title, icon, children, onClose, onClosed, onMinimize,
// restored windows look newly opened.
//
// Bare, there is no entrance. Motion is a visual effect like the
- // glass and the shadow, and `under` and `over` are the layers where
+ // surface and the shadow, and `under` and `over` are the layers where
// the system paints nothing — so what would scale and drift here is
// the program's own content, which reads as the program stumbling
// rather than as a window opening. It showed on every refresh,
@@ -160,25 +162,25 @@ export default function ({ title, icon, children, onClose, onClosed, onMinimize,
if (minimized) {
- gsap.set(glass.current, { scale: reducedMotion ? 1 : 0.86, y: reducedMotion ? 0 : 28, visibility: "hidden" })
+ gsap.set(surfaceElement.current, { scale: reducedMotion ? 1 : 0.86, y: reducedMotion ? 0 : 28, visibility: "hidden" })
return
}
if (!animateEntrance) {
- restSurface(glass.current)
+ restSurface(surfaceElement.current)
- gsap.set(glass.current, { visibility: "visible" })
+ gsap.set(surfaceElement.current, { visibility: "visible" })
return
}
- prepareSurfaceEntrance(glass.current, reducedMotion)
+ prepareSurfaceEntrance(surfaceElement.current, reducedMotion)
- gsap.set(glass.current, { visibility: "visible" })
+ gsap.set(surfaceElement.current, { visibility: "visible" })
- const animation = enterSurface(glass.current, reducedMotion)
+ const animation = enterSurface(surfaceElement.current, reducedMotion)
return () => { animation?.kill() }
@@ -190,20 +192,20 @@ export default function ({ title, icon, children, onClose, onClosed, onMinimize,
// closing still answers its completion handshake.
useLayoutEffect(function () {
- if (!glass.current) return
+ if (!surfaceElement.current) return
// A hidden window can silently prepare the pose that a future
// restore will animate from if the preference has been relaxed.
if (!reducedMotion) {
- if (minimized) gsap.set(glass.current, { scale: 0.86, y: 28, visibility: "hidden" })
+ if (minimized) gsap.set(surfaceElement.current, { scale: 0.86, y: 28, visibility: "hidden" })
return
}
- gsap.killTweensOf(glass.current)
+ gsap.killTweensOf(surfaceElement.current)
- gsap.set(glass.current, { scale: 1, y: 0, visibility: minimized || closing ? "hidden" : "visible" })
+ gsap.set(surfaceElement.current, { scale: 1, y: 0, visibility: minimized || closing ? "hidden" : "visible" })
if (closing) {
@@ -228,7 +230,7 @@ export default function ({ title, icon, children, onClose, onClosed, onMinimize,
return
}
- if (!glass.current) return
+ if (!surfaceElement.current) return
if (minimized) onUnavailable?.("minimize")
@@ -238,24 +240,21 @@ export default function ({ title, icon, children, onClose, onClosed, onMinimize,
// would be motion toward nowhere.
if (bare || reducedMotion) {
- gsap.set(glass.current, { scale: 1, y: 0, visibility: minimized ? "hidden" : "visible" })
+ gsap.set(surfaceElement.current, { scale: 1, y: 0, visibility: minimized ? "hidden" : "visible" })
return
}
- // Presence is scale and drift, never opacity: an element with
- // opacity below 1 is a backdrop root, and inside one there is
- // nothing behind to sample — the glass would be dead for as long
- // as the fade lasted, which is exactly as long as the eye is on
- // it. Going away is a departure toward the taskbar; hiding at
- // the end is visibility, which forms no such root.
- if (!minimized) gsap.set(glass.current, { visibility: "visible" })
+ // Presence is scale and drift, never opacity, so the material and its
+ // content remain visually stable throughout the movement. Going away
+ // is a departure toward the taskbar; hiding happens only at the end.
+ if (!minimized) gsap.set(surfaceElement.current, { visibility: "visible" })
const animation = minimized
- ? gsap.to(glass.current, { scale: 0.86, y: 28, duration: 0.11, ease: "power3.in", onComplete: () => gsap.set(glass.current, { visibility: "hidden" }) })
+ ? gsap.to(surfaceElement.current, { scale: 0.86, y: 28, duration: 0.11, ease: "power3.in", onComplete: () => gsap.set(surfaceElement.current, { visibility: "hidden" }) })
- : gsap.to(glass.current, { scale: 1, y: 0, duration: 0.24, ease: "power3.out" })
+ : gsap.to(surfaceElement.current, { scale: 1, y: 0, duration: 0.24, ease: "power3.out" })
return () => { animation.kill() }
@@ -265,7 +264,7 @@ export default function ({ title, icon, children, onClose, onClosed, onMinimize,
// element may be unmounted.
useLayoutEffect(function () {
- if (!closing || !glass.current) return
+ if (!closing || !surfaceElement.current) return
onUnavailable?.("close")
@@ -279,7 +278,7 @@ export default function ({ title, icon, children, onClose, onClosed, onMinimize,
return
}
- const animation = gsap.to(glass.current, { scale: 0.86, y: 12, duration: 0.16, ease: "power2.in", onComplete: completeClosure })
+ const animation = gsap.to(surfaceElement.current, { scale: 0.86, y: 12, duration: 0.16, ease: "power2.in", onComplete: completeClosure })
return () => { animation.kill() }
@@ -603,16 +602,13 @@ export default function ({ title, icon, children, onClose, onClosed, onMinimize,
Bare, there is no difference: the frame fills the box, so
the window is exactly as large as it asked to be and its
boundaries are the ones its own content draws. */}
- <div data-window-container ref={glass} style={bare ? { inset: 0 } : { ...paintedInsets, borderRadius: outerRadius }} className={`absolute isolate grid ${bare ? "grid-rows-1" : `overflow-hidden grid-rows-[auto_minmax(0,1fr)] ${reducedMotion ? "" : "transition-shadow duration-200"} ${surface}`}`}>
+ <WindowContainer data-window-container ref={surfaceElement} style={bare ? { inset: 0 } : { ...paintedInsets, borderRadius: outerRadius }} className={`absolute isolate grid ${bare ? "grid-rows-1" : `overflow-hidden grid-rows-[auto_minmax(0,1fr)] ${reducedMotion ? "" : "transition-shadow duration-200"} ${surface}`}`}>
- {/* A bare Client cannot refract the desktop through its iframe.
- Its host surface is therefore a sibling behind the frame,
- with its own radius and no clipping parent. */}
+ {/* A bare Client controls its own host surface. It remains a
+ sibling behind the frame, with its own radius and no
+ clipping parent. */}
{bare && localSurface && <WindowSurface state={localSurface} onComplete={revision => onLocalAnimationComplete?.("surface", revision)} />}
- {/* LAYER 1 — the shared Theme-driven glass material. */}
- {!bare && <GlassSurface aria-hidden="true" radius="inherit" className="pointer-events-none absolute inset-0" />}
-
{!bare && <WindowHeader
title={title}
@@ -645,7 +641,7 @@ export default function ({ title, icon, children, onClose, onClosed, onMinimize,
</div>
- </div>
+ </WindowContainer>
{!bare && edges.map(handle => <div
@@ -702,7 +698,7 @@ interface WindowProps extends Omit<ComponentProps<"div">, "title"> {
active?: boolean
// Nothing the system paints. The window's boundaries become the
- // frame's exactly: no glass, no shadow, no rounding, no header, no
+ // frame's exactly: no surface, no shadow, no rounding, no header, no
// controls, and no gutter — so what a program asked to be is what it
// gets, edge to edge, rather than half a gutter smaller.
//