An open-source, self-hosted system for apps built with web technologies.
Appearance: the new material and shadow, kept Appearances read as understood
zohayrslileheba788ecaf0c
diff --git a/source/client/view/appearance/appearance.tsx b/source/client/view/appearance/appearance.tsxindex 81c784d..46e435e 100644--- a/source/client/view/appearance/appearance.tsx+++ b/source/client/view/appearance/appearance.tsx@@ -1,5 +1,5 @@import DesktopPreferencesProvider, { useDesktopPreferences, useDesktopThemeTransaction } from "./desktop-preferences"-import { applyAppearanceUpdate, defaultAppearance, type Appearance, type Transaction } from "@phreshos/core"+import { defaultAppearance, readSavedAppearance, type Appearance, type Transaction } from "@phreshos/core"import { timing, UIProvider } from "@phreshos/react-ui"import ReducedMotion from "@libs/react-motion"import { createContext, type PropsWithChildren, useCallback, useContext, useLayoutEffect, useMemo, useState } from "react"@@ -78,7 +78,7 @@ export function resolveStoredAppearance(value: string | null): Appearance {if (value === null) return defaultAppearancetry {- return applyAppearanceUpdate(defaultAppearance, JSON.parse(value))+ return readSavedAppearance(JSON.parse(value))}catch {return defaultAppearancediff --git a/source/client/view/appearance/floating-shadow.ts b/source/client/view/appearance/floating-shadow.tsindex 680cd04..a9c7ff0 100644--- a/source/client/view/appearance/floating-shadow.ts+++ b/source/client/view/appearance/floating-shadow.ts@@ -1,5 +1,5 @@/**- * The Appearance shadow at its `xlarge` level, for what floats above the Desktop: standard windows,+ * The Appearance shadow at its `xlarge` strength, for what floats above the Desktop: standard windows,* the Start menu and the Map.*/-export const floatingShadow = Object.freeze({ x: "xlarge", y: "xlarge", blur: "xlarge", spread: "xlarge", opacity: "xlarge" } as const)+export const floatingShadow = "xlarge"diff --git a/source/client/view/structure/authentication/credentials-form.tsx b/source/client/view/structure/authentication/credentials-form.tsxindex 9a1da43..e45ce56 100644--- a/source/client/view/structure/authentication/credentials-form.tsx+++ b/source/client/view/structure/authentication/credentials-form.tsx@@ -65,7 +65,7 @@ export default function CredentialsForm({ title, description, submitLabel, passw>- <Surface material="full" radius="large" className="w-full" style={{ padding: resolveSpacing("xlarge", spacing) }}>+ <Surface material="frosted" radius="large" className="w-full" style={{ padding: resolveSpacing("xlarge", spacing) }}><formdiff --git a/source/client/view/structure/desktop/layers/shell/start-menu/start-menu.tsx b/source/client/view/structure/desktop/layers/shell/start-menu/start-menu.tsxindex ff0279a..48ad4bd 100644--- a/source/client/view/structure/desktop/layers/shell/start-menu/start-menu.tsx+++ b/source/client/view/structure/desktop/layers/shell/start-menu/start-menu.tsx@@ -42,7 +42,6 @@ export const StartMenuButton = memo(function StartMenuButton({ showLabel = truelabel={name}showLabel={showLabel}color="default:base"- material="extended"aria-controls={control.id}aria-expanded={control.popover.open}aria-haspopup="dialog"diff --git a/source/client/view/structure/desktop/layers/shell/taskbar/map/map-control.tsx b/source/client/view/structure/desktop/layers/shell/taskbar/map/map-control.tsxindex 51d263f..aba6133 100644--- a/source/client/view/structure/desktop/layers/shell/taskbar/map/map-control.tsx+++ b/source/client/view/structure/desktop/layers/shell/taskbar/map/map-control.tsx@@ -525,7 +525,7 @@ function ViewMap({ labelId, viewport, windows, centered, menus, room }: Readonly<div className="relative" style={fills ? { alignSelf: "center", justifySelf: "center" } : undefined}>{/* The plane, a well recessed into the Panel like the Start Menu's; views and Windows sit on it, and the frame above them. */}- <Surface depth="recessed" color="background" material="extended" className="relative overflow-hidden" style={{ width: columns * cell.width, height: rows * cell.height }}>+ <Surface depth="recessed" color="background" className="relative overflow-hidden" style={{ width: columns * cell.width, height: rows * cell.height }}>{/* One clear cell per view, so the well shows as it does in the Start Menu. */}<div className="absolute inset-0 grid" style={{ gridTemplateColumns: `repeat(${columns}, ${cell.width}px)`, gridTemplateRows: `repeat(${rows}, ${cell.height}px)` }}>@@ -568,7 +568,7 @@ function ViewMap({ labelId, viewport, windows, centered, menus, room }: Readonly<motion.div className="absolute left-0 top-0" style={{ width: cell.width, height: cell.height }} initial={false}animate={{ x: mapX(viewport.offset.x) - cell.width / 2, y: mapY(viewport.offset.y) - cell.height / 2 }}transition={viewport.transaction && !reducedMotion ? motionTransition(viewport.transaction) : { duration: 0 }}>- <Surface aria-hidden="true" color="primary" material={{ opacity: 0.3, backdrop: 0 }} radius="small" className="cursor-grab touch-none active:cursor-grabbing"+ <Surface aria-hidden="true" color="primary" material={{ mode: "translucent", opacity: 0.3 }} radius="small" className="cursor-grab touch-none active:cursor-grabbing"style={{ width: "100%", height: "100%" }}onPointerDown={grab} onPointerMove={follow} onPointerUp={release} onPointerCancel={() => { drag.current = null; setSettle(null) }} /></motion.div>diff --git a/source/client/view/structure/desktop/layers/shell/taskbar/programs/taskbar-item.tsx b/source/client/view/structure/desktop/layers/shell/taskbar/programs/taskbar-item.tsxindex 005aa68..9c370f9 100644--- a/source/client/view/structure/desktop/layers/shell/taskbar/programs/taskbar-item.tsx+++ b/source/client/view/structure/desktop/layers/shell/taskbar/programs/taskbar-item.tsx@@ -35,8 +35,11 @@ export default forwardRef<HTMLButtonElement, TaskbarItemProps>(function TaskbarI</Button>})-/** The material of a window that is not active: mostly the bar shows through it. */-const resting = { opacity: 0.35 }+/**+ * The material of a window that is not active: mostly the bar shows through it. The bar is already+ * frosted, so the item is only translucent: frosting it again would blur the same backdrop twice.+ */+const resting = { mode: "translucent", opacity: 0.35 } as constinterface TaskbarItemProps extends Omit<ButtonActionProps, "children"> {diff --git a/source/client/view/structure/desktop/layers/shell/taskbar/taskbar.tsx b/source/client/view/structure/desktop/layers/shell/taskbar/taskbar.tsxindex fc700b6..de7c35b 100644--- a/source/client/view/structure/desktop/layers/shell/taskbar/taskbar.tsx+++ b/source/client/view/structure/desktop/layers/shell/taskbar/taskbar.tsx@@ -79,7 +79,7 @@ export default function Taskbar({ leading, navigation, trailing, taskbar, spacin{...props}- material="full"+ material="frosted"onPointerEnter={event => {setRevealed(true)diff --git a/source/client/view/structure/desktop/windows/window-surface.tsx b/source/client/view/structure/desktop/windows/window-surface.tsxindex 0d6d857..87dbc2b 100644--- a/source/client/view/structure/desktop/windows/window-surface.tsx+++ b/source/client/view/structure/desktop/windows/window-surface.tsx@@ -93,16 +93,16 @@ function surfaceColor(surface: VisibleWindowSurface): Color | undefined {: surface.color}-function surfaceMaterial(surface: VisibleWindowSurface, active: boolean): "none" | "basic" | "full" | MaterialOptions {+function surfaceMaterial(surface: VisibleWindowSurface, active: boolean): "none" | "frosted" | MaterialOptions | undefined {- const material = surface === true || surface.material === undefined ? "full" : surface.material+ const material = surface === true || surface.material === undefined ? "frosted" : surface.materialif (material === false) return "none"// Frost blurs everything behind a window again whenever anything behind it// changes, so its cost grows with every open window. Only the front window- // keeps it; the others become the same paint, opaque, as on macOS.- return active ? material : "basic"+ // keeps it; the others take a Surface's own material, without frost.+ return active ? material : undefined}const appearanceColors = ["background", "foreground", "default", "primary", "secondary", "success", "warning", "danger", "info"] as const satisfies readonly AppearanceColor[]diff --git a/source/server/core/appearance-manager.ts b/source/server/core/appearance-manager.tsindex dbb50c6..40df028 100644--- a/source/server/core/appearance-manager.ts+++ b/source/server/core/appearance-manager.ts@@ -1,6 +1,6 @@import Keyv from "keyv"import { isDeepStrictEqual } from "node:util"-import { applyAppearanceUpdate, defaultAppearance, isUploadFile, systemWallpapers, wallpaperKind, wallpaperSizeLimit, type Appearance, type AppearanceWallpapers } from "@phreshos/core"+import { applyAppearanceUpdate, defaultAppearance, isUploadFile, readSavedAppearance, systemWallpapers, wallpaperKind, wallpaperSizeLimit, type Appearance, type AppearanceWallpapers } from "@phreshos/core"import UploadManager from "./upload-manager"const storageKey = "appearance"@@ -15,9 +15,7 @@ export default class AppearanceManager {public static async open(store: Keyv, uploads: UploadManager) {const stored = await store.get(storageKey)- const held = stored === undefined- ? defaultAppearance- : applyAppearanceUpdate(defaultAppearance, stored)+ const held = stored === undefined ? defaultAppearance : readSavedAppearance(stored)// A wallpaper that can no longer be shown, such as an upload gone from disk, becomes the// System's own for its place, so the Desktop never shows nothing and later changes apply.diff --git a/tests/appearance.test.ts b/tests/appearance.test.tsindex 0ada801..e30edbc 100644--- a/tests/appearance.test.ts+++ b/tests/appearance.test.ts@@ -94,20 +94,25 @@ test("appearance contract", async () => {const reopened = await AppearanceManager.open(store, uploads)assert.deepEqual(reopened.value, manager.value)- const shadow = {- light: { x: -3, y: 12, blur: 30, spread: 2, opacity: 0.25 },- dark: { x: 2, y: 6, blur: 18, spread: -1, opacity: 0.12 }- }+ const shadow = { light: 0.25, dark: 0.12 }await manager.update({ ...manager.value, shadow })assert.deepEqual(manager.value.shadow, shadow)assert.deepEqual((await store.get("appearance")).shadow, shadow)assert.deepEqual((await AppearanceManager.open(store, uploads)).value.shadow, shadow)- for (const invalid of [{ ...shadow.light, blur: -1 }, { ...shadow.light, opacity: 1.1 }, { ...shadow.light, x: Infinity }]) {+ for (const invalid of [-0.1, 0.31, Infinity]) {await assert.rejects(manager.update({ ...manager.value, shadow: { ...shadow, light: invalid } }))assert.deepEqual(manager.value.shadow, shadow)}+ // A saved field whose shape has changed takes its default; the others stay.+ await store.set("appearance", { ...manager.value, spacing: 16, shadow: { light: { x: 0, y: 0, blur: 10, spread: 0, opacity: 0.2 }, dark: {} } })+ const understood = await AppearanceManager.open(store, uploads)+ assert.equal(understood.value.spacing, 16)+ assert.deepEqual(understood.value.shadow, defaultAppearance.shadow)+ await understood.update({ ...understood.value, shadow })+ assert.deepEqual(understood.value.shadow, shadow)+const updated = {...manager.value,tempo: 1.5