diff --git a/apps/web/src/components/sidebar-right/inspector/background.tsx b/apps/web/src/components/sidebar-right/inspector/background.tsx index 705567a..00184a1 100644 --- a/apps/web/src/components/sidebar-right/inspector/background.tsx +++ b/apps/web/src/components/sidebar-right/inspector/background.tsx @@ -8,6 +8,7 @@ import { FloatingInspectorContent, FloatingInspectorHeader, FloatingInspectorTitle, + FloatingInspectorLayer, } from "@/components/ui/floating-inspector"; import { Icon } from "@/components/ui/icon"; import { PanelSection } from "@/components/ui/panel-section"; @@ -16,17 +17,24 @@ import { ColorOpacityRow } from "@/components/ui/color-opacity-row"; import { useEngine } from "@/context/engine"; import { Button } from "@/components/ui/button"; import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"; -import { createSignal } from "solid-js"; +import { createUniqueId, Show } from "solid-js"; import { DEFAULT_BACKGROUND, persistWorldState, useWorldState } from "@/components/engine"; +import { useActiveInspector } from "./active-inspector"; + +const OWNER = "background"; +// The background has no entity; a fixed id keys its single picker in the shared model. +const SLOT = 1; export function BackgroundSettings() { const { world } = useEngine(); - const [isPickerOpen, setIsPickerOpen] = createSignal(false); + const titleId = createUniqueId(); + const inspectors = useActiveInspector(); + const isPickerOpen = () => inspectors.currentId(OWNER) !== undefined; const color = useWorldState(w => w.background, DEFAULT_BACKGROUND); - let anchorRef: HTMLDivElement | undefined; + let sectionRef: HTMLDivElement | undefined; const assignColor = (next: number) => { world.background = next; @@ -34,47 +42,57 @@ export function BackgroundSettings() { }; return ( - - - setIsPickerOpen(true)} - /> - - - - - Color -
- - setIsPickerOpen(false)} - > - - - Close - -
-
- - +
+ + + world.history.startTransaction(label)} - onEndChange={() => world.history.commitTransaction()} - withoutOpacity + onChangeColor={assignColor} + onClick={() => inspectors.toggle(OWNER, SLOT)} /> - - - + + +
+ + + inspectors.close(OWNER)} + triggerRef={sectionRef} + triggerControlSelector="[data-row-control]" + labelledBy={titleId} + > + + + Color +
+ + inspectors.close(OWNER)} + > + + + Close + +
+
+ + world.history.startTransaction(label)} + onEndChange={() => world.history.commitTransaction()} + withoutOpacity + /> + +
+
+
+ ); }