Skip to content

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

Refine surface presentation

zohayrslileh1d5a7b860cef
diff --git a/source/client/view/appearance/appearance.css b/source/client/view/appearance/appearance.css
index 8a09c5e..3407721 100644
--- a/source/client/view/appearance/appearance.css
+++ b/source/client/view/appearance/appearance.css
@@ -39,7 +39,6 @@
--shadow-snap-preview: inset 0 1px 0 rgba(255, 255, 255, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.25);
- --text-shadow-chrome: 0 1px 0 rgba(255, 255, 255, 0.8);
}
[data-start-menu-scroll] {
diff --git a/source/client/view/structure/authentication/credentials-form.tsx b/source/client/view/structure/authentication/credentials-form.tsx
index 954039e..025937d 100644
--- a/source/client/view/structure/authentication/credentials-form.tsx
+++ b/source/client/view/structure/authentication/credentials-form.tsx
@@ -60,7 +60,7 @@ export default function CredentialsForm({ title, description, submitLabel, passw
<Surface aria-hidden="true" className="pointer-events-none absolute inset-0 rounded-[inherit]" />
- <div className="relative grid gap-1 px-5 py-4 text-shadow-chrome">
+ <div className="relative grid gap-1 px-5 py-4">
<h1 className="text-xl font-semibold">{title}</h1>
diff --git a/source/client/view/structure/desktop/taskbar/programs/taskbar-item.tsx b/source/client/view/structure/desktop/taskbar/programs/taskbar-item.tsx
index 462ed8c..2f86d31 100644
--- a/source/client/view/structure/desktop/taskbar/programs/taskbar-item.tsx
+++ b/source/client/view/structure/desktop/taskbar/programs/taskbar-item.tsx
@@ -18,7 +18,7 @@ export default function ({ active = false, icon, children, className, ...props }
aria-pressed={active}
- className={`relative flex h-8 max-w-40 shrink-0 scroll-mx-8 cursor-pointer select-none items-center gap-1.5 overflow-hidden rounded-lg border px-2.5 text-xs font-medium text-shadow-chrome outline-none focus-visible:ring-2 focus-visible:ring-white/80 ${reducedMotion ? "" : "transition-colors duration-100 active:scale-95"} ${surface} ${className ?? ""}`}
+ className={`relative flex h-8 max-w-40 shrink-0 scroll-mx-8 cursor-pointer select-none items-center gap-1.5 overflow-hidden rounded-lg border px-2.5 text-xs font-medium outline-none focus-visible:ring-2 focus-visible:ring-white/80 ${reducedMotion ? "" : "transition-colors duration-100 active:scale-95"} ${surface} ${className ?? ""}`}
{...props}
diff --git a/source/client/view/structure/desktop/taskbar/taskbar-surface.tsx b/source/client/view/structure/desktop/taskbar/taskbar-surface.tsx
index fdafd90..b94acb3 100644
--- a/source/client/view/structure/desktop/taskbar/taskbar-surface.tsx
+++ b/source/client/view/structure/desktop/taskbar/taskbar-surface.tsx
@@ -11,7 +11,7 @@ export default function TaskbarSurface({ label, labelId, children }: TaskbarSurf
return <Surface className="grid min-h-0 max-h-[inherit] grid-rows-[auto_minmax(0,1fr)] overflow-hidden rounded-[inherit]">
- <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>
+ <h2 id={labelId} className="relative grid h-10 items-center px-3.5 text-window-title font-medium select-none">{label}</h2>
<div style={{ borderRadius: contentRadius }} className="relative m-1.5 mt-0 min-h-0 overflow-hidden bg-white/25 shadow-window-content">
diff --git a/source/client/view/structure/desktop/windows/window-header.tsx b/source/client/view/structure/desktop/windows/window-header.tsx
index 2b75d60..aee2344 100644
--- a/source/client/view/structure/desktop/windows/window-header.tsx
+++ b/source/client/view/structure/desktop/windows/window-header.tsx
@@ -75,7 +75,7 @@ export default function WindowHeader({ title, icon, active, whole, reducedMotion
equally legible when another window owns the keyboard. */}
<span
ref={titleElement}
- className="truncate text-window-title font-medium text-shadow-chrome"
+ className="truncate text-window-title font-medium"
style={{ color: renderedActive ? "#1e293b" : "#64748b" }}
>{title}</span>
diff --git a/source/client/view/structure/desktop/windows/window-surface.tsx b/source/client/view/structure/desktop/windows/window-surface.tsx
index 7903cc8..43470bc 100644
--- a/source/client/view/structure/desktop/windows/window-surface.tsx
+++ b/source/client/view/structure/desktop/windows/window-surface.tsx
@@ -1,11 +1,13 @@
import { useReducedMotion } from "@libs/react-motion"
import { Surface } from "@phreshos/react-ui"
-import { useLayoutEffect, useRef, useState } from "react"
+import { useLayoutEffect, useRef } from "react"
import { type LocalSurfaceState } from "../../../components/desktop-host/local-window"
import gsap, { motionDuration, motionEase } from "../../../appearance/motion"
const systemDuration = 240
+const paintSelector = "[data-surface-backdrop], [data-surface-border], [data-surface-material]"
+
/** Projects one representation-local target and animates explicit replacements. */
export default function WindowSurface({ state, onComplete }: WindowSurfaceProps) {
@@ -17,9 +19,9 @@ export default function WindowSurface({ state, onComplete }: WindowSurfaceProps)
const reducedMotion = useReducedMotion()
- // Keep the last painted target in React while an incoming transition is
- // prepared from the element's current compositor value.
- const [renderedVisible, setRenderedVisible] = useState(visible)
+ // The configured material and border opacity remain the visible targets;
+ // visibility animation must not replace those values with a root opacity.
+ const visibleOpacity = useRef(new Map<Element, number>())
useLayoutEffect(function () {
@@ -27,13 +29,18 @@ export default function WindowSurface({ state, onComplete }: WindowSurfaceProps)
if (!surface) return
- const current = getComputedStyle(surface)
+ const layers = [...surface.querySelectorAll(paintSelector)]
+
+ for (const layer of layers) {
+
+ if (!visibleOpacity.current.has(layer)) visibleOpacity.current.set(layer, Number(getComputedStyle(layer).opacity))
+ }
const revision = transition?.revision ?? null
const changed = revision !== null
- const from = { opacity: firstRender.current && visible ? 0 : Number(current.opacity) }
+ const initial = firstRender.current
firstRender.current = false
@@ -41,36 +48,32 @@ export default function WindowSurface({ state, onComplete }: WindowSurfaceProps)
const duration = transaction?.duration ?? systemDuration
- gsap.killTweensOf(surface)
+ gsap.killTweensOf(layers)
if (!transaction || !changed || reducedMotion || duration === 0) {
- gsap.set(surface, { opacity: visible ? 1 : 0 })
- setRenderedVisible(visible)
+ for (const layer of layers) gsap.set(layer, { opacity: visible ? visibleOpacity.current.get(layer) : 0 })
if (transaction && changed) onComplete(revision!)
return
}
- const animation = gsap.fromTo(surface, from, {
- opacity: visible ? 1 : 0,
+ const animation = gsap.timeline({
+ onComplete: () => onComplete(revision!)
+ })
+
+ for (const layer of layers) animation.fromTo(layer, {
+ opacity: initial && visible ? 0 : Number(getComputedStyle(layer).opacity)
+ }, {
+ opacity: visible ? visibleOpacity.current.get(layer) : 0,
duration: motionDuration(duration),
ease: motionEase(transaction.easing),
- overwrite: "auto",
- onComplete: function () {
-
- setRenderedVisible(visible)
- onComplete(revision!)
- }
- })
+ overwrite: "auto"
+ }, 0)
return function () {
- const shown = getComputedStyle(surface)
-
- surface.style.opacity = shown.opacity
-
animation.kill()
}
@@ -86,8 +89,6 @@ export default function WindowSurface({ state, onComplete }: WindowSurfaceProps)
className="pointer-events-none absolute inset-0"
- style={{ opacity: renderedVisible ? 1 : 0 }}
-
/>
}