An open-source, self-hosted system for apps built with web technologies.
Lay out frames at their own size under the Desktop scale
zohayrslileh10ee11bce2af
diff --git a/source/client/view/components/program-frame.tsx b/source/client/view/components/program-frame.tsxindex 5b90e79..7fda289 100644--- a/source/client/view/components/program-frame.tsx+++ b/source/client/view/components/program-frame.tsx@@ -3,6 +3,7 @@ import ClientState from "@client/core/link-manager/auth-manager/process-manager/import { blockedProgramDocument, type ProgramAccess } from "./program-access"import { type Theme } from "@phreshos/core"import { type ReactEventHandler, useCallback, useRef } from "react"+import { useDesktopFrameStyle } from "../structure/desktop/desktop-scale"export function programFrameSource(assetId: string, door: string) {@@ -12,6 +13,8 @@ export function programFrameSource(assetId: string, door: string) {/** The document representation shared by every Client role. */export default function ProgramFrame({ record, assetId, client, title, door, access, theme, className = "size-full border-0", onFrame, onLoad }: ProgramFrameProps) {+ const style = useDesktopFrameStyle()+const source = useCallback((element: HTMLIFrameElement | null) => onFrame(record.identity, element), [onFrame, record.identity])// The document is served in the Desktop's theme at the moment the frame loads it. A later theme@@ -32,6 +35,8 @@ export default function ProgramFrame({ record, assetId, client, title, door, accclassName={className}+ style={style}+/>return <iframe@@ -46,6 +51,8 @@ export default function ProgramFrame({ record, assetId, client, title, door, accclassName={className}+ style={style}+ref={source}onLoad={onLoad}diff --git a/source/client/view/structure/desktop/desktop-scale.tsx b/source/client/view/structure/desktop/desktop-scale.tsxindex 076273d..00fcb08 100644--- a/source/client/view/structure/desktop/desktop-scale.tsx+++ b/source/client/view/structure/desktop/desktop-scale.tsx@@ -1,5 +1,5 @@import { defaultDesktopScale } from "@phreshos/core"-import { createContext, type ReactNode, useContext, useMemo } from "react"+import { createContext, type CSSProperties, type ReactNode, useContext, useMemo } from "react"const DesktopScaleContext = createContext<DesktopScale>({ scale: defaultDesktopScale, container: null })@@ -20,6 +20,24 @@ export function useDesktopScaleContainer() {return useContext(DesktopScaleContext).container}+/**+ * Places a frame filling its container in the Desktop's scale. The frame takes no zoom itself: its+ * document is laid out at the frame's own size and the frame is enlarged as a picture. Under zoom,+ * Safari lays a frame's document out at the zoomed size while showing it at the unzoomed one, so its+ * content is cut off or leaves empty bands.+ */+export function useDesktopFrameStyle(): CSSProperties {+ const scale = useDesktopScale()++ return useMemo(() => ({+ zoom: 1 / scale,+ width: `${100 / scale}%`,+ height: `${100 / scale}%`,+ transform: `scale(${scale})`,+ transformOrigin: "0 0"+ }), [scale])+}+/** Converts one physical browser distance into the Desktop coordinate space. */export function physicalToDesktopPixels(value: number, scale: number) {return value / scalediff --git a/source/client/view/structure/desktop/layers/wallpaper/wallpaper.tsx b/source/client/view/structure/desktop/layers/wallpaper/wallpaper.tsxindex a7a1c91..ccfe303 100644--- a/source/client/view/structure/desktop/layers/wallpaper/wallpaper.tsx+++ b/source/client/view/structure/desktop/layers/wallpaper/wallpaper.tsx@@ -5,6 +5,7 @@ import { useReady } from "@libs/readiness"import { wallpaperRequirement } from "../../../readiness-requirements"import { usePreferences, useTiming } from "@phreshos/react-ui"import { useReducedMotion } from "@libs/react-motion"+import { useDesktopFrameStyle } from "../../desktop-scale"import { cssEasing, wallpaperKind, type AppearanceWallpapers, type ThemedValue, type WallpaperKind } from "@phreshos/core"/** Where a wallpaper is shown. */@@ -137,6 +138,7 @@ function WallpaperLayer({ source, visible, onLoad, onError, onShown }: Readonly<const reducedMotion = useReducedMotion()const interactive = source.kind === "html" && visibleconst element = useRef<HTMLDivElement>(null)+ const frameStyle = useDesktopFrameStyle()const showing = useEffectEvent(() => onShown?.())// A frame after it becomes visible, a fade is running or none will: without one, it already shows.@@ -180,7 +182,8 @@ function WallpaperLayer({ source, visible, onLoad, onError, onShown }: Readonly</>}{source.kind === "html" && <iframe- className="h-full w-full border-0"+ className="border-0"+ style={frameStyle}src={source.url}title="Wallpaper"sandbox="allow-scripts"