Skip to content

Free open-source image editor for the browser

Use @roprgm/ui and refine the editor sidebar (#45)

Rodrigo Belfiore95d3a8d56d41
diff --git a/DESIGN.md b/DESIGN.md
index 0fbe994..031604d 100644
--- a/DESIGN.md
+++ b/DESIGN.md
@@ -1,16 +1,16 @@
# Interface design system
-OpenLight uses a small set of shared UI primitives so the editor reads as one application across tools and panels. They live in `src/components/ui`; floating parts are built on [Base UI](https://base-ui.com), which owns positioning, focus, dismissal, keyboard navigation, and ARIA.
+OpenLight uses a small set of shared UI primitives so the editor reads as one application across tools and panels. They come from [`@roprgm/ui`](https://ui.roprgm.com), imported per component as `@roprgm/ui/<name>`, with its theme imported in `src/index.css`; floating parts are built on [Base UI](https://base-ui.com), which owns positioning, focus, dismissal, keyboard navigation, and ARIA. `src/components/ui` keeps only what the library does not provide yet: `TextLink` and `TreeDrag`.
| Component | Use |
| --- | --- |
-| `Button`, `IconButton` | Actions. `IconButton` is a ghost icon button whose `label` names it and shows as its tooltip, with an optional `shortcut`. |
-| `Chip`, `ChipGroup` | Pill buttons in the bar over the canvas; `aria-pressed` shows a toggle on, and a group is segmented. |
+| `Button`, `IconButton` | Actions. `IconButton` is a ghost icon button whose `label` names it and shows as its tooltip, with an optional `shortcut`; use `size="icon-sm"` in headers, rows, and bars. |
+| `Chip` | Pill buttons in the bar over the canvas; `aria-pressed` shows a toggle on. A segmented group is a `fieldset` of chips. |
| `Tooltip` | A hint on hover or focus for any control, with an optional shortcut written as `Mod Z` (⌘ or Ctrl). |
-| `Menu`, `MenuItem`, `MenuSeparator`, `Submenu` | Commands such as Duplicate, Move, or Delete. |
+| `Menu`, `MenuItem`, `MenuSeparator`, `Submenu` | Commands such as Duplicate, Move, or Delete, opened from a `trigger` such as an `IconButton`. |
| `Select` | A choice that replaces a current value, with `field` or `pill` trigger. |
-| `Popover` | Settings that open beside a pill, such as bar controls that no longer fit. |
-| `Surface` | The elevated panel under every menu, select, and popover; popup parts render as one. |
+| `Popover` | Settings that open beside a `trigger`, such as bar controls that no longer fit. |
+| `Slider`, `ScrubInput`, `VerticalSlider` | Numbers. A `Slider` is `panel`, `toolbar`, or `compact`; `format` writes the value and whatever follows its digits reads as the unit. |
## Selection and menus
@@ -22,18 +22,18 @@ OpenLight uses a small set of shared UI primitives so the editor reads as one ap
## Tooltips
- Every icon-only control has a tooltip; use `IconButton` or wrap the control in `Tooltip`. Do not use the native `title` attribute.
-- A tooltip names the control in a few words and adds the shortcut beside it; longer guidance belongs in the panel or a canvas hint.
+- A tooltip names the control in a few words and adds the shortcut beside it; longer guidance belongs in the panel. The canvas shows only brief status, such as an error or a stroke finishing.
- A tooltip is not the accessible name. Keep `aria-label` on icon-only controls; `IconButton` sets it from `label`.
- Text that may be cut short, such as a layer name, shows its tooltip only when truncated.
## Panels
-- `EditorPanel` stacks its sections in the order written with a divider between each; `PanelBody` is the section that scrolls, and `PanelHeader` titles a section. The editing sidebar's order is the JSX in `app/editor/sidebar.tsx`.
+- `EditorPanel` stacks its sections in the order written with a divider between each; `PanelBody` is the section that takes the remaining height, with its `header` fixed above the part that scrolls. `PanelHeader` titles a section and rules it off. The layers section keeps room for three rows and shows, empty, before a document opens. The editing sidebar's order is the JSX in `app/editor/sidebar.tsx`.
- `EditorViewport` is the canvas region: a `ViewportStage` inside it pans and zooms with the image, and other children float over it without panning.
## Panel collections
-- Use `PanelListItem` for selectable rows in editor panels. It owns row height, divider, hover, muted, and selected states.
+- Use `ListItem` for selectable rows in editor panels. It owns row height, divider, hover, muted, and selected states.
- A row may compose its own thumbnail, label, compact fields, and action menu. Keep those feature-specific parts with the feature.
- Keep lists flush with the panel edges. Put empty-state copy inside the panel padding rather than padding every populated row.
@@ -42,18 +42,18 @@ OpenLight uses a small set of shared UI primitives so the editor reads as one ap
- Use shared components for repeated interaction and surface behavior. Keep feature-specific composition in the feature.
- Use Tailwind tokens already present in the shared primitive for color, borders, shadows, focus, and pointer-coarse sizing. A caller chooses a documented variant instead of recreating the surface.
- Anchor viewport-corner controls and messages 12 px from both edges. Tool overlays cover the full viewport; the camera preserves a 24 px margin around fitted content without shrinking that coordinate space.
-- Use `Notice` for a message floating over the viewport that must not block editing, such as a storage failure or an offer to recover a draft. Choose its `tone` (status or alert, which sets the ARIA role), `placement`, and `anchor` (the window, or the editor viewport it renders inside); pass `actions` for buttons under the message and `onDismiss` when the user may close it.
+- Use `Notice` for a message floating over the viewport that must not block editing, such as a storage failure or an offer to recover a draft. Choose its `tone` (status or alert, which sets the ARIA role) and position it with classes, `fixed` over the window or `absolute` inside the editor viewport; pass `actions` for buttons under the message and `onDismiss` when the user may close it.
- Use `TextLink` for an underlined link inside running text. It renders an anchor with `href` and a button otherwise; the `muted` variant stays in the sentence's color for secondary actions such as Forget.
-- Use `ScrubInput` for numbers that primarily read as inline text and secondarily accept typing. Inline variants hug the current digits and unit, keep their label close, and show only a subtly rounded background while text editing is active. Reserve the persistent bordered `box` variant for form fields that need explicit input chrome.
-- Give toolbar slider values an explicit minimum character width when their expected range changes digit count. Set it at the call site from the useful range: percentages reserve three tabular characters, while brush size uses the actual maximum's digit count. Do not guess a global maximum.
+- Use `ScrubInput` for numbers that read as inline text, drag sideways, and accept typing. It hugs its digits and unit and shows a subtly rounded background only while text editing is active.
+- Give toolbar slider values an explicit minimum character width (`valueWidth`) when their expected range changes digit count. It counts digits, with the unit after them: percentages reserve three tabular characters, while brush size uses the actual maximum's digit count. Do not guess a global maximum.
- Text uses the global body size. Express hierarchy with weight and color.
## Editor tools
How the rail, canvas bar, sidebar, and layer stack behave. Commands they call are in the [control API](API.md).
-The sidebar always shows the output histogram, the selected layer's controls under that layer's name (or Image), and the layer stack; layers and controls scroll independently. The zoom percentage counts image pixels per device pixel: clicking it at fit zooms to 100%, and anywhere else returns to fit. The rail holds tools: **A** Adjust, **B** Brush, **L** Linear gradient, **R** Radial gradient, **H** Healing, and **C** Crop; **E** opens Export from the header. A selected mask is *active*: the sidebar shows its adjustments and the bar its opacity. It is *edited* only while a shape tool is on the rail, which shows its guides or brush and the overlay; Adjust leaves the canvas to pan and zoom. Selecting a mask in the stack arms the tool of its shape; selecting the image or an effect returns to Adjust. **Enter**, or **Escape** with no drag in progress, leaves one level at a time: a shape tool returns to Adjust with the mask still selected, so its sliders stay at hand without guides over the image, and in Adjust the selection climbs to the parent mask, then to the image with its global controls. The shape's key or the mask's row enters editing again. Enter on a focused button stays its click. The bar over the image edits the active tool and the selected layer: the tool's options, then the layer's opacity, Overlay, and a radial mask's Feather or a child mask's operation. It never wraps: when the canvas is narrow it drops the slider bars, then moves the layer options and finally everything into a menu at its end. Dragging with a gradient tool draws a new mask above the selection; the tool stays active, and **Alt** while starting the drag subtracts the gradient from the selected mask instead. Choosing the Brush tool creates an empty brush mask above the selection at once, so adjustments made before the first stroke belong to it; leaving the tool while that mask has no strokes and nothing else changed removes it together with its history entry. A brush stroke paints into the selected brush mask, or starts a new brush mask. Creating inside a mask happens in the layer stack: each root mask row has Add and Subtract menus that choose a shape and nest the next mask inside it, and **Delete** removes the selected layer with any tool. The brush bar sets size, feather, flow, and paint or erase; **[** and **]** resize, holding **Alt** erases and shows Erase pressed, and **Escape** cancels the stroke. On a touch screen a second finger during a stroke cancels it and pinches instead, so painting and zooming never mix. The brush cursor previews the dab's feather and remains visible while Size or Feather is edited. Creating the mask and each stroke are separate undo steps.
+The sidebar always shows the output histogram, the layer stack, and the selected layer's controls under a title naming what they edit (Adjustments for the image, Mask adjustments for a mask, or the effect's kind); layers and controls scroll independently. The zoom percentage counts image pixels per device pixel: clicking it at fit zooms to 100%, and anywhere else returns to fit. The rail holds tools: **A** Adjust, **B** Brush, **L** Linear gradient, **R** Radial gradient, **H** Healing, and **C** Crop; **E** opens Export from the header. A selected mask is *active*: the sidebar shows its adjustments and the bar its opacity. It is *edited* only while a shape tool is on the rail, which shows its guides or brush and the overlay; Adjust leaves the canvas to pan and zoom. Selecting a mask in the stack arms the tool of its shape; selecting the image or an effect returns to Adjust. **Enter**, or **Escape** with no drag in progress, leaves one level at a time: a shape tool returns to Adjust with the mask still selected, so its sliders stay at hand without guides over the image, and in Adjust the selection climbs to the parent mask, then to the image with its global controls. The shape's key or the mask's row enters editing again. Enter on a focused button stays its click. The bar over the image edits the active tool and the selected layer: the tool's options, then the layer's opacity and a radial mask's Feather or a child mask's operation. It never wraps: when the canvas is narrow it drops the slider bars, then moves the layer options and finally everything into a menu at its end. Dragging with a gradient tool draws a new mask on top of the stack; the tool stays active, and **Alt** while starting the drag subtracts the gradient from the selected mask instead. Choosing the Brush tool creates an empty brush mask on top of the stack at once, so adjustments made before the first stroke belong to it; leaving the tool while that mask has no strokes and nothing else changed removes it together with its history entry. A brush stroke paints into the selected brush mask, or starts a new brush mask. Creating inside a mask happens in the layer stack: each root mask's actions menu has Add to mask and Subtract from mask submenus that choose a shape and nest the next mask inside it, and **Delete** removes the selected layer with any tool. The brush bar sets size, feather, flow, and paint or erase; **[** and **]** resize, holding **Alt** erases and shows Erase pressed, and **Escape** cancels the stroke. On a touch screen a second finger during a stroke cancels it and pinches instead, so painting and zooming never mix. The brush cursor previews the dab's feather and remains visible while Size or Feather is edited. Creating the mask and each stroke are separate undo steps.
**H** enters Healing and creates an empty Healing layer unless one is selected. Each stroke becomes a patch filled from a donor elsewhere in the image. Size sets the next stroke and never resizes an existing patch. Healing keeps its own next-stroke Feather, initially 10%, without changing the Brush tool. A selected patch exposes editable Feather and Opacity; feather softens the accumulated hard-stroke shape inward from its contour rather than expanding it or feathering every dab independently. A stroke whose brush does not reach the image is declined. Healing chooses a nearby donor automatically; **Alt-click** sets it manually, and Automatic source clears the override. Its boundary correction is bounded to avoid extreme color gains and remains independent of Feather and Opacity. A stroke's donor search keeps its history group open, so Size, Feather, or a handle drag started meanwhile joins that stroke's undo step. Each patch receives the visible result of every earlier patch in its layer. The sidebar numbers patches in replay order with each one's brush size and any lowered opacity; drawing, selection, and row hover show their destination contour and first-point anchor. Dragging the destination anchor moves the shape while its source stays fixed. A completed patch also shows a quieter source contour whose anchor moves its donor. **Escape** cancels painting or pending processing; Enter leaves after completion. Leaving an untouched new layer removes it.
-The red overlay shows a mask being edited that does not change the image yet: a gradient being drawn, or the selected mask while its adjustments and curve are default and its effects are off. Once the mask applies an effect, the image itself shows it, so painting continues without the tint. The Overlay button shows whether the overlay is visible; it and **O** show or hide the overlay for the selected mask in any tool, until another layer is selected. The tint follows the layer's opacity, which scales the mask's coverage. The curve's input histogram weighs pixels by that coverage, so it describes what the curve affects; it ignores opacity and stays available while the layer is hidden or at zero opacity. Selected masks stay editable: drag the center to move, guides to resize or rotate, and the radial inner handle or Feather slider to soften its edge. Shift constrains drawing; Escape cancels the gesture; Delete/Backspace removes the selected mask. Each gesture is one undo. A new mask shows a red overlay of its coverage until Enter leaves editing or its first adjustment; the overlay also shows while drawing or dragging a guide. Add/Subtract menus accept either gradient shape. **+** adds an effect, inside a selected top-level mask or above the selected sibling. Eye buttons toggle visibility; the inspector edits opacity. Drag a layer name to reorder (insertion line) or nest (highlighted row); the base stays locked and nesting is limited to two levels. Double-click a name to rename; the row menu also duplicates, deletes, reorders, or reparents. Image import still replaces the document; multiple image layers and additional blend modes are not implemented.
+The red overlay shows a mask being edited that does not change the image yet: a gradient being drawn, or the selected mask while its adjustments and curve are default and its effects are off. Once the mask applies an effect, the image itself shows it, so painting continues without the tint. The overlay button beside a mask's adjustments title shows whether the overlay is visible; it and **O** show or hide the overlay for the selected mask in any tool, and the choice holds for the next mask selected. The tint follows the layer's opacity, which scales the mask's coverage. The curve's input histogram weighs pixels by that coverage, so it describes what the curve affects; it ignores opacity and stays available while the layer is hidden or at zero opacity. Selected masks stay editable: drag the center to move, guides to resize or rotate, and the radial inner handle or Feather slider to soften its edge. Shift constrains drawing; Escape cancels the gesture; Delete/Backspace removes the selected mask. Each gesture is one undo. A new mask shows a red overlay of its coverage until Enter leaves editing or its first adjustment; the overlay also shows while drawing or dragging a guide. The Add and Subtract submenus offer either gradient or a brush. **+** adds an effect, inside a selected top-level mask or above the selected sibling. Eye buttons toggle visibility; the inspector edits opacity. Drag a layer name to reorder (insertion line) or nest (highlighted row); the base stays locked and nesting is limited to two levels. Double-click a name to rename; the row menu also duplicates, deletes, reorders, or reparents. Image import still replaces the document; multiple image layers and additional blend modes are not implemented.
diff --git a/README.md b/README.md
index bbee03f..1b4b492 100644
--- a/README.md
+++ b/README.md
@@ -21,14 +21,14 @@ Image processing runs on your own GPU with WebGPU. Photos never leave your devic
- Draggable effect layers: Details, Exposure, Color Mixer, Vignette, and Color, which paints one color with Photoshop blend modes.
- Linear and radial masks with their own adjustments and child effects.
-- Add and Subtract submasks to shape a mask's coverage.
+- Add and Subtract submasks, from a mask's actions menu, to shape its coverage.
**Tools**
- Healing paints patches from an automatic or manually positioned donor. Repairs remain editable and each patch builds on the previous result.
-- Brush, linear, and radial gradient tools on the rail draw masks; their options sit in the bar over the image.
+- Brush, linear, and radial gradient tools on the rail draw masks on top of the stack; their options sit in the bar over the image.
- Brush masks with size, feather, flow, pen pressure, and Alt to erase.
-- The mask overlay shows until a mask changes the image, then the image shows the mask; the Overlay button shows or hides it.
+- The mask overlay shows until a mask changes the image, then the image shows the mask; the overlay button beside the mask's adjustments, or O, shows or hides it for every mask.
- Edits preview at a reduced resolution while you drag, then render in full.
**Compose**
@@ -61,7 +61,7 @@ bun install
bun dev
```
-See [CONTRIBUTING.md](CONTRIBUTING.md) for browser setup, validation, benchmarks, and the pull request checklist. `window.openlight` exposes a scripting [API](API.md).
+The shared controls, such as buttons, sliders, menus, and panels, come from [@roprgm/ui](https://ui.roprgm.com). See [CONTRIBUTING.md](CONTRIBUTING.md) for browser setup, validation, benchmarks, and the pull request checklist. `window.openlight` exposes a scripting [API](API.md).
## License
diff --git a/bun.lock b/bun.lock
index 487d023..df8bd24 100644
--- a/bun.lock
+++ b/bun.lock
@@ -8,11 +8,12 @@
"@base-ui/react": "^1.8.0",
"@dnd-kit/core": "^6.3.1",
"@fontsource-variable/geist": "^5.3.0",
+ "@roprgm/ui": "^0.5.1",
"@tailwindcss/vite": "^4.3.3",
"@vercel/analytics": "^2.0.1",
"@vercel/speed-insights": "^2.0.0",
"class-variance-authority": "^0.7.1",
- "cn": "^0.2.4",
+ "cn": "^0.4.0",
"idb": "^8.0.3",
"raw-webgpu": "0.1.1",
"react": "^19.2.8",
@@ -128,6 +129,8 @@
"@rolldown/pluginutils": ["@rolldown/[email protected]", "", {}, "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw=="],
+ "@roprgm/ui": ["@roprgm/[email protected]", "", { "dependencies": { "@base-ui/react": "^1.8.0", "class-variance-authority": "^0.7.1", "cn": "^0.4.0" }, "peerDependencies": { "react": ">=19" } }, "sha512-OsqLRlvilblOILIfEEpZwG/gRRJCVvCy91Snfjzh9ADaiM/qoakt+cqr2IfXiXkf3Gf6XFy3vNnrVo9TqQqsaA=="],
+
"@tailwindcss/node": ["@tailwindcss/[email protected]", "", { "dependencies": { "@jridgewell/remapping": "^2.3.5", "enhanced-resolve": "^5.24.1", "jiti": "^2.7.0", "lightningcss": "1.32.0", "magic-string": "^0.30.21", "source-map-js": "^1.2.1", "tailwindcss": "4.3.3" } }, "sha512-/T8IKEsf9VTU6tLjgC7+sv2mOPtQxzE2jMw7u4Tt40Tx+QSZxpzh95/H6cMKoja9XuW7iMdLJYBB0o9G1CaAgg=="],
"@tailwindcss/oxide": ["@tailwindcss/[email protected]", "", { "optionalDependencies": { "@tailwindcss/oxide-android-arm64": "4.3.3", "@tailwindcss/oxide-darwin-arm64": "4.3.3", "@tailwindcss/oxide-darwin-x64": "4.3.3", "@tailwindcss/oxide-freebsd-x64": "4.3.3", "@tailwindcss/oxide-linux-arm-gnueabihf": "4.3.3", "@tailwindcss/oxide-linux-arm64-gnu": "4.3.3", "@tailwindcss/oxide-linux-arm64-musl": "4.3.3", "@tailwindcss/oxide-linux-x64-gnu": "4.3.3", "@tailwindcss/oxide-linux-x64-musl": "4.3.3", "@tailwindcss/oxide-wasm32-wasi": "4.3.3", "@tailwindcss/oxide-win32-arm64-msvc": "4.3.3", "@tailwindcss/oxide-win32-x64-msvc": "4.3.3" } }, "sha512-krXjAikiaFSPaK/FkAQT5UTx3VormQaiZ5hBFlJZ9UFQGB/rwg1MZIhHAG9smMQRTdyJxP6Qt5MwMtdyU5FWrA=="],
@@ -232,7 +235,7 @@
"clsx": ["[email protected]", "", {}, "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA=="],
- "cn": ["[email protected]", "", { "bin": { "cn": "bin/cn.mjs" } }, "sha512-SzQvoh5FwizWtQg9+JueKdjWhlfCZMdu5DqNHm9q1wUlRVmKb9WXlepR9bTTbPwzEOyX1ujJ6lcCppmn3bNUCg=="],
+ "cn": ["[email protected]", "", { "bin": { "cn": "bin/cn.mjs" } }, "sha512-qOAeUhPwPzBxx6jaeQdo646XIKliKHc2j1ZF7Ngb1o0pJZKH5gq8FkA0aVdUdPFUDXNXyUCXpCtoJISo6dhizg=="],
"csstype": ["[email protected]", "", {}, "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ=="],
diff --git a/package.json b/package.json
index 33ba83a..e5d8985 100644
--- a/package.json
+++ b/package.json
@@ -15,11 +15,12 @@
"@base-ui/react": "^1.8.0",
"@dnd-kit/core": "^6.3.1",
"@fontsource-variable/geist": "^5.3.0",
+ "@roprgm/ui": "^0.5.1",
"@tailwindcss/vite": "^4.3.3",
"@vercel/analytics": "^2.0.1",
"@vercel/speed-insights": "^2.0.0",
"class-variance-authority": "^0.7.1",
- "cn": "^0.2.4",
+ "cn": "^0.4.0",
"idb": "^8.0.3",
"raw-webgpu": "0.1.1",
"react": "^19.2.8",
diff --git a/public/og.png b/public/og.png
index 34abf0b..45ade05 100644
Binary files a/public/og.png and b/public/og.png differ
diff --git a/src/app/draft/notice.tsx b/src/app/draft/notice.tsx
index 9f3e1bd..9eebbc3 100644
--- a/src/app/draft/notice.tsx
+++ b/src/app/draft/notice.tsx
@@ -1,4 +1,4 @@
-import { Notice } from "@/components/ui/notice";
+import { Notice } from "@roprgm/ui/notice";
/** Draft storage failures stay out of the way: the editor keeps working and a scene file still saves the work. */
export function DraftNotice({
@@ -9,7 +9,10 @@ export function DraftNotice({
onDismiss: () => void;
}) {
return (
- <Notice onDismiss={onDismiss}>
+ <Notice
+ onDismiss={onDismiss}
+ className="fixed bottom-3 left-1/2 z-50 -translate-x-1/2"
+ >
Drafts can't be kept in this browser: {error} Save a scene from Export to
keep your edits.
</Notice>
diff --git a/src/app/editor/adjust/index.tsx b/src/app/editor/adjust/index.tsx
index 9bd08e4..b521527 100644
--- a/src/app/editor/adjust/index.tsx
+++ b/src/app/editor/adjust/index.tsx
@@ -1,10 +1,16 @@
+import { Slider } from "@roprgm/ui/slider";
import { useCallback } from "react";
import { useStore } from "zustand";
-import { PanelHeader } from "@/components/editor/panel";
+import { effectKinds } from "@/app/editor/layers";
+import { PanelBody, PanelHeader } from "@/components/editor/panel";
import { useRenderer } from "@/components/editor/pipeline";
import { useDocument, useScene } from "@/components/editor/session";
-import { Slider } from "@/components/ui/slider";
-import { adjustmentTarget, type Layer, type ToneCurve } from "@/core/document";
+import {
+ adjustmentTarget,
+ findLayer,
+ type Layer,
+ type ToneCurve,
+} from "@/core/document";
import { AdjustmentControls } from "@/features/adjustments/controls";
import { setExposure } from "@/features/adjustments/edits";
import { ColorMixerControls } from "@/features/color-mixer/controls";
@@ -12,12 +18,20 @@ import { DetailsControls } from "@/features/details/controls";
import { FillControls } from "@/features/fill/controls";
import { HealControls } from "@/features/heal/controls";
import { Histogram } from "@/features/histogram";
+import { OverlayToggle } from "@/features/layers/overlay-toggle";
import { setToneCurve } from "@/features/tone-curves/edits";
import { ToneCurves } from "@/features/tone-curves/tone-curves";
import { VignetteControls } from "@/features/vignette/controls";
import { WhiteBalanceControls } from "@/features/white-balance/controls";
import { useEditGesture } from "@/hooks/use-edit-gesture";
+/** Names what the controls edit, not the layer, whose name the stack already shows. */
+function panelTitle(layer: Layer) {
+ if (layer.kind === "image") return "Adjustments";
+ if (layer.kind === "mask") return "Mask adjustments";
+ return effectKinds.find((entry) => entry.kind === layer.kind)?.label;
+}
+
const curveHistogramColors = ["#a3a3a3"] as const;
function CurveInputHistogram({ id }: { id: string }) {
@@ -109,10 +123,20 @@ export function AdjustPanel() {
const target = useScene(
(scene) => adjustmentTarget(scene.layers, selected) ?? scene.layers[0],
);
+ const mask = useScene(
+ (scene) => findLayer(scene.layers, selected)?.kind === "mask",
+ );
return (
- <div {...gesture}>
- <PanelHeader title={target.kind === "image" ? "Image" : target.name} />
- <SelectedControls layer={target} />
- </div>
+ <PanelBody
+ header={
+ <PanelHeader title={panelTitle(target) ?? target.name}>
+ {mask && <OverlayToggle />}
+ </PanelHeader>
+ }
+ >
+ <div {...gesture}>
+ <SelectedControls layer={target} />
+ </div>
+ </PanelBody>
);
}
diff --git a/src/app/editor/clipping-controls.tsx b/src/app/editor/clipping-controls.tsx
index f2dfc8e..2ebc2d3 100644
--- a/src/app/editor/clipping-controls.tsx
+++ b/src/app/editor/clipping-controls.tsx
@@ -1,6 +1,6 @@
+import { IconButton } from "@roprgm/ui/icon-button";
import { useStore } from "zustand";
import { useDocument } from "@/components/editor/session";
-import { IconButton } from "@/components/ui/button";
export function ClippingControls() {
const { preview } = useDocument();
diff --git a/src/app/editor/comparison-control.tsx b/src/app/editor/comparison-control.tsx
index 0b9f7e0..e8568b0 100644
--- a/src/app/editor/comparison-control.tsx
+++ b/src/app/editor/comparison-control.tsx
@@ -1,7 +1,7 @@
+import { IconButton } from "@roprgm/ui/icon-button";
import { useEffect } from "react";
import { useStore } from "zustand";
import { useDocument } from "@/components/editor/session";
-import { IconButton } from "@/components/ui/button";
import type { Preview } from "@/core/document";
import { isTyping } from "@/lib/dom";
@@ -53,6 +53,7 @@ export function ComparisonControl() {
<IconButton
label="Compare before and after"
shortcut="Hold \"
+ size="icon-sm"
aria-pressed={comparison !== "edited"}
className="aria-pressed:bg-neutral-700 aria-pressed:text-neutral-100"
onClick={() =>
diff --git a/src/app/editor/empty.tsx b/src/app/editor/empty.tsx
index d9fe077..0aeb5bd 100644
--- a/src/app/editor/empty.tsx
+++ b/src/app/editor/empty.tsx
@@ -1,3 +1,6 @@
+import { Button } from "@roprgm/ui/button";
+import { Notice } from "@roprgm/ui/notice";
+import { Spinner } from "@roprgm/ui/spinner";
import { useRef } from "react";
import { type Gpu, target } from "vgpu";
import { useGpu } from "vgpu-react";
@@ -5,9 +8,6 @@ import { sceneExtension } from "@/app/loaders/scene";
import type { Workspace } from "@/app/workspace";
import { RendererProvider } from "@/components/editor/pipeline";
import { DocumentProvider } from "@/components/editor/session";
-import { Button } from "@/components/ui/button";
-import { Notice } from "@/components/ui/notice";
-import { Spinner } from "@/components/ui/spinner";
import { TextLink } from "@/components/ui/text-link";
import { createDocument, createResources } from "@/core/document";
import { createImageSource } from "@/core/image";
@@ -64,8 +64,7 @@ export type Recovery = {
function RecoverDraft({ onRecover, onForget }: Recovery) {
return (
<Notice
- anchor="viewport"
- placement="start"
+ className="absolute bottom-3 left-3 z-50"
actions={
<>
<Button onClick={onRecover}>Recover</Button>
@@ -82,7 +81,7 @@ function RecoverDraft({ onRecover, onForget }: Recovery) {
function Status({ state, onOpen }: { state: EmptyState } & OpenProps) {
if (state.status === "loading") {
- return <Spinner />;
+ return <Spinner className="size-5" />;
}
if (state.status === "error") {
return (
diff --git a/src/app/editor/export/index.tsx b/src/app/editor/export/index.tsx
index 6ba0af4..2372924 100644
--- a/src/app/editor/export/index.tsx
+++ b/src/app/editor/export/index.tsx
@@ -1,3 +1,8 @@
+import { Button } from "@roprgm/ui/button";
+import { ScrubInput } from "@roprgm/ui/scrub-input";
+import { Select } from "@roprgm/ui/select";
+import { Slider } from "@roprgm/ui/slider";
+import { Spinner } from "@roprgm/ui/spinner";
import { cn } from "cn";
import { type ReactNode, useMemo, useRef, useState } from "react";
import { useGpu } from "vgpu-react";
@@ -6,11 +11,6 @@ import { Image } from "@/components/editor/image";
import { EditorPanel, PanelBody, PanelHeader } from "@/components/editor/panel";
import { useDocument, useScene } from "@/components/editor/session";
import { EditorViewport, ViewportStage } from "@/components/editor/viewport";
-import { Button } from "@/components/ui/button";
-import { ScrubInput } from "@/components/ui/scrub-input";
-import { Select } from "@/components/ui/select";
-import { Slider } from "@/components/ui/slider";
-import { Spinner } from "@/components/ui/spinner";
import type { Point } from "@/core/image/frame";
import { useShortcuts } from "@/hooks/use-shortcuts";
import { type ExportFormat, exportImage, exportSize } from "./export-image";
@@ -76,12 +76,12 @@ function FormatSelect({
<Select
aria-label="Format"
value={value.id}
- options={formats.map((format) => ({
+ items={formats.map((format) => ({
value: format.id,
label: format.label,
}))}
- className="w-28"
- onChange={(id) => {
+ className="h-7 w-28"
+ onValueChange={(id) => {
const format = formats.find((format) => format.id === id);
if (format) onChange(format);
}}
@@ -93,6 +93,9 @@ function FormatSelect({
}
/** Width, height, and scale edit one long edge; extra rows share the grid. */
+const pixels = (value: number) => `${value}px`;
+const percent = (value: number) => `${value}%`;
+
function SizeFields({
size,
longEdge,
@@ -111,40 +114,38 @@ function SizeFields({
const scaleTo = (fraction: number) =>
onChange(Math.max(1, Math.round(maxEdge * fraction)));
return (
- <div className="grid grid-cols-[auto_1fr_1.5rem] items-center gap-x-3 gap-y-2 text-neutral-400">
+ // Units follow their digits, as in a slider; the values' 4px padding reaches past the file size's edge.
+ <div className="grid grid-cols-[auto_1fr] items-center gap-x-3 gap-y-2 text-neutral-400">
<span>Width</span>
- <div className="justify-self-end">
- <ScrubInput
- aria-label="Width"
- value={width}
- min={1}
- max={fullWidth}
- onChange={(value) => scaleTo(value / fullWidth)}
- />
- </div>
- <span className="text-neutral-500">px</span>
+ <ScrubInput
+ aria-label="Width"
+ value={width}
+ min={1}
+ max={fullWidth}
+ format={pixels}
+ className="-mr-1 justify-self-end"
+ onChange={(value) => scaleTo(value / fullWidth)}
+ />
<span>Height</span>
- <div className="justify-self-end">
- <ScrubInput
- aria-label="Height"
- value={height}
- min={1}
- max={fullHeight}
- onChange={(value) => scaleTo(value / fullHeight)}
- />
- </div>
- <span className="text-neutral-500">px</span>
+ <ScrubInput
+ aria-label="Height"
+ value={height}
+ min={1}
+ max={fullHeight}
+ format={pixels}
+ className="-mr-1 justify-self-end"
+ onChange={(value) => scaleTo(value / fullHeight)}
+ />
<span>Scale</span>
- <div className="justify-self-end">
- <ScrubInput
- aria-label="Scale"
- value={scale}
- min={1}
- max={100}
- onChange={(value) => scaleTo(value / 100)}
- />
- </div>
- <span className="text-neutral-500">%</span>
+ <ScrubInput
+ aria-label="Scale"
+ value={scale}
+ min={1}
+ max={100}
+ format={percent}
+ className="-mr-1 justify-self-end"
+ onChange={(value) => scaleTo(value / 100)}
+ />
{children}
</div>
);
@@ -185,7 +186,7 @@ function SaveScene() {
<p className="text-neutral-500">
Saves the photo and every edit in one file. Open it to continue editing.
</p>
- <Button className="w-full py-2" onClick={save}>
+ <Button className="w-full" onClick={save}>
Save scene
</Button>
{error && (
@@ -247,8 +248,7 @@ export function ExportMode({ onClose }: { onClose: () => void }) {
{pending && <LoadingOverlay />}
</EditorViewport>
<EditorPanel>
- <PanelHeader title="Export" onClose={onClose} />
- <PanelBody>
+ <PanelBody header={<PanelHeader title="Export" onClose={onClose} />}>
<section
aria-label="Image export"
className="flex flex-col gap-5 p-4"
@@ -268,7 +268,7 @@ export function ExportMode({ onClose }: { onClose: () => void }) {
<span>File size</span>
<span
className={cn(
- "col-span-2 flex items-center justify-end gap-1.5 text-neutral-100 tabular-nums",
+ "flex items-center justify-end gap-1.5 text-neutral-100 tabular-nums",
pending && "text-neutral-500",
)}
>
@@ -276,7 +276,7 @@ export function ExportMode({ onClose }: { onClose: () => void }) {
{pending && <Spinner className="size-3" />}
</span>
</SizeFields>
- <Button className="w-full py-2" onClick={save}>
+ <Button className="w-full" onClick={save}>
Save image
</Button>
{error && (
diff --git a/src/app/editor/header.tsx b/src/app/editor/header.tsx
index 563b095..2cf0a0e 100644
--- a/src/app/editor/header.tsx
+++ b/src/app/editor/header.tsx
@@ -1,5 +1,5 @@
+import { Tooltip } from "@roprgm/ui/tooltip";
import type { ReactNode } from "react";
-import { Tooltip } from "@/components/ui/tooltip";
/** Identity on the left, document actions on the right; present in every editor state. */
export function EditorHeader({
@@ -10,7 +10,7 @@ export function EditorHeader({
children?: ReactNode;
}) {
return (
- <header className="flex h-11 shrink-0 items-center gap-3 border-black border-b bg-panel px-3">
+ <header className="flex h-11 shrink-0 items-center gap-3 border-black border-b layer-panel px-3">
<span className="flex items-center gap-2">
<img src="/logo.svg" alt="" className="size-5" />
<span className="font-medium text-neutral-200">OpenLight</span>
diff --git a/src/app/editor/history.tsx b/src/app/editor/history.tsx
index aa4facb..28e06f0 100644
--- a/src/app/editor/history.tsx
+++ b/src/app/editor/history.tsx
@@ -1,7 +1,7 @@
+import { IconButton } from "@roprgm/ui/icon-button";
import { useStore } from "zustand";
import { useDocument } from "@/components/editor/session";
import { Icon } from "@/components/icons/icon";
-import { IconButton } from "@/components/ui/button";
import { useShortcuts } from "@/hooks/use-shortcuts";
export function HistoryControls() {
@@ -18,6 +18,7 @@ export function HistoryControls() {
<IconButton
label="Undo"
shortcut="Mod Z"
+ size="icon-sm"
disabled={!undoCount}
onClick={history.undo}
>
@@ -28,6 +29,7 @@ export function HistoryControls() {
<IconButton
label="Redo"
shortcut="Mod Shift Z"
+ size="icon-sm"
disabled={!redoCount}
onClick={history.redo}
>
diff --git a/src/app/editor/index.tsx b/src/app/editor/index.tsx
index f672cdb..b505da6 100644
--- a/src/app/editor/index.tsx
+++ b/src/app/editor/index.tsx
@@ -1,3 +1,5 @@
+import { Button } from "@roprgm/ui/button";
+import { Tooltip } from "@roprgm/ui/tooltip";
import type { ReactNode } from "react";
import type { Workspace } from "@/app/workspace";
import { BrushProvider } from "@/components/editor/brush-tool";
@@ -9,10 +11,8 @@ import {
useScene,
} from "@/components/editor/session";
import { EditorViewport, ViewportStage } from "@/components/editor/viewport";
-import { Button } from "@/components/ui/button";
-import { Tooltip } from "@/components/ui/tooltip";
import type { Mask } from "@/core/document";
-import { findLayer, locateLayer } from "@/core/document";
+import { locateLayer } from "@/core/document";
import { HealingProvider } from "@/features/heal/mode";
import { addLayer } from "@/features/layers/edits";
import { MaskToolProvider, type Nesting } from "@/features/layers/mask-tool";
@@ -77,7 +77,7 @@ function ExportButton() {
<Tooltip content="Export the photo or save a scene" shortcut="E">
<Button
aria-pressed={exporting}
- className="ml-1 aria-pressed:bg-neutral-600"
+ className="ml-1 h-7 px-4 aria-pressed:bg-raised-hover"
onClick={() => setTool(exporting ? tools[0] : exportTool)}
>
Export
@@ -90,17 +90,14 @@ function ExportButton() {
function MaskTools({ children }: { children: ReactNode }) {
const document = useDocument();
const { setTool } = useTool();
+ // A mask from the rail goes on top of the stack; one chosen from a mask's Add or Subtract menu goes inside it.
function addMask(mask: Mask, nesting: Nesting) {
- const scene = document.scene.getState();
- const selected = document.selection.getState().layerId;
- // A new top-level mask goes above the selection's root ancestor.
- const root =
- scene.layers.find((item) => findLayer([item], selected)) ??
- scene.layers[0];
- const placement = nesting.parentId
- ? { inside: nesting.parentId }
- : { above: root.id };
- addLayer(document, createMask(mask, nesting.operation), placement);
+ const layer = createMask(mask, nesting.operation);
+ if (nesting.parentId) {
+ addLayer(document, layer, { inside: nesting.parentId });
+ return;
+ }
+ addLayer(document, layer);
}
return (
<MaskToolProvider
diff --git a/src/app/editor/sidebar.tsx b/src/app/editor/sidebar.tsx
index 3ddaea2..28ca621 100644
--- a/src/app/editor/sidebar.tsx
+++ b/src/app/editor/sidebar.tsx
@@ -1,8 +1,8 @@
-import { EditorPanel, PanelBody } from "@/components/editor/panel";
+import { EditorPanel } from "@/components/editor/panel";
import { useDocument } from "@/components/editor/session";
import type { EffectLayer } from "@/core/document";
import { findLayer } from "@/core/document";
-import { LayersControls } from "@/features/layers/controls";
+import { LayersControls, LayersSection } from "@/features/layers/controls";
import { addLayer } from "@/features/layers/edits";
import { AdjustPanel } from "./adjust";
import { ImageHistogram } from "./histogram";
@@ -30,21 +30,18 @@ export function EditorSidebar() {
<EditorPanel>
<ImageHistogram />
<EditorLayers />
- <PanelBody>
- <AdjustPanel />
- </PanelBody>
+ <AdjustPanel />
</EditorPanel>
);
}
-/** Before a document opens, the sidebar shows default controls, dimmed, without a layer stack. */
+/** Before a document opens, the sidebar shows the same sections, dimmed, with an empty layer stack. */
export function PlaceholderSidebar() {
return (
<EditorPanel inert>
<ImageHistogram />
- <PanelBody>
- <AdjustPanel />
- </PanelBody>
+ <LayersSection />
+ <AdjustPanel />
</EditorPanel>
);
}
diff --git a/src/app/editor/tool-rail.tsx b/src/app/editor/tool-rail.tsx
index f0dfc3b..0560cbf 100644
--- a/src/app/editor/tool-rail.tsx
+++ b/src/app/editor/tool-rail.tsx
@@ -1,6 +1,6 @@
+import { Tab, TabList } from "@roprgm/ui/tabs";
+import { Tooltip } from "@roprgm/ui/tooltip";
import { GithubIcon } from "@/components/icons/github";
-import { Tab, TabList } from "@/components/ui/tabs";
-import { Tooltip } from "@/components/ui/tooltip";
import { useShortcuts } from "@/hooks/use-shortcuts";
import { type Tool, tools, useTool } from "./tools";
@@ -14,7 +14,7 @@ export function ToolTabList({
}) {
const editing = tools.filter((entry) => entry.group === "edit");
return (
- <div className="flex shrink-0 gap-1 overflow-auto border-black border-b bg-panel p-1.5 md:w-11 md:flex-col md:border-r md:border-b-0">
+ <div className="flex shrink-0 gap-1 overflow-auto border-black border-b layer-panel p-1.5 md:w-11 md:flex-col md:border-r md:border-b-0">
<TabList aria-label="Tools" className="md:flex-col">
{editing.map((entry) => (
<Tooltip
diff --git a/src/components/editor/brush-canvas.tsx b/src/components/editor/brush-canvas.tsx
index 12ec5ab..3c82fb2 100644
--- a/src/components/editor/brush-canvas.tsx
+++ b/src/components/editor/brush-canvas.tsx
@@ -37,7 +37,6 @@ type PointerLike = {
/** Shared pressure-aware brush input and cursor. The caller owns the scene edit. */
export function BrushCanvas({
label,
- hint,
erase,
feather,
onStart,
@@ -49,7 +48,6 @@ export function BrushCanvas({
children,
}: {
label: string;
- hint?: string;
erase: boolean;
/** Overrides the shared brush feather for tools that own their stroke softness. */
feather?: number;
@@ -253,7 +251,7 @@ export function BrushCanvas({
const radius = brush.settings.size / 2 / mapping.pixelsPerViewportPixel;
const color = erase ? "black" : "white";
const dash = erase ? "4 3" : undefined;
- const status = error ?? (busy ? "Finishing stroke…" : hint);
+ const status = error ?? (busy ? "Finishing stroke…" : undefined);
const cursor = pointerVisible || brush.preview ? pointer : null;
return (
<div
diff --git a/src/components/editor/panel.tsx b/src/components/editor/panel.tsx
index d40009b..394951f 100644
--- a/src/components/editor/panel.tsx
+++ b/src/components/editor/panel.tsx
@@ -1,48 +1,54 @@
+import { IconButton } from "@roprgm/ui/icon-button";
+import {
+ PanelBody as Body,
+ PanelHeader as Header,
+ Panel,
+} from "@roprgm/ui/panel";
import type { ComponentProps, ReactNode } from "react";
import { CloseIcon } from "@/components/icons/close";
-import { IconButton } from "@/components/ui/button";
-import { ResizablePanel } from "@/components/ui/resizable-panel";
-import { ScrollArea } from "@/components/ui/scroll-area";
import { useEditorSession } from "./session";
/**
- * The resizable side panel. Its sections stack in the order written, with a divider between each;
- * give one a PanelBody to scroll. An inert panel shows its contents dimmed and unresponsive.
+ * The resizable side panel, a bottom sheet on mobile. Its sections stack in the order written,
+ * with a divider between each; give one a PanelBody to scroll. An inert panel dims its contents.
*/
-export function EditorPanel({
- inert,
- children,
- ...props
-}: ComponentProps<"aside">) {
+export function EditorPanel({ inert, ...props }: ComponentProps<"aside">) {
const { width, onWidthChange } = useEditorSession();
return (
- <ResizablePanel width={width} onWidthChange={onWidthChange} {...props}>
- <div
- inert={inert}
- data-inert={inert}
- className="flex h-full min-h-0 flex-col divide-y divide-black data-[inert=true]:opacity-50"
- >
- {children}
- </div>
- </ResizablePanel>
+ <Panel
+ width={width}
+ onWidthChange={onWidthChange}
+ inert={inert}
+ // Inert content is already hidden from assistive technology; say so for tools that read ARIA only.
+ aria-hidden={inert}
+ data-inert={inert}
+ // A black edge parts it from the canvas: along the top as a bottom sheet, on the left beside it.
+ className="layer-panel h-[45%] divide-black border-black max-md:w-full! max-md:border-t md:h-auto md:border-l data-[inert=true]:*:opacity-50"
+ {...props}
+ />
);
}
-/** The panel section that takes the remaining height and scrolls. */
-export function PanelBody({ children }: { children: ReactNode }) {
+/** The section that takes the remaining height: its header stays put while the rest scrolls. */
+export function PanelBody({
+ header,
+ children,
+}: {
+ header: ReactNode;
+ children: ReactNode;
+}) {
return (
- <ScrollArea
- fade
- className="flex-1"
- role="region"
+ <section
aria-label="Editor controls"
+ className="flex min-h-0 flex-1 flex-col"
>
- {children}
- </ScrollArea>
+ {header}
+ <Body>{children}</Body>
+ </section>
);
}
-/** A title with optional actions and a close button, sized to the panel row. */
+/** A title with optional actions and a close button, ruled off from what follows. */
export function PanelHeader({
title,
children,
@@ -53,14 +59,18 @@ export function PanelHeader({
onClose?: () => void;
}) {
return (
- <div className="flex h-10 shrink-0 items-center gap-1 border-b border-black/50 pr-1.5 pl-3">
- <h2 className="flex-1 font-medium text-neutral-200">{title}</h2>
+ <Header title={title} className="border-black/50 border-b">
{children}
{onClose && (
- <IconButton label="Close" shortcut="Esc" onClick={onClose}>
+ <IconButton
+ label="Close"
+ shortcut="Esc"
+ size="icon-sm"
+ onClick={onClose}
+ >
<CloseIcon className="size-4" />
</IconButton>
)}
- </div>
+ </Header>
);
}
diff --git a/src/components/editor/pipeline.tsx b/src/components/editor/pipeline.tsx
index e6d6aff..fe69fe0 100644
--- a/src/components/editor/pipeline.tsx
+++ b/src/components/editor/pipeline.tsx
@@ -1,3 +1,4 @@
+import { Notice } from "@roprgm/ui/notice";
import {
createContext,
type ReactNode,
@@ -7,7 +8,6 @@ import {
} from "react";
import type { Gpu } from "vgpu";
import { useGpu } from "vgpu-react";
-import { Notice } from "@/components/ui/notice";
import { adjustmentTarget } from "@/core/document";
import type { ImageSource } from "@/core/image";
import type { createRenderer } from "@/core/renderer";
@@ -28,7 +28,7 @@ export function useRenderer() {
function RendererError({ message }: { message: string }) {
return (
- <Notice tone="alert" placement="start">
+ <Notice tone="alert" className="fixed bottom-3 left-3 z-50">
Renderer error: {message}
</Notice>
);
diff --git a/src/components/editor/viewport.tsx b/src/components/editor/viewport.tsx
index a936150..0a8c200 100644
--- a/src/components/editor/viewport.tsx
+++ b/src/components/editor/viewport.tsx
@@ -1,8 +1,9 @@
+import { Button } from "@roprgm/ui/button";
+import { IconButton } from "@roprgm/ui/icon-button";
+import { Tooltip } from "@roprgm/ui/tooltip";
import { createContext, type ReactNode, useContext } from "react";
import { Canvas } from "vgpu-react";
import { Icon } from "@/components/icons/icon";
-import { Button, IconButton } from "@/components/ui/button";
-import { Tooltip } from "@/components/ui/tooltip";
import type { Point } from "@/core/image/frame";
import { usePanZoom } from "@/hooks/use-pan-zoom";
import { useEditorSession } from "./session";
@@ -38,7 +39,7 @@ function ZoomControl() {
<Tooltip content={fitted ? "Zoom to 100%" : "Fit to view"} side="top">
<Button
variant="ghost"
- className="min-w-14 rounded-full px-1 py-0.5 text-neutral-200 tabular-nums"
+ className="h-6 min-w-14 rounded-full px-1 text-neutral-200 tabular-nums"
onClick={() =>
fitted ? zoomTo(1 / (scale * devicePixelRatio)) : resetView()
}
diff --git a/src/components/ui/button.tsx b/src/components/ui/button.tsx
deleted file mode 100644
index e8e1f25..0000000
--- a/src/components/ui/button.tsx
+++ /dev/null
@@ -1,57 +0,0 @@
-import { cva, type VariantProps } from "class-variance-authority";
-import { cn } from "cn";
-import type { ComponentProps } from "react";
-import { Tooltip } from "./tooltip";
-
-const button = cva(
- "cursor-pointer rounded-md transition-colors focus-visible:outline-1 focus-visible:outline-offset-1 focus-visible:outline-neutral-400/80 disabled:pointer-events-none disabled:opacity-40",
- {
- variants: {
- variant: {
- default:
- "bg-neutral-700 text-neutral-100 shadow-ridge hover:bg-neutral-600 active:bg-neutral-700 active:shadow-groove",
- ghost:
- "text-neutral-400 hover:bg-neutral-700/50 hover:text-neutral-100 active:bg-neutral-700 data-popup-open:bg-neutral-700/50 data-popup-open:text-neutral-100",
- },
- /** Both sizes pad 6 px vertically, so text and 16 px icons produce the same height. */
- size: {
- default: "px-4 py-1.5",
- icon: "grid place-items-center p-1.5",
- },
- },
- defaultVariants: { variant: "default", size: "default" },
- },
-);
-
-export function Button({
- className,
- variant,
- size,
- ...props
-}: ComponentProps<"button"> & VariantProps<typeof button>) {
- return (
- <button
- className={cn(button({ variant, size }), className)}
- type="button"
- {...props}
- />
- );
-}
-
-/** A ghost icon button; its label names it for assistive technology and shows as its tooltip. */
-export function IconButton({
- label,
- shortcut,
- side,
- ...props
-}: ComponentProps<typeof Button> & {
- label: string;
- shortcut?: string;
- side?: ComponentProps<typeof Tooltip>["side"];
-}) {
- return (
- <Tooltip content={label} shortcut={shortcut} side={side}>
- <Button variant="ghost" size="icon" aria-label={label} {...props} />
- </Tooltip>
- );
-}
diff --git a/src/components/ui/chip.tsx b/src/components/ui/chip.tsx
deleted file mode 100644
index 805052f..0000000
--- a/src/components/ui/chip.tsx
+++ /dev/null
@@ -1,42 +0,0 @@
-import { cva, type VariantProps } from "class-variance-authority";
-import { cn } from "cn";
-import type { ComponentProps } from "react";
-
-const chip = cva(
- "shrink-0 cursor-pointer rounded-full px-2.5 whitespace-nowrap text-neutral-400 transition-colors hover:bg-white/10 hover:text-neutral-100 focus-visible:outline-1 focus-visible:outline-neutral-400/80 aria-pressed:bg-white/15 aria-pressed:text-neutral-100 data-popup-open:bg-white/15 data-popup-open:text-neutral-100",
- {
- variants: {
- /** "segment" sits inside a ChipGroup. */
- size: {
- default: "h-7 pointer-coarse:h-9",
- segment: "h-6 pointer-coarse:h-8",
- },
- },
- defaultVariants: { size: "default" },
- },
-);
-
-/** A pill button for the bar over the canvas; `aria-pressed` shows it on. */
-export function Chip({
- className,
- size,
- ...props
-}: ComponentProps<"button"> & VariantProps<typeof chip>) {
- return (
- <button
- type="button"
- className={cn(chip({ size }), className)}
- {...props}
- />
- );
-}
-
-/** Segmented chips, one of which is pressed. */
-export function ChipGroup({ className, ...props }: ComponentProps<"fieldset">) {
- return (
- <fieldset
- className={cn("flex gap-0.5 rounded-full bg-white/5 p-0.5", className)}
- {...props}
- />
- );
-}
diff --git a/src/components/ui/field.tsx b/src/components/ui/field.tsx
deleted file mode 100644
index dc2ba33..0000000
--- a/src/components/ui/field.tsx
+++ /dev/null
@@ -1,29 +0,0 @@
-import { cva } from "class-variance-authority";
-import { cn } from "cn";
-import type { ComponentProps } from "react";
-
-type FieldProps = ComponentProps<"span"> & {
- /**
- * "box" always shows the chrome; "text" reads as plain text until focused, then sinks a little;
- * "pill" keeps the bar's control height without adding permanent chrome.
- */
- variant?: "box" | "text" | "pill";
-};
-
-const chrome = cva("", {
- variants: {
- variant: {
- box: "rounded border border-black bg-neutral-900 px-1 py-0.5 shadow-groove focus-within:ring-1 focus-within:ring-white/10",
- text: "rounded-[2px] px-0.5 py-0.5 focus-within:bg-black/25",
- pill: "h-7 rounded-[2px] px-0.5 focus-within:bg-black/25 pointer-coarse:h-9",
- },
- },
-});
-
-/**
- * Sunken chrome around a bare form control (input, select, textarea).
- * The child styles itself with `w-full bg-transparent outline-none`.
- */
-export function Field({ variant = "box", className, ...props }: FieldProps) {
- return <span className={cn(chrome({ variant }), className)} {...props} />;
-}
diff --git a/src/components/ui/menu.tsx b/src/components/ui/menu.tsx
deleted file mode 100644
index 7c07009..0000000
--- a/src/components/ui/menu.tsx
+++ /dev/null
@@ -1,103 +0,0 @@
-import { Menu as Primitive } from "@base-ui/react/menu";
-import { cn } from "cn";
-import { type ComponentProps, type ReactNode, useState } from "react";
-import { Icon } from "@/components/icons/icon";
-import { Button } from "./button";
-import { Chip } from "./chip";
-import { Surface } from "./surface";
-import { Tooltip } from "./tooltip";
-
-/**
- * A button that opens a list of commands. The label names the button and shows as its tooltip.
- * Items mount only while the menu is open. For settings, use a Popover.
- */
-export function Menu({
- label,
- icon,
- variant = "row",
- children,
-}: {
- label: string;
- icon: ReactNode;
- /** "row" sits in a panel row; "pill" sits in the bar over the canvas. */
- variant?: "row" | "pill";
- children: ReactNode;
-}) {
- // The tooltip steps aside while the menu is open, so Escape closes the menu.
- const [open, setOpen] = useState(false);
- return (
- <Primitive.Root open={open} onOpenChange={setOpen}>
- <Tooltip content={label} disabled={open}>
- <Primitive.Trigger
- aria-label={label}
- render={
- variant === "pill" ? (
- <Chip className="grid place-items-center px-2" />
- ) : (
- <Button
- variant="ghost"
- size="icon"
- className="pointer-coarse:size-10"
- />
- )
- }
- >
- {icon}
- </Primitive.Trigger>
- </Tooltip>
- <Primitive.Portal>
- <Primitive.Positioner sideOffset={4} align="end" className="z-50">
- <Primitive.Popup render={(props) => <Surface {...props} />}>
- {children}
- </Primitive.Popup>
- </Primitive.Positioner>
- </Primitive.Portal>
- </Primitive.Root>
- );
-}
-
-export function MenuItem({
- className,
- ...props
-}: ComponentProps<typeof Primitive.Item>) {
- return (
- <Primitive.Item
- className={cn(
- "flex cursor-default items-center gap-2 rounded-md px-2.5 py-1.5 outline-none select-none data-disabled:text-neutral-600 data-highlighted:bg-white/8",
- className,
- )}
- {...props}
- />
- );
-}
-
-export function MenuSeparator() {
- return <Primitive.Separator className="mx-1 my-1 h-px bg-white/10" />;
-}
-
-/** An item that opens a nested list of commands beside the menu. */
-export function Submenu({
- label,
- children,
-}: {
- label: string;
- children: ReactNode;
-}) {
- return (
- <Primitive.SubmenuRoot>
- <Primitive.SubmenuTrigger className="flex cursor-default items-center justify-between gap-4 rounded-md px-2.5 py-1.5 outline-none select-none data-highlighted:bg-white/8 data-popup-open:bg-white/8">
- {label}
- <Icon className="size-3 text-neutral-400">
- <path d="m9 5 7 7-7 7" />
- </Icon>
- </Primitive.SubmenuTrigger>
- <Primitive.Portal>
- <Primitive.Positioner sideOffset={4} alignOffset={-4} className="z-50">
- <Primitive.Popup render={(props) => <Surface {...props} />}>
- {children}
- </Primitive.Popup>
- </Primitive.Positioner>
- </Primitive.Portal>
- </Primitive.SubmenuRoot>
- );
-}
diff --git a/src/components/ui/notice.tsx b/src/components/ui/notice.tsx
deleted file mode 100644
index c25bf50..0000000
--- a/src/components/ui/notice.tsx
+++ /dev/null
@@ -1,70 +0,0 @@
-import { cva, type VariantProps } from "class-variance-authority";
-import { cn } from "cn";
-import type { ComponentProps, ReactNode } from "react";
-import { CloseIcon } from "@/components/icons/close";
-import { IconButton } from "./button";
-
-const notice = cva(
- "bottom-3 z-50 flex max-w-sm items-start gap-2 rounded-lg border border-black/60 bg-neutral-800 py-2 pl-3 shadow-float",
- {
- variants: {
- /** Status messages read as ordinary text; alerts are red and interrupt assistive technology. */
- tone: {
- status: "text-neutral-300",
- alert: "text-red-300",
- },
- /** 12 px from the edge, or centered along it. */
- placement: {
- start: "left-3",
- center: "-translate-x-1/2 left-1/2",
- },
- /** Over the whole window, or inside the nearest positioned ancestor such as the editor viewport. */
- anchor: {
- window: "fixed",
- viewport: "absolute",
- },
- },
- defaultVariants: { tone: "status", placement: "center", anchor: "window" },
- },
-);
-
-type NoticeProps = ComponentProps<"div"> &
- VariantProps<typeof notice> & {
- /** Buttons shown under the message. */
- actions?: ReactNode;
- onDismiss?: () => void;
- };
-
-/** A message floating over the viewport that doesn't block the editor. */
-export function Notice({
- className,
- tone,
- placement,
- anchor,
- actions,
- onDismiss,
- children,
- ...props
-}: NoticeProps) {
- return (
- <div
- role={tone === "alert" ? "alert" : "status"}
- className={cn(
- notice({ tone, placement, anchor }),
- onDismiss || "pr-3",
- className,
- )}
- {...props}
- >
- <div className="flex flex-col gap-2">
- <p>{children}</p>
- {actions && <div className="flex gap-2">{actions}</div>}
- </div>
- {onDismiss && (
- <IconButton label="Dismiss" className="mr-1" onClick={onDismiss}>
- <CloseIcon />
- </IconButton>
- )}
- </div>
- );
-}
diff --git a/src/components/ui/panel-list.tsx b/src/components/ui/panel-list.tsx
deleted file mode 100644
index d773539..0000000
--- a/src/components/ui/panel-list.tsx
+++ /dev/null
@@ -1,24 +0,0 @@
-import { cn } from "cn";
-import { type ComponentProps, forwardRef } from "react";
-
-/** Shared row chrome for selectable collections in editor panels. */
-export const PanelListItem = forwardRef<
- HTMLDivElement,
- ComponentProps<"div"> & { selected?: boolean; muted?: boolean }
->(function PanelListItem(
- { selected = false, muted = false, className, ...props },
- ref,
-) {
- return (
- <div
- {...props}
- ref={ref}
- data-selected={selected}
- data-muted={muted}
- className={cn(
- "group relative flex h-10 items-center border-b border-black/50 text-neutral-300 pointer-coarse:h-12 data-[selected=false]:hover:bg-white/5 data-[selected=true]:bg-neutral-700 data-[muted=true]:text-neutral-500",
- className,
- )}
- />
- );
-});
diff --git a/src/components/ui/popover.tsx b/src/components/ui/popover.tsx
deleted file mode 100644
index 2d72ce9..0000000
--- a/src/components/ui/popover.tsx
+++ /dev/null
@@ -1,37 +0,0 @@
-import { Popover as Primitive } from "@base-ui/react/popover";
-import { type ReactNode, useState } from "react";
-import { Chip } from "./chip";
-import { Surface } from "./surface";
-import { Tooltip } from "./tooltip";
-
-/** A pill that opens settings beside it, such as bar controls that no longer fit. */
-export function Popover({
- label,
- icon,
- children,
-}: {
- label: string;
- icon: ReactNode;
- children: ReactNode;
-}) {
- const [open, setOpen] = useState(false);
- return (
- <Primitive.Root open={open} onOpenChange={setOpen}>
- <Tooltip content={label} disabled={open}>
- <Primitive.Trigger
- aria-label={label}
- render={<Chip className="grid place-items-center px-2" />}
- >
- {icon}
- </Primitive.Trigger>
- </Tooltip>
- <Primitive.Portal>
- <Primitive.Positioner sideOffset={4} align="end" className="z-50">
- <Primitive.Popup render={(props) => <Surface {...props} />}>
- {children}
- </Primitive.Popup>
- </Primitive.Positioner>
- </Primitive.Portal>
- </Primitive.Root>
- );
-}
diff --git a/src/components/ui/resizable-panel.tsx b/src/components/ui/resizable-panel.tsx
deleted file mode 100644
index f3abacc..0000000
--- a/src/components/ui/resizable-panel.tsx
+++ /dev/null
@@ -1,45 +0,0 @@
-import { cn } from "cn";
-import type { ComponentProps, PointerEvent } from "react";
-
-type ResizablePanelProps = ComponentProps<"aside"> & {
- width?: number;
- onWidthChange?: (width: number) => void;
- min?: number;
- max?: number;
-};
-
-/** Bottom panel on mobile; right-side panel with a draggable left edge on desktop. */
-export function ResizablePanel({
- width = 320,
- onWidthChange,
- min = 240,
- max = 400,
- className,
- style,
- children,
- ...props
-}: ResizablePanelProps) {
- const resize = (event: PointerEvent) =>
- event.buttons === 1 &&
- onWidthChange?.(Math.min(max, Math.max(min, width - event.movementX)));
-
- return (
- <aside
- className={cn(
- "relative h-[45%] shrink-0 bg-panel max-md:w-full! max-md:border-t max-md:border-black md:h-auto",
- className,
- )}
- style={{ width, ...style }}
- {...props}
- >
- <div
- className="absolute inset-y-0 -left-1 z-20 hidden w-2 cursor-col-resize touch-none after:absolute after:inset-y-0 after:left-1 after:w-px after:bg-black hover:after:bg-neutral-600 after:transition-colors after:duration-200 md:block"
- onPointerDown={(event) =>
- event.currentTarget.setPointerCapture(event.pointerId)
- }
- onPointerMove={resize}
- />
- {children}
- </aside>
- );
-}
diff --git a/src/components/ui/scroll-area.tsx b/src/components/ui/scroll-area.tsx
deleted file mode 100644
index adab0cc..0000000
--- a/src/components/ui/scroll-area.tsx
+++ /dev/null
@@ -1,37 +0,0 @@
-import { ScrollArea as Primitive } from "@base-ui/react/scroll-area";
-import { cn } from "cn";
-import type { ComponentProps } from "react";
-
-type ScrollAreaProps = ComponentProps<"div"> & {
- /** Shade an edge while content is clipped beyond it. */
- fade?: boolean;
-};
-
-export function ScrollArea({
- children,
- className,
- fade = false,
- ...props
-}: ScrollAreaProps) {
- return (
- <Primitive.Root
- className={cn("relative min-h-0 overflow-hidden", className)}
- {...props}
- >
- <Primitive.Viewport
- className={cn(
- "h-full overscroll-contain focus-visible:outline focus-visible:outline-neutral-500 focus-visible:-outline-offset-1",
- fade &&
- "before:pointer-events-none before:sticky before:top-0 before:z-10 before:-mb-6 before:block before:h-6 before:bg-linear-to-b before:from-black/40 before:opacity-0 before:transition-opacity data-overflow-y-start:before:opacity-100 after:pointer-events-none after:sticky after:bottom-0 after:z-10 after:-mt-6 after:block after:h-6 after:bg-linear-to-t after:from-black/40 after:opacity-0 after:transition-opacity data-overflow-y-end:after:opacity-100",
- )}
- >
- <Primitive.Content style={{ minWidth: 0 }}>
- {children}
- </Primitive.Content>
- </Primitive.Viewport>
- <Primitive.Scrollbar className="group z-10 my-1 mr-px flex w-1.5 justify-center">
- <Primitive.Thumb className="w-1 rounded-full bg-neutral-400/60 group-hover:bg-neutral-300 group-data-scrolling:bg-neutral-300" />
- </Primitive.Scrollbar>
- </Primitive.Root>
- );
-}
diff --git a/src/components/ui/scrub-input.tsx b/src/components/ui/scrub-input.tsx
deleted file mode 100644
index 38b57d8..0000000
--- a/src/components/ui/scrub-input.tsx
+++ /dev/null
@@ -1,159 +0,0 @@
-import { cva } from "class-variance-authority";
-import { cn } from "cn";
-import {
- type ComponentProps,
- type PointerEvent,
- useRef,
- useState,
-} from "react";
-import { Field } from "./field";
-
-type ScrubInputProps = Omit<
- ComponentProps<"input">,
- "onChange" | "type" | "value" | "min" | "max" | "step"
-> & {
- /** Rendered inline before the field; omit it inside an already-labeled row. */
- label?: string;
- value: number;
- onChange: (value: number) => void;
- onEditingChange?: (editing: boolean) => void;
- min: number;
- max: number;
- step?: number;
- /** Minimum width of the numeric part in tabular characters. */
- minChars?: number;
- /** Follows the number after a hair of space, in a quieter color. */
- unit?: string;
- /**
- * "box" always shows the field chrome; "text" reads as plain text until edited and hugs its digits;
- * "pill" is "text" shaped like the other controls in the bar over the canvas.
- */
- variant?: "box" | "text" | "pill";
-};
-
-const input = cva(
- "cursor-ew-resize bg-transparent text-neutral-100 tabular-nums outline-none selection:bg-white/20 focus:cursor-text",
- {
- variants: {
- variant: {
- box: "w-full text-center",
- text: "text-right",
- pill: "text-right",
- },
- },
- },
-);
-
-type Drag = { dx: number; lastX: number; value: number; moved: boolean };
-
-/** Numeric field that edits on click and scrubs the value on horizontal drag. */
-export function ScrubInput({
- label,
- value,
- onChange,
- onEditingChange,
- min,
- max,
- step = 1,
- minChars = 1,
- unit,
- variant = "box",
- className,
- ...props
-}: ScrubInputProps) {
- const decimals = `${step}`.split(".")[1]?.length ?? 0;
- const [draft, setDraft] = useState<string>();
- const drag = useRef<Drag | undefined>(undefined);
- const shown = draft ?? value.toFixed(decimals);
- const chars = Math.max(1, shown.length);
-
- const clamp = (next: number) =>
- Math.min(max, Math.max(min, Number(next.toFixed(decimals))));
-
- const commit = () => {
- if (draft && !Number.isNaN(Number(draft))) onChange(clamp(Number(draft)));
- setDraft(undefined);
- onEditingChange?.(false);
- };
-
- const startScrub = (event: PointerEvent<HTMLInputElement>) => {
- if (document.activeElement === event.currentTarget) return;
- event.preventDefault();
- event.currentTarget.setPointerCapture(event.pointerId);
- drag.current = { dx: 0, lastX: event.clientX, value, moved: false };
- onEditingChange?.(true);
- };
-
- const scrub = (event: PointerEvent<HTMLInputElement>) => {
- const state = drag.current;
- if (!state) return;
- // Under pointer lock clientX freezes, so deltas come from movementX.
- const locked = document.pointerLockElement === event.currentTarget;
- state.dx += locked ? event.movementX : event.clientX - state.lastX;
- state.lastX = event.clientX;
- if (!state.moved && Math.abs(state.dx) > 2) {
- state.moved = true;
- // Lock hides the cursor so the drag is unbounded by screen edges.
- Promise.resolve(event.currentTarget.requestPointerLock()).catch(() => {});
- }
- // Range-based speed so every control sweeps its full range in ~250px.
- if (state.moved)
- onChange(clamp(state.value + (state.dx * (max - min)) / 250));
- };
-
- const endScrub = (event: PointerEvent<HTMLInputElement>) => {
- const state = drag.current;
- drag.current = undefined;
- if (!state) return;
- if (state.moved) {
- document.exitPointerLock();
- onEditingChange?.(false);
- return;
- }
- // A press that never moved is a click: enter text editing.
- event.currentTarget.focus();
- event.currentTarget.select();
- };
-
- return (
- <label
- className={cn("flex items-center gap-1 text-neutral-400", className)}
- >
- {label}
- <Field
- className={cn(
- "inline-flex items-center gap-0.5",
- variant === "box" && "w-16 max-w-full",
- )}
- variant={variant}
- >
- <input
- {...props}
- className={input({ variant })}
- style={
- variant === "box"
- ? undefined
- : { width: `${Math.max(chars, minChars)}ch` }
- }
- inputMode="decimal"
- onBlur={commit}
- onChange={(event) => setDraft(event.currentTarget.value)}
- onFocus={() => onEditingChange?.(true)}
- onKeyDown={(event) =>
- event.key === "Enter" && event.currentTarget.blur()
- }
- onPointerDown={startScrub}
- onPointerMove={scrub}
- onPointerCancel={() => {
- drag.current = undefined;
- onEditingChange?.(false);
- }}
- onPointerUp={endScrub}
- type="text"
- value={shown}
- />
- {unit && <span className="text-neutral-500">{unit}</span>}
- </Field>
- </label>
- );
-}
diff --git a/src/components/ui/select.tsx b/src/components/ui/select.tsx
deleted file mode 100644
index 0ede079..0000000
--- a/src/components/ui/select.tsx
+++ /dev/null
@@ -1,113 +0,0 @@
-import { Select as Primitive } from "@base-ui/react/select";
-import { cva } from "class-variance-authority";
-import { cn } from "cn";
-import { useState } from "react";
-import { Icon } from "@/components/icons/icon";
-import { Surface } from "./surface";
-import { Tooltip } from "./tooltip";
-
-export type SelectOption<T extends string = string> = {
- value: T;
- label: string;
- disabled?: boolean;
-};
-
-const trigger = cva(
- "inline-flex min-w-0 shrink-0 cursor-pointer items-center justify-between gap-2 text-neutral-200 outline-none focus-visible:ring-1 focus-visible:ring-white/20",
- {
- variants: {
- /** "field" sits in a panel; "pill" sits in the bar over the canvas. */
- variant: {
- field:
- "rounded border border-black bg-neutral-900 py-0.5 pr-2 pl-1 shadow-groove",
- pill: "h-7 rounded-full bg-white/10 px-3 hover:bg-white/15 data-popup-open:bg-white/15 pointer-coarse:h-9",
- },
- },
- },
-);
-
-/** A value chosen from a list on the shared surface, with the selected option checked. */
-export function Select<T extends string>({
- "aria-label": label,
- value,
- options,
- onChange,
- placeholder,
- tooltip,
- className,
- variant = "field",
-}: {
- "aria-label": string;
- value?: T;
- options: readonly SelectOption<T>[];
- onChange: (value: T) => void;
- placeholder?: string;
- tooltip?: string;
- className?: string;
- variant?: "field" | "pill";
-}) {
- const [open, setOpen] = useState(false);
- const control = (
- <Primitive.Trigger
- aria-label={label}
- className={cn(trigger({ variant }), className)}
- >
- <Primitive.Value placeholder={placeholder} className="truncate" />
- <Icon className="size-3 shrink-0 text-neutral-400">
- <path d="m6 9 6 6 6-6" />
- </Icon>
- </Primitive.Trigger>
- );
- return (
- <Primitive.Root
- items={options}
- value={value ?? null}
- open={open}
- onOpenChange={setOpen}
- onValueChange={(next) => {
- const option = options.find((item) => item.value === next);
- if (option) {
- onChange(option.value);
- }
- }}
- >
- {tooltip ? (
- <Tooltip content={tooltip} disabled={open}>
- {control}
- </Tooltip>
- ) : (
- control
- )}
- <Primitive.Portal>
- <Primitive.Positioner
- sideOffset={4}
- alignItemWithTrigger={false}
- className="z-50"
- >
- <Primitive.Popup
- render={(props) => <Surface {...props} />}
- className="min-w-(--anchor-width)"
- >
- <Primitive.List>
- {options.map((option, index) => (
- <Primitive.Item
- key={`${option.value}-${index}`}
- value={option.value}
- disabled={option.disabled}
- className="flex cursor-default items-center justify-between gap-4 rounded-md px-2.5 py-1.5 outline-none select-none data-disabled:text-neutral-600 data-highlighted:bg-white/8 data-selected:bg-neutral-700"
- >
- <Primitive.ItemText>{option.label}</Primitive.ItemText>
- <Primitive.ItemIndicator>
- <Icon className="size-3.5 shrink-0 text-neutral-300">
- <path d="m5 12 4 4L19 6" />
- </Icon>
- </Primitive.ItemIndicator>
- </Primitive.Item>
- ))}
- </Primitive.List>
- </Primitive.Popup>
- </Primitive.Positioner>
- </Primitive.Portal>
- </Primitive.Root>
- );
-}
diff --git a/src/components/ui/slider.tsx b/src/components/ui/slider.tsx
deleted file mode 100644
index 8137652..0000000
--- a/src/components/ui/slider.tsx
+++ /dev/null
@@ -1,112 +0,0 @@
-import { cva } from "class-variance-authority";
-import { ScrubInput } from "./scrub-input";
-
-type SliderProps = {
- label: string;
- value: number;
- onChange: (value: number) => void;
- /** Reports interaction with either the range or its numeric field. */
- onEditingChange?: (editing: boolean) => void;
- min: number;
- max: number;
- step?: number;
- /** Restored by double-clicking the bar. */
- defaultValue?: number;
- /** CSS color stops painting the bar left to right, e.g. ["#46f", "#fc3"]. */
- stops?: string[];
- unit?: string;
- /** Minimum width of the numeric value in tabular characters. */
- valueWidth?: number;
- /** "panel" stacks the bar under its label; "toolbar" keeps one row; "compact" is that row without the bar. */
- variant?: "panel" | "toolbar" | "compact";
-};
-
-// In the bar, the label is inset like the text of the pills around it.
-const root = cva("items-center whitespace-nowrap text-neutral-400", {
- variants: {
- variant: {
- panel: "grid grid-cols-[1fr_auto] gap-y-0.5",
- toolbar: "flex gap-1.5 pl-2.5",
- compact: "flex gap-1.5 pl-2.5",
- },
- },
-});
-const field = cva("relative z-10 flex items-center", {
- variants: {
- variant: { panel: "", toolbar: "order-last", compact: "order-last" },
- },
-});
-const track = cva(
- "relative h-1 min-w-11 rounded-full bg-neutral-900 shadow-groove",
- {
- variants: {
- variant: { panel: "col-span-2 my-1", toolbar: "w-16", compact: "hidden" },
- },
- },
-);
-const range = cva(
- "absolute top-1/2 w-full -translate-y-1/2 touch-pan-y appearance-none bg-transparent outline-none [&:focus-visible::-webkit-slider-thumb]:ring-2 [&:focus-visible::-webkit-slider-thumb]:ring-sky-300 [&:focus-visible::-moz-range-thumb]:ring-2 [&:focus-visible::-moz-range-thumb]:ring-sky-300 [&::-webkit-slider-runnable-track]:bg-transparent [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:size-3 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-neutral-100 [&::-webkit-slider-thumb]:ring-1 [&::-webkit-slider-thumb]:ring-neutral-800 [&::-moz-range-track]:bg-transparent [&::-moz-range-thumb]:size-2.5 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-0 [&::-moz-range-thumb]:bg-neutral-100 [&::-moz-range-thumb]:ring-1 [&::-moz-range-thumb]:ring-neutral-800",
- { variants: { variant: { panel: "h-11", toolbar: "h-7", compact: "h-7" } } },
-);
-
-/** Labeled slider paired with a scrubbable numeric field. */
-export function Slider({
- label,
- value,
- onChange,
- onEditingChange,
- min,
- max,
- step = 1,
- defaultValue,
- stops,
- unit,
- valueWidth,
- variant = "panel",
-}: SliderProps) {
- const gradient = stops && {
- background: `linear-gradient(to right, ${stops.join()})`,
- };
- const reset = () => defaultValue !== undefined && onChange(defaultValue);
-
- return (
- <div className={root({ variant })}>
- <span>{label}</span>
- <div className={field({ variant })}>
- <ScrubInput
- aria-label={label}
- max={max}
- min={min}
- onChange={onChange}
- onEditingChange={onEditingChange}
- step={step}
- minChars={valueWidth}
- unit={unit}
- value={value}
- variant={variant === "panel" ? "text" : "pill"}
- />
- </div>
- <div className={track({ variant })} style={gradient}>
- <input
- aria-label={label}
- className={range({ variant })}
- max={max}
- min={min}
- onChange={(event) => onChange(event.currentTarget.valueAsNumber)}
- onDoubleClick={reset}
- onBlur={() => onEditingChange?.(false)}
- onFocus={() => onEditingChange?.(true)}
- onKeyDown={(event) =>
- event.key === "Enter" && event.currentTarget.blur()
- }
- step={step}
- onPointerCancel={() => onEditingChange?.(false)}
- onPointerDown={() => onEditingChange?.(true)}
- onPointerUp={() => onEditingChange?.(false)}
- type="range"
- value={value}
- />
- </div>
- </div>
- );
-}
diff --git a/src/components/ui/spinner.tsx b/src/components/ui/spinner.tsx
deleted file mode 100644
index 30e7fd9..0000000
--- a/src/components/ui/spinner.tsx
+++ /dev/null
@@ -1,16 +0,0 @@
-import { cn } from "cn";
-import type { ComponentProps } from "react";
-
-export function Spinner({ className, ...props }: ComponentProps<"div">) {
- return (
- <div
- aria-label="Loading"
- className={cn(
- "size-5 animate-spin rounded-full border-2 border-neutral-600 border-t-neutral-100",
- className,
- )}
- role="status"
- {...props}
- />
- );
-}
diff --git a/src/components/ui/surface.tsx b/src/components/ui/surface.tsx
deleted file mode 100644
index 9ac7a55..0000000
--- a/src/components/ui/surface.tsx
+++ /dev/null
@@ -1,19 +0,0 @@
-import { cn } from "cn";
-import type { ComponentProps } from "react";
-
-/**
- * The elevated floating panel under menus, selects, and popovers. Render a popup part as one:
- * `<Menu.Popup render={(props) => <Surface {...props} />} />`.
- */
-export function Surface({ className, ...props }: ComponentProps<"div">) {
- return (
- <div
- data-surface=""
- className={cn(
- "max-h-(--available-height) min-w-40 origin-(--transform-origin) overflow-y-auto rounded-lg border border-black/60 bg-neutral-800 p-1 text-neutral-200 shadow-float outline-none transition-[opacity,scale] duration-100 data-ending-style:opacity-0 data-starting-style:scale-95 data-starting-style:opacity-0",
- className,
- )}
- {...props}
- />
- );
-}
diff --git a/src/components/ui/tabs.tsx b/src/components/ui/tabs.tsx
deleted file mode 100644
index 4b3695a..0000000
--- a/src/components/ui/tabs.tsx
+++ /dev/null
@@ -1,59 +0,0 @@
-import { cn } from "cn";
-import type { ComponentProps, KeyboardEvent } from "react";
-import { Button } from "./button";
-
-const steps: Record<string, number> = {
- ArrowRight: 1,
- ArrowDown: 1,
- ArrowLeft: -1,
- ArrowUp: -1,
-};
-
-/** Arrow keys in any direction move between the tabs inside. Orientation comes from className. */
-export function TabList({ className, ...props }: ComponentProps<"div">) {
- function selectNeighbor(event: KeyboardEvent<HTMLDivElement>) {
- const step = steps[event.key];
- if (!step) {
- return;
- }
- event.preventDefault();
- const tabs = [
- ...event.currentTarget.querySelectorAll<HTMLElement>('[role="tab"]'),
- ];
- const index = tabs.findIndex(
- (tab) => tab.getAttribute("aria-selected") === "true",
- );
- const next = tabs.at((index + step) % tabs.length);
- next?.focus();
- next?.click();
- }
- return (
- <div
- role="tablist"
- onKeyDown={selectNeighbor}
- className={cn("flex gap-1", className)}
- {...props}
- />
- );
-}
-
-/** Only the selected tab is in the tab order; arrow keys reach the rest. */
-export function Tab({
- selected,
- className,
- ...props
-}: ComponentProps<typeof Button> & { selected: boolean }) {
- return (
- <Button
- variant="ghost"
- role="tab"
- aria-selected={selected}
- tabIndex={selected ? 0 : -1}
- className={cn(
- "aria-selected:bg-neutral-700 aria-selected:text-neutral-100 aria-selected:shadow-ridge",
- className,
- )}
- {...props}
- />
- );
-}
diff --git a/src/components/ui/tooltip.tsx b/src/components/ui/tooltip.tsx
deleted file mode 100644
index 50e126c..0000000
--- a/src/components/ui/tooltip.tsx
+++ /dev/null
@@ -1,50 +0,0 @@
-import { Tooltip as Primitive } from "@base-ui/react/tooltip";
-import type { ReactElement, ReactNode } from "react";
-
-/** Shares hover timing, so moving between controls shows their tips without waiting again. */
-export function TooltipProvider({ children }: { children: ReactNode }) {
- return <Primitive.Provider delay={500}>{children}</Primitive.Provider>;
-}
-
-const mac =
- typeof navigator !== "undefined" &&
- /Mac|iPhone|iPad/.test(navigator.platform);
-
-/** Writes "Mod" as the platform's command key. */
-function keys(shortcut: string) {
- return shortcut.replace("Mod", mac ? "⌘" : "Ctrl");
-}
-
-/**
- * A short hint on hover or keyboard focus, with an optional shortcut. It wraps one element that
- * accepts a ref and props, and names nothing for assistive technology; the element keeps its own label.
- */
-export function Tooltip({
- content,
- shortcut,
- side = "bottom",
- disabled,
- children,
-}: {
- content: ReactNode;
- shortcut?: string;
- side?: "top" | "right" | "bottom" | "left";
- disabled?: boolean;
- children: ReactElement;
-}) {
- return (
- <Primitive.Root disabled={disabled}>
- <Primitive.Trigger render={children} />
- <Primitive.Portal>
- <Primitive.Positioner side={side} sideOffset={6} className="z-50">
- <Primitive.Popup className="flex max-w-64 origin-(--transform-origin) items-center gap-2 rounded-md border border-black/60 bg-neutral-950 px-2 py-1 text-neutral-200 shadow-float transition-[opacity,scale] duration-100 data-ending-style:opacity-0 data-instant:transition-none data-starting-style:scale-95 data-starting-style:opacity-0">
- {content}
- {shortcut && (
- <kbd className="text-neutral-500">{keys(shortcut)}</kbd>
- )}
- </Primitive.Popup>
- </Primitive.Positioner>
- </Primitive.Portal>
- </Primitive.Root>
- );
-}
diff --git a/src/components/ui/vertical-slider.tsx b/src/components/ui/vertical-slider.tsx
deleted file mode 100644
index 6a49f26..0000000
--- a/src/components/ui/vertical-slider.tsx
+++ /dev/null
@@ -1,45 +0,0 @@
-type VerticalSliderProps = {
- label: string;
- value: number;
- onChange: (value: number) => void;
- min: number;
- max: number;
- defaultValue?: number;
- stops: readonly string[];
- color: string;
-};
-
-/** Native vertical range: up increases, down decreases, double-click restores the default. */
-export function VerticalSlider({
- label,
- value,
- onChange,
- min,
- max,
- defaultValue,
- stops,
- color,
-}: VerticalSliderProps) {
- return (
- <div className="relative flex h-44 w-full justify-center">
- <div
- className="pointer-events-none absolute inset-y-2 w-1 rounded-full shadow-groove"
- style={{ background: `linear-gradient(to top, ${stops.join()})` }}
- />
- <input
- aria-label={label}
- aria-orientation="vertical"
- className="relative h-full w-full touch-none cursor-ns-resize appearance-none bg-transparent [direction:rtl] [writing-mode:vertical-lr] focus-visible:outline-1 focus-visible:outline-offset-2 focus-visible:outline-neutral-400 [&::-webkit-slider-runnable-track]:bg-transparent [&::-webkit-slider-thumb]:size-4 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-current [&::-webkit-slider-thumb]:ring-1 [&::-webkit-slider-thumb]:ring-black/30 [&::-moz-range-track]:bg-transparent [&::-moz-range-thumb]:size-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-0 [&::-moz-range-thumb]:bg-current [&::-moz-range-thumb]:ring-1 [&::-moz-range-thumb]:ring-black/30"
- style={{ color }}
- type="range"
- min={min}
- max={max}
- value={value}
- onChange={(event) => onChange(event.currentTarget.valueAsNumber)}
- onDoubleClick={() =>
- defaultValue !== undefined && onChange(defaultValue)
- }
- />
- </div>
- );
-}
diff --git a/src/features/adjustments/controls.tsx b/src/features/adjustments/controls.tsx
index 4a3b449..1b90f12 100644
--- a/src/features/adjustments/controls.tsx
+++ b/src/features/adjustments/controls.tsx
@@ -1,6 +1,6 @@
+import { Slider } from "@roprgm/ui/slider";
import type { ReactNode } from "react";
import { useDocument } from "@/components/editor/session";
-import { Slider } from "@/components/ui/slider";
import type { Adjustments } from "@/core/document";
import { setAdjustments } from "./edits";
import { adjustmentLimits, defaultAdjustments } from "./model";
diff --git a/src/features/color-mixer/controls.tsx b/src/features/color-mixer/controls.tsx
index de798ec..d17deab 100644
--- a/src/features/color-mixer/controls.tsx
+++ b/src/features/color-mixer/controls.tsx
@@ -1,9 +1,9 @@
+import { ScrubInput } from "@roprgm/ui/scrub-input";
+import { Tab, TabList } from "@roprgm/ui/tabs";
+import { Tooltip } from "@roprgm/ui/tooltip";
+import { VerticalSlider } from "@roprgm/ui/vertical-slider";
import { useId, useState } from "react";
import { useDocument } from "@/components/editor/session";
-import { ScrubInput } from "@/components/ui/scrub-input";
-import { Tab, TabList } from "@/components/ui/tabs";
-import { Tooltip } from "@/components/ui/tooltip";
-import { VerticalSlider } from "@/components/ui/vertical-slider";
import type { ColorMixer } from "@/core/document";
import { setColorMixer } from "./edits";
import { channels, colors, type MixerChannel } from "./model";
@@ -39,9 +39,9 @@ function ColorSlider({
<div className="flex min-w-0 flex-col items-center gap-1">
<ScrubInput
aria-label={`${label} value`}
- className="w-full leading-4 [&>span]:px-0 [&_input]:text-center [&_input]:tracking-tight"
- variant="text"
+ className="w-full justify-center px-0 tracking-tight"
value={value}
+ defaultValue={0}
onChange={change}
min={-100}
max={100}
@@ -74,7 +74,7 @@ export function ColorMixerControls({
<section className="p-3">
<TabList
aria-label="Color Mixer adjustment"
- className="mb-3 gap-0.5 rounded-md bg-neutral-900 p-0.5 shadow-groove"
+ className="mb-3 gap-0.5 rounded-md bg-neutral-900 p-0.5 shadow-sunken"
>
{channels.map(({ id: value, label }) => (
<Tab
@@ -83,7 +83,7 @@ export function ColorMixerControls({
aria-controls={`${id}-sliders`}
selected={channel === value}
onClick={() => setChannel(value)}
- className="min-w-0 flex-1 rounded px-1 py-1.5"
+ className="h-7 min-w-0 flex-1 rounded-sm px-1"
>
{label}
</Tab>
diff --git a/src/features/crop/view.tsx b/src/features/crop/view.tsx
index b756715..b09493d 100644
--- a/src/features/crop/view.tsx
+++ b/src/features/crop/view.tsx
@@ -1,3 +1,7 @@
+import { Button } from "@roprgm/ui/button";
+import { Select } from "@roprgm/ui/select";
+import { Slider } from "@roprgm/ui/slider";
+import { Tooltip } from "@roprgm/ui/tooltip";
import { useState } from "react";
import { Image } from "@/components/editor/image";
import { EditorPanel, PanelBody, PanelHeader } from "@/components/editor/panel";
@@ -5,10 +9,6 @@ import { useDocument, useEditorSession } from "@/components/editor/session";
import { EditorViewport, ViewportStage } from "@/components/editor/viewport";
import { FlipIcon } from "@/components/icons/flip";
import { RotateIcon } from "@/components/icons/rotate";
-import { Button } from "@/components/ui/button";
-import { Select } from "@/components/ui/select";
-import { Slider } from "@/components/ui/slider";
-import { Tooltip } from "@/components/ui/tooltip";
import { imageFrame, type Point } from "@/core/image/frame";
import { useShortcuts } from "@/hooks/use-shortcuts";
import { applyCrop } from "./edits";
@@ -115,17 +115,16 @@ export function CropEditor({ onClose }: { onClose: () => void }) {
}
}}
>
- <PanelHeader title="Crop" onClose={onClose} />
- <PanelBody>
+ <PanelBody header={<PanelHeader title="Crop" onClose={onClose} />}>
<section aria-label="Crop tool" className="space-y-5 p-4">
<div className="flex items-center justify-between text-neutral-400">
Aspect ratio
<Select
aria-label="Aspect ratio"
value={ratio === null ? "free" : `${ratio}`}
- options={ratioOptions}
- className="w-24"
- onChange={changeRatio}
+ items={ratioOptions}
+ className="h-7 w-24"
+ onValueChange={(value) => value !== null && changeRatio(value)}
/>
</div>
<section
@@ -135,7 +134,7 @@ export function CropEditor({ onClose }: { onClose: () => void }) {
<h3 className="col-span-3 text-neutral-400">Rotate & flip</h3>
<Button
variant="ghost"
- className="justify-self-end px-2 py-1"
+ className="h-6 justify-self-end px-2"
onClick={reset}
>
Reset
@@ -176,7 +175,7 @@ export function CropEditor({ onClose }: { onClose: () => void }) {
</section>
</PanelBody>
<div className="p-3">
- <Button className="w-full py-2" onClick={apply}>
+ <Button className="w-full" onClick={apply}>
Apply crop
</Button>
</div>
diff --git a/src/features/details/controls.tsx b/src/features/details/controls.tsx
index 49d3477..eb82069 100644
--- a/src/features/details/controls.tsx
+++ b/src/features/details/controls.tsx
@@ -1,5 +1,5 @@
+import { Slider } from "@roprgm/ui/slider";
import { useDocument } from "@/components/editor/session";
-import { Slider } from "@/components/ui/slider";
import type { Details } from "@/core/document";
import { setDetails } from "./edits";
import { defaultDetails, detailLimits } from "./model";
diff --git a/src/features/fill/controls.tsx b/src/features/fill/controls.tsx
index cddb063..2f45342 100644
--- a/src/features/fill/controls.tsx
+++ b/src/features/fill/controls.tsx
@@ -1,6 +1,6 @@
+import { Select } from "@roprgm/ui/select";
import { useEffect, useRef } from "react";
import { useDocument } from "@/components/editor/session";
-import { Select } from "@/components/ui/select";
import type { Fill } from "@/core/document";
import { setFill } from "./edits";
import { blends } from "./model";
@@ -41,9 +41,9 @@ export function FillControls({ id, fill }: { id: string; fill: Fill }) {
<Select
aria-label="Blend"
value={fill.blend}
- options={blends.map(([value, label]) => ({ value, label }))}
- className="w-28"
- onChange={(blend) => setFill(document, { blend }, id)}
+ items={blends.map(([value, label]) => ({ value, label }))}
+ className="h-7 w-28"
+ onValueChange={(blend) => blend && setFill(document, { blend }, id)}
/>
</div>
</section>
diff --git a/src/features/heal/controls.tsx b/src/features/heal/controls.tsx
index a73522a..232c526 100644
--- a/src/features/heal/controls.tsx
+++ b/src/features/heal/controls.tsx
@@ -1,9 +1,10 @@
+import { IconButton } from "@roprgm/ui/icon-button";
+import { ListItem } from "@roprgm/ui/list-item";
+import { Menu, MenuItem } from "@roprgm/ui/menu";
import { CoverageThumbnail } from "@/components/editor/coverage-thumbnail";
import { useDocument } from "@/components/editor/session";
import { HealIcon } from "@/components/icons/heal";
import { Icon } from "@/components/icons/icon";
-import { Menu, MenuItem } from "@/components/ui/menu";
-import { PanelListItem } from "@/components/ui/panel-list";
import type { HealPatch } from "@/core/document";
import { deleteHealPatch, duplicateHealPatch } from "./edits";
import { useHealing } from "./mode";
@@ -35,15 +36,20 @@ function PatchActions({
const { selectPatch } = useHealing();
return (
<Menu
- label="Patch actions"
- icon={
- <Icon className="size-4">
- <path
- d="M5 12h.01M12 12h.01M19 12h.01"
- strokeWidth="3"
- strokeLinecap="round"
- />
- </Icon>
+ trigger={
+ <IconButton
+ label="Patch actions"
+ size="icon-sm"
+ className="pointer-coarse:size-10"
+ >
+ <Icon className="size-4">
+ <path
+ d="M5 12h.01M12 12h.01M19 12h.01"
+ strokeWidth="3"
+ strokeLinecap="round"
+ />
+ </Icon>
+ </IconButton>
}
>
<MenuItem
@@ -97,9 +103,9 @@ export function HealControls({
<ol aria-label="Healing patches">
{patches.map((patch, index) => (
<li key={patch.id}>
- <PanelListItem
+ <ListItem
selected={selectedPatch === patch.id}
- className="pr-1"
+ className="gap-0 pr-1 pl-0 pointer-coarse:h-12"
onPointerEnter={() => hoverPatch(patch.id)}
onPointerLeave={() => hoverPatch()}
>
@@ -127,7 +133,7 @@ export function HealControls({
patch={patch}
next={patches[index - 1]?.id ?? patches[index + 1]?.id}
/>
- </PanelListItem>
+ </ListItem>
</li>
))}
</ol>
diff --git a/src/features/heal/options.tsx b/src/features/heal/options.tsx
index f6aebb1..9ee5f59 100644
--- a/src/features/heal/options.tsx
+++ b/src/features/heal/options.tsx
@@ -1,9 +1,9 @@
+import { Chip } from "@roprgm/ui/chip";
+import { Slider } from "@roprgm/ui/slider";
+import { Tooltip } from "@roprgm/ui/tooltip";
import { useBrushTool } from "@/components/editor/brush-tool";
import { useDocument, useSelectedLayer } from "@/components/editor/session";
import { barSlider, useBarDensity } from "@/components/editor/toolbar-density";
-import { Chip } from "@/components/ui/chip";
-import { Slider } from "@/components/ui/slider";
-import { Tooltip } from "@/components/ui/tooltip";
import { setHealPatch } from "./edits";
import { useHealing } from "./mode";
@@ -36,7 +36,7 @@ export function HealOptions() {
label="Size"
min={1}
max={maxSize}
- unit="px"
+ format={(value) => `${value}px`}
valueWidth={`${maxSize}`.length}
variant={variant}
value={size}
@@ -48,7 +48,7 @@ export function HealOptions() {
value={feather * 100}
min={0}
max={100}
- unit="%"
+ format={(value) => `${value}%`}
valueWidth={3}
variant={variant}
onEditingChange={setPreview}
@@ -64,7 +64,7 @@ export function HealOptions() {
value={selected.opacity * 100}
min={0}
max={100}
- unit="%"
+ format={(value) => `${value}%`}
valueWidth={3}
variant={variant}
onChange={(value) => changePatch({ opacity: value / 100 })}
diff --git a/src/features/layers/brush-options.tsx b/src/features/layers/brush-options.tsx
index 0300d11..204ddb2 100644
--- a/src/features/layers/brush-options.tsx
+++ b/src/features/layers/brush-options.tsx
@@ -1,8 +1,8 @@
+import { Chip } from "@roprgm/ui/chip";
+import { Slider } from "@roprgm/ui/slider";
+import { Tooltip } from "@roprgm/ui/tooltip";
import { useBrushTool } from "@/components/editor/brush-tool";
import { barSlider, useBarDensity } from "@/components/editor/toolbar-density";
-import { Chip, ChipGroup } from "@/components/ui/chip";
-import { Slider } from "@/components/ui/slider";
-import { Tooltip } from "@/components/ui/tooltip";
const modes = [
["paint", "Paint", "Add coverage", undefined],
@@ -15,25 +15,28 @@ export function BrushOptions() {
const variant = barSlider(useBarDensity());
return (
<>
- <ChipGroup aria-label="Brush mode">
+ <fieldset
+ aria-label="Brush mode"
+ className="flex gap-0.5 rounded-full bg-white/5 p-0.5"
+ >
{modes.map(([mode, label, hint, shortcut]) => (
<Tooltip key={mode} content={hint} shortcut={shortcut}>
<Chip
- size="segment"
aria-pressed={erase === (mode === "erase")}
+ className="h-6"
onClick={() => update({ erase: mode === "erase" })}
>
{label}
</Chip>
</Tooltip>
))}
- </ChipGroup>
+ </fieldset>
<Slider
label="Size"
value={settings.size}
min={1}
max={maxSize}
- unit="px"
+ format={(value) => `${value}px`}
valueWidth={`${maxSize}`.length}
variant={variant}
onEditingChange={setPreview}
@@ -45,7 +48,7 @@ export function BrushOptions() {
min={0}
max={100}
defaultValue={50}
- unit="%"
+ format={(value) => `${value}%`}
valueWidth={3}
variant={variant}
onEditingChange={setPreview}
@@ -57,7 +60,7 @@ export function BrushOptions() {
min={1}
max={100}
defaultValue={100}
- unit="%"
+ format={(value) => `${value}%`}
valueWidth={3}
variant={variant}
onChange={(value) => update({ flow: value / 100 })}
diff --git a/src/features/layers/brush-overlay.tsx b/src/features/layers/brush-overlay.tsx
index 2f00755..be4266a 100644
--- a/src/features/layers/brush-overlay.tsx
+++ b/src/features/layers/brush-overlay.tsx
@@ -27,7 +27,6 @@ export function BrushOverlay() {
return (
<BrushCanvas
label="Brush canvas"
- hint="Drag to paint · Alt erases · [ ] resize · Enter when done"
erase={brush.erase}
onStart={(stroke) => {
const id = selectedBrush()?.id;
diff --git a/src/features/layers/controls.tsx b/src/features/layers/controls.tsx
index bf02eeb..dff6270 100644
--- a/src/features/layers/controls.tsx
+++ b/src/features/layers/controls.tsx
@@ -1,6 +1,12 @@
+import { IconButton } from "@roprgm/ui/icon-button";
+import { ListItem } from "@roprgm/ui/list-item";
+import { Menu, MenuItem } from "@roprgm/ui/menu";
+import { ScrollArea } from "@roprgm/ui/scroll-area";
+import { Tooltip } from "@roprgm/ui/tooltip";
import {
type ComponentType,
memo,
+ type ReactNode,
useCallback,
useEffect,
useState,
@@ -9,10 +15,6 @@ import { useStore } from "zustand";
import { PanelHeader } from "@/components/editor/panel";
import { useDocument, useScene } from "@/components/editor/session";
import { Icon, type IconProps } from "@/components/icons/icon";
-import { Menu, MenuItem } from "@/components/ui/menu";
-import { PanelListItem } from "@/components/ui/panel-list";
-import { ScrollArea } from "@/components/ui/scroll-area";
-import { Tooltip } from "@/components/ui/tooltip";
import {
TreeDrag,
type TreeDrop,
@@ -24,7 +26,7 @@ import { layerDrop } from "./drop";
import { deleteLayer, moveLayer, setLayer } from "./edits";
import { LayerName } from "./layer-name";
import { useMaskTool } from "./mask-tool";
-import { LayerActions, MaskNesting } from "./menu";
+import { LayerActions } from "./menu";
import { ImageThumbnail, MaskThumbnail } from "./thumbnails";
/** How the stack shows and offers each effect kind; the app supplies them so this feature names no other. */
@@ -104,7 +106,7 @@ const LayerRow = memo(function LayerRow({
const expandLabel = `${expanded ? "Collapse" : "Expand"} ${layer.name}`;
return (
<>
- <PanelListItem
+ <ListItem
ref={drag.ref}
data-drop={drag.drop}
data-dragging={drag.dragging}
@@ -112,7 +114,7 @@ const LayerRow = memo(function LayerRow({
selected={selected === layer.id}
muted={!visible}
style={{ paddingLeft: depth * 12 }}
- className="pr-1 data-[dragging=true]:opacity-40 data-[drop=inside]:ring-1 data-[drop=inside]:ring-blue-400 data-[drop=inside]:ring-inset data-[drop=before]:before:absolute data-[drop=before]:before:inset-x-0 data-[drop=before]:before:-top-px data-[drop=before]:before:border-t-2 data-[drop=before]:before:border-blue-400 data-[drop=after]:after:absolute data-[drop=after]:after:inset-x-0 data-[drop=after]:after:-bottom-px data-[drop=after]:after:border-b-2 data-[drop=after]:after:border-blue-400"
+ className="gap-0 pr-1 pointer-coarse:h-12 data-[dragging=true]:opacity-40 data-[drop=inside]:ring-1 data-[drop=inside]:ring-blue-400 data-[drop=inside]:ring-inset data-[drop=before]:before:absolute data-[drop=before]:before:inset-x-0 data-[drop=before]:before:-top-px data-[drop=before]:before:border-t-2 data-[drop=before]:before:border-blue-400 data-[drop=after]:after:absolute data-[drop=after]:after:inset-x-0 data-[drop=after]:after:-bottom-px data-[drop=after]:after:border-b-2 data-[drop=after]:after:border-blue-400"
>
<Tooltip
content={visible ? "Hide layer" : "Show layer"}
@@ -185,11 +187,10 @@ const LayerRow = memo(function LayerRow({
</span>
</Tooltip>
)}
- {layer.kind === "mask" && !parent && <MaskNesting layer={layer} />}
{layer.kind !== "image" && (
<LayerActions layer={layer} onSelect={onSelect} />
)}
- </PanelListItem>
+ </ListItem>
{expanded &&
layer.children
.toReversed()
@@ -207,6 +208,31 @@ const LayerRow = memo(function LayerRow({
);
});
+/**
+ * The layers section: a fixed header over a list that scrolls. It holds three rows before it grows.
+ * The list reaches a pixel into the section's divider, so a last row that touches the bottom shares
+ * that line instead of doubling it.
+ */
+export function LayersSection({
+ actions,
+ children,
+}: {
+ actions?: ReactNode;
+ children?: ReactNode;
+}) {
+ return (
+ <section
+ aria-label="Layers"
+ className="grid max-h-1/2 min-h-41 shrink-0 grid-rows-[auto_minmax(0,1fr)] layer-panel"
+ >
+ <PanelHeader title="Layers">{actions}</PanelHeader>
+ <ScrollArea fade className="-mb-px">
+ {children}
+ </ScrollArea>
+ </section>
+ );
+}
+
export function LayersControls({
effects,
onAdd,
@@ -243,17 +269,19 @@ export function LayersControls({
}
return (
- <section
- aria-label="Layers"
- className="grid max-h-1/2 min-h-36 shrink-0 grid-rows-[auto_minmax(0,1fr)] bg-panel"
- >
- <PanelHeader title="Layers">
+ <LayersSection
+ actions={
<Menu
- label="Add effect"
- icon={
- <Icon className="size-4">
- <path d="M12 4v16M4 12h16" />
- </Icon>
+ trigger={
+ <IconButton
+ label="Add effect"
+ size="icon-sm"
+ className="pointer-coarse:size-10"
+ >
+ <Icon className="size-4">
+ <path d="M12 4v16M4 12h16" />
+ </Icon>
+ </IconButton>
}
>
{effects
@@ -264,26 +292,25 @@ export function LayersControls({
</MenuItem>
))}
</Menu>
- </PanelHeader>
- <ScrollArea fade>
- <TreeDrag
- canDrop={(target) =>
- Boolean(layerDrop(document.scene.getState(), target))
- }
- onDrop={drop}
- label={(id) => findLayer(layers, id)?.name ?? id}
- >
- {layers.toReversed().map((layer) => (
- <LayerRow
- key={layer.id}
- layer={layer}
- depth={0}
- effects={effects}
- onSelect={select}
- />
- ))}
- </TreeDrag>
- </ScrollArea>
- </section>
+ }
+ >
+ <TreeDrag
+ canDrop={(target) =>
+ Boolean(layerDrop(document.scene.getState(), target))
+ }
+ onDrop={drop}
+ label={(id) => findLayer(layers, id)?.name ?? id}
+ >
+ {layers.toReversed().map((layer) => (
+ <LayerRow
+ key={layer.id}
+ layer={layer}
+ depth={0}
+ effects={effects}
+ onSelect={select}
+ />
+ ))}
+ </TreeDrag>
+ </LayersSection>
);
}
diff --git a/src/features/layers/gradient-overlay.tsx b/src/features/layers/gradient-overlay.tsx
index 48ecedd..f9c542c 100644
--- a/src/features/layers/gradient-overlay.tsx
+++ b/src/features/layers/gradient-overlay.tsx
@@ -1,6 +1,5 @@
import { type PointerEvent, useEffect, useRef, useState } from "react";
import { useStore } from "zustand";
-import { CanvasHint } from "@/components/editor/canvas-hint";
import { useDocumentMapping } from "@/components/editor/mapping";
import { useDocument, useScene } from "@/components/editor/session";
import { useViewport } from "@/components/editor/viewport";
@@ -209,10 +208,6 @@ export function GradientOverlay({ shape }: { shape: Gradient["kind"] }) {
extent={Math.hypot(...camera.viewport)}
/>
)}
- <CanvasHint>
- Drag to draw · Shift constrains · Alt subtracts from the selected mask ·
- Enter when done
- </CanvasHint>
</div>
);
}
diff --git a/src/features/layers/layer-name.tsx b/src/features/layers/layer-name.tsx
index 8c6a1c4..dbe1518 100644
--- a/src/features/layers/layer-name.tsx
+++ b/src/features/layers/layer-name.tsx
@@ -1,6 +1,6 @@
+import { Tooltip } from "@roprgm/ui/tooltip";
import { type ComponentProps, useState } from "react";
import { useDocument } from "@/components/editor/session";
-import { Tooltip } from "@/components/ui/tooltip";
import type { Layer } from "@/core/document";
import { setLayer } from "./edits";
diff --git a/src/features/layers/mask-options.tsx b/src/features/layers/mask-options.tsx
index c3839e5..848462f 100644
--- a/src/features/layers/mask-options.tsx
+++ b/src/features/layers/mask-options.tsx
@@ -1,30 +1,22 @@
-import { useStore } from "zustand";
+import { Select } from "@roprgm/ui/select";
+import { Slider } from "@roprgm/ui/slider";
import { useDocument, useScene } from "@/components/editor/session";
import { barSlider, useBarDensity } from "@/components/editor/toolbar-density";
-import { Chip } from "@/components/ui/chip";
-import { Select } from "@/components/ui/select";
-import { Slider } from "@/components/ui/slider";
-import { Tooltip } from "@/components/ui/tooltip";
import { locateLayer, type MaskLayer } from "@/core/document";
-import { useShortcuts } from "@/hooks/use-shortcuts";
import { setLayerMask, setMaskOperation } from "./edits";
-import { useMaskTool } from "./mask-tool";
-/** The selected mask's options in the canvas bar: its overlay, a radial feather, and a child's operation. */
+/** The selected mask's options in the canvas bar: a radial feather and a child's operation. Its overlay toggles in the stack. */
export function MaskOptions({ layer }: { layer: MaskLayer }) {
const document = useDocument();
- const tool = useMaskTool();
const density = useBarDensity();
const parent = useScene(
(scene) => locateLayer(scene.layers, layer.id)?.parent,
);
- // The button reports what the canvas shows, whether by choice or by default.
- const shown = useStore(
- document.preview,
- (preview) => preview.maskOverlay !== undefined,
- );
- const toggleOverlay = () => tool.showOverlay(!shown);
- useShortcuts({ o: toggleOverlay });
+ const radial = layer.mask.kind === "radial";
+ const child = parent?.kind === "mask";
+ if (!radial && !child) {
+ return null;
+ }
return (
<>
{density !== "menu" && (
@@ -33,11 +25,6 @@ export function MaskOptions({ layer }: { layer: MaskLayer }) {
className="h-4 w-px border-0 bg-white/15"
/>
)}
- <Tooltip content="Show the mask overlay" shortcut="O">
- <Chip aria-pressed={shown} onClick={toggleOverlay}>
- Overlay
- </Chip>
- </Tooltip>
{layer.mask.kind === "radial" && (
<Slider
label="Feather"
@@ -45,7 +32,7 @@ export function MaskOptions({ layer }: { layer: MaskLayer }) {
min={0}
max={100}
defaultValue={50}
- unit="%"
+ format={(value) => `${value}%`}
valueWidth={3}
variant={barSlider(density)}
onChange={(value) => {
@@ -58,18 +45,18 @@ export function MaskOptions({ layer }: { layer: MaskLayer }) {
}}
/>
)}
- {parent?.kind === "mask" && (
+ {child && (
<Select
variant="pill"
aria-label="Mask operation"
tooltip="Combine with the parent mask"
value={layer.operation}
- options={[
+ items={[
{ value: "add", label: "Add" },
{ value: "subtract", label: "Subtract" },
]}
- onChange={(operation) =>
- setMaskOperation(document, layer.id, operation)
+ onValueChange={(operation) =>
+ operation && setMaskOperation(document, layer.id, operation)
}
/>
)}
diff --git a/src/features/layers/mask-tool.tsx b/src/features/layers/mask-tool.tsx
index f785ee3..475f317 100644
--- a/src/features/layers/mask-tool.tsx
+++ b/src/features/layers/mask-tool.tsx
@@ -29,7 +29,10 @@ const MaskTool = createContext<{
) => void;
/** Adds the mask where `nesting` says, else where a pending choice says, else on top. */
create: (mask: Mask, nesting?: Nesting) => void;
- /** The choice for the selected mask's overlay; auto shows it while the mask changes nothing yet. */
+ /**
+ * The choice for the selected mask's overlay; auto shows it while the mask changes nothing yet.
+ * It holds across selections, so a mask chosen next shows or hides it the same way.
+ */
overlay: OverlayChoice;
showOverlay: (shown: boolean) => void;
/** A gradient being drawn, not yet in the scene, tinted like a mask. */
@@ -63,13 +66,9 @@ export function MaskToolProvider({
const [overlay, setOverlay] = useState<OverlayChoice>("auto");
const draft = useMemo(() => createStore<Gradient | null>(() => null), []);
const document = useDocument();
- // A nesting and an overlay choice belong to the selection that made them.
+ // A nesting belongs to the selection that chose it.
useEffect(
- () =>
- document.selection.subscribe(() => {
- setPending(null);
- setOverlay("auto");
- }),
+ () => document.selection.subscribe(() => setPending(null)),
[document],
);
return (
diff --git a/src/features/layers/menu.tsx b/src/features/layers/menu.tsx
index a0cc56e..d3a5818 100644
--- a/src/features/layers/menu.tsx
+++ b/src/features/layers/menu.tsx
@@ -1,6 +1,7 @@
+import { IconButton } from "@roprgm/ui/icon-button";
+import { Menu, MenuItem, MenuSeparator, Submenu } from "@roprgm/ui/menu";
import { useDocument, useScene } from "@/components/editor/session";
import { Icon } from "@/components/icons/icon";
-import { Menu, MenuItem, MenuSeparator, Submenu } from "@/components/ui/menu";
import {
findLayer,
locateLayer,
@@ -39,6 +40,12 @@ function LayerActionItems({
}
return (
<>
+ {layer.kind === "mask" && !parent && (
+ <>
+ <NestingItems layer={layer} />
+ <MenuSeparator />
+ </>
+ )}
<MenuItem
disabled={index === siblings.length - 1}
onClick={() => moveLayer(document, layer.id, index + 1, parent?.id)}
@@ -83,25 +90,16 @@ const shapes = [
["brush", "Brush"],
] as const;
const nestings = [
- ["add", "Add to", "M12 8.5v7M8.5 12h7"],
- ["subtract", "Subtract from", "M8.5 12h7"],
+ ["add", "Add to mask"],
+ ["subtract", "Subtract from mask"],
] as const;
/** Chooses the shape of the next mask and nests it inside this one, adding or subtracting coverage. */
-export function MaskNesting({ layer }: { layer: MaskLayer }) {
+function NestingItems({ layer }: { layer: MaskLayer }) {
const document = useDocument();
const tool = useMaskTool();
- return nestings.map(([operation, verb, glyph]) => (
- <Menu
- key={operation}
- label={`${verb} ${layer.name}`}
- icon={
- <Icon className="size-4">
- <circle cx="12" cy="12" r="8" />
- <path d={glyph} />
- </Icon>
- }
- >
+ return nestings.map(([operation, label]) => (
+ <Submenu key={operation} label={label}>
{shapes.map(([shape, name]) => (
<MenuItem
key={shape}
@@ -113,7 +111,7 @@ export function MaskNesting({ layer }: { layer: MaskLayer }) {
{name}
</MenuItem>
))}
- </Menu>
+ </Submenu>
));
}
@@ -123,15 +121,20 @@ export function LayerActions(props: {
}) {
return (
<Menu
- label={`${props.layer.name} actions`}
- icon={
- <Icon className="size-4">
- <path
- d="M5 12h.01M12 12h.01M19 12h.01"
- strokeWidth="3"
- strokeLinecap="round"
- />
- </Icon>
+ trigger={
+ <IconButton
+ label={`${props.layer.name} actions`}
+ size="icon-sm"
+ className="pointer-coarse:size-10"
+ >
+ <Icon className="size-4">
+ <path
+ d="M5 12h.01M12 12h.01M19 12h.01"
+ strokeWidth="3"
+ strokeLinecap="round"
+ />
+ </Icon>
+ </IconButton>
}
>
<LayerActionItems {...props} />
diff --git a/src/features/layers/overlay-toggle.tsx b/src/features/layers/overlay-toggle.tsx
new file mode 100644
index 0000000..a7afe69
--- /dev/null
+++ b/src/features/layers/overlay-toggle.tsx
@@ -0,0 +1,37 @@
+import { IconButton } from "@roprgm/ui/icon-button";
+import { useStore } from "zustand";
+import { useDocument } from "@/components/editor/session";
+import { Icon } from "@/components/icons/icon";
+import { useShortcuts } from "@/hooks/use-shortcuts";
+import { useMaskTool } from "./mask-tool";
+
+/**
+ * Shows or hides the selected mask's tinted overlay on the canvas, with O as its shortcut. It
+ * reports what the canvas shows, whether by choice or by default, and the choice carries over to
+ * the next mask selected.
+ */
+export function OverlayToggle() {
+ const document = useDocument();
+ const tool = useMaskTool();
+ const shown = useStore(document.preview, (preview) =>
+ Boolean(preview.maskOverlay?.layerId),
+ );
+ const toggle = () => tool.showOverlay(!shown);
+ useShortcuts({ o: toggle });
+ return (
+ <IconButton
+ label="Mask overlay"
+ shortcut="O"
+ size="icon-sm"
+ aria-pressed={shown}
+ onClick={toggle}
+ className="pointer-coarse:size-10 aria-pressed:bg-pressed aria-pressed:text-foreground"
+ >
+ {/* A frame hatched like the tint the overlay lays over the mask. */}
+ <Icon className="size-4">
+ <rect x="4" y="5" width="16" height="14" rx="2" />
+ <path d="M4 11l6-6M4 17l12-12M8 19l12-12M14 19l6-6" />
+ </Icon>
+ </IconButton>
+ );
+}
diff --git a/src/features/layers/thumbnails.tsx b/src/features/layers/thumbnails.tsx
index 5dbd6a7..b0bf017 100644
--- a/src/features/layers/thumbnails.tsx
+++ b/src/features/layers/thumbnails.tsx
@@ -1,9 +1,9 @@
+import { Tooltip } from "@roprgm/ui/tooltip";
import { useEffect, useId, useRef, useState } from "react";
import { useGpu } from "vgpu-react";
import { CoverageThumbnail } from "@/components/editor/coverage-thumbnail";
import { useDocument, useScene } from "@/components/editor/session";
import { Icon } from "@/components/icons/icon";
-import { Tooltip } from "@/components/ui/tooltip";
import type { MaskLayer } from "@/core/document";
import { renderBitmap } from "@/core/renderer";
import { MaskFill } from "./mask-fill";
diff --git a/src/features/layers/toolbar.tsx b/src/features/layers/toolbar.tsx
index 22034da..de25af5 100644
--- a/src/features/layers/toolbar.tsx
+++ b/src/features/layers/toolbar.tsx
@@ -1,3 +1,6 @@
+import { IconButton } from "@roprgm/ui/icon-button";
+import { Popover } from "@roprgm/ui/popover";
+import { Slider } from "@roprgm/ui/slider";
import { type ReactNode, useLayoutEffect, useRef, useState } from "react";
import { useStore } from "zustand";
import { useDocument, useScene } from "@/components/editor/session";
@@ -7,8 +10,6 @@ import {
useBarDensity,
} from "@/components/editor/toolbar-density";
import { Icon } from "@/components/icons/icon";
-import { Popover } from "@/components/ui/popover";
-import { Slider } from "@/components/ui/slider";
import { findLayer, type ProcessingLayer } from "@/core/document";
import { useEditGesture } from "@/hooks/use-edit-gesture";
import { setLayer } from "./edits";
@@ -25,7 +26,7 @@ function LayerOptions({ layer }: { layer: ProcessingLayer }) {
min={0}
max={100}
defaultValue={100}
- unit="%"
+ format={(value) => `${value}%`}
valueWidth={3}
variant={barSlider(density)}
onChange={(value) =>
@@ -89,7 +90,8 @@ export function CanvasToolbar({ children }: { children?: ReactNode }) {
ref={bar}
aria-label="Layer options"
{...gesture}
- className="absolute top-3 left-3 flex min-w-0 max-w-[calc(100%-1.5rem)] items-center gap-x-2.5 overflow-hidden rounded-full bg-neutral-800/80 p-1 pr-2 backdrop-blur-sm"
+ // No wrapping, so running out of room overflows, which is what the steps above measure.
+ className="absolute top-3 left-3 flex min-w-0 max-w-[calc(100%-1.5rem)] items-center gap-x-2.5 overflow-hidden whitespace-nowrap rounded-full bg-neutral-800/80 p-1 pr-2 backdrop-blur-sm"
>
<Density value={step === 0 ? "full" : "compact"}>
{inlineTool}
@@ -97,19 +99,24 @@ export function CanvasToolbar({ children }: { children?: ReactNode }) {
</Density>
{(menuTool || menuLayer) && (
<Popover
- label="More options"
- icon={
- <Icon className="size-4">
- <path
- d="M12 5h.01M12 12h.01M12 19h.01"
- strokeWidth="3"
- strokeLinecap="round"
- />
- </Icon>
+ trigger={
+ <IconButton
+ label="More options"
+ size="icon-sm"
+ className="rounded-full"
+ >
+ <Icon className="size-4">
+ <path
+ d="M12 5h.01M12 12h.01M12 19h.01"
+ strokeWidth="3"
+ strokeLinecap="round"
+ />
+ </Icon>
+ </IconButton>
}
>
<Density value="menu">
- <div className="flex w-56 flex-col gap-3 p-2">
+ <div className="flex w-56 flex-col gap-3">
{menuTool}
{menuLayer && <LayerOptions layer={layer} />}
</div>
diff --git a/src/features/tone-curves/tone-curves.tsx b/src/features/tone-curves/tone-curves.tsx
index 21ffe19..bd846e0 100644
--- a/src/features/tone-curves/tone-curves.tsx
+++ b/src/features/tone-curves/tone-curves.tsx
@@ -1,5 +1,5 @@
+import { Button } from "@roprgm/ui/button";
import type { ReactNode } from "react";
-import { Button } from "@/components/ui/button";
import type { ToneCurve } from "@/core/document";
import { defaultCurve } from "./curve";
import { Graph } from "./graph";
@@ -18,14 +18,14 @@ export function ToneCurves({ points, onChange, children }: ToneCurvesProps) {
<Button
variant="ghost"
aria-label="Reset curve"
- className="px-2 py-1"
+ className="h-6 px-2"
onClick={() => onChange(defaultCurve)}
>
Reset
</Button>
</div>
<div className="px-0.5">
- <div className="relative aspect-square max-h-60 w-full rounded border border-black bg-neutral-900 shadow-groove md:max-h-50">
+ <div className="relative aspect-square max-h-55 w-full rounded border border-black bg-neutral-900 shadow-sunken md:max-h-45">
{children}
<Graph onChange={onChange} points={points} />
</div>
diff --git a/src/features/vignette/controls.tsx b/src/features/vignette/controls.tsx
index 9660be7..b8912d8 100644
--- a/src/features/vignette/controls.tsx
+++ b/src/features/vignette/controls.tsx
@@ -1,5 +1,5 @@
+import { Slider } from "@roprgm/ui/slider";
import { useDocument } from "@/components/editor/session";
-import { Slider } from "@/components/ui/slider";
import type { Vignette } from "@/core/document";
import { setVignette } from "./edits";
import { defaultVignette } from "./model";
diff --git a/src/features/white-balance/controls.tsx b/src/features/white-balance/controls.tsx
index ba6e9ee..77b89d4 100644
--- a/src/features/white-balance/controls.tsx
+++ b/src/features/white-balance/controls.tsx
@@ -1,5 +1,5 @@
+import { Slider } from "@roprgm/ui/slider";
import { useDocument, useScene } from "@/components/editor/session";
-import { Slider } from "@/components/ui/slider";
import { setWhiteBalance, whiteBalanceLimits } from "./edits";
export function WhiteBalanceControls() {
@@ -14,20 +14,28 @@ export function WhiteBalanceControls() {
const limits = whiteBalanceLimits(asShot);
return (
<>
- <button
- type="button"
- className="cursor-pointer self-end text-neutral-400 hover:text-neutral-100"
- onClick={() => setWhiteBalance(document)}
- >
- As Shot
- </button>
- <Slider
- label="Temperature (K)"
- value={balance.temperature}
- {...limits.temperature}
- defaultValue={asShot.temperature}
- onChange={(temperature) => setWhiteBalance(document, { temperature })}
- />
+ <div className="relative">
+ <Slider
+ label="Temperature (K)"
+ value={balance.temperature}
+ {...limits.temperature}
+ defaultValue={asShot.temperature}
+ onChange={(temperature) => setWhiteBalance(document, { temperature })}
+ />
+ {/* The slider's label row again, its text hidden, so As Shot follows the label without a row of its own. */}
+ <div className="pointer-events-none absolute inset-x-0 top-0 flex items-center gap-2 py-0.5">
+ <span aria-hidden className="invisible">
+ Temperature (K)
+ </span>
+ <button
+ type="button"
+ className="pointer-events-auto cursor-pointer text-faint hover:text-foreground"
+ onClick={() => setWhiteBalance(document)}
+ >
+ As Shot
+ </button>
+ </div>
+ </div>
<Slider
label="Tint"
value={balance.tint}
diff --git a/src/index.css b/src/index.css
index ff2b40c..d0156e1 100644
--- a/src/index.css
+++ b/src/index.css
@@ -1,10 +1,22 @@
@import "tailwindcss";
+/* Color tokens, shadows, focus ring, text shadow, and the `thumb:` variant that the shared components use. */
+@import "@roprgm/ui/theme.css";
@theme {
- --color-panel: var(--color-neutral-800);
--font-sans: "Geist Variable", system-ui, sans-serif;
}
+/* The editor's panels, header, and rail: darker and higher in contrast than the library's cards.
+ Controls inside take their fills from it; popups open one layer above, as from a card. */
+@utility layer-panel {
+ --layer-name: card;
+ --layer: var(--color-neutral-800);
+ --field: var(--color-neutral-900);
+ --raised: var(--color-neutral-700);
+ --raised-hover: var(--color-neutral-600);
+ background-color: var(--layer);
+}
+
/* `optional` never swaps after first paint, so the font can't cause layout shift. */
@font-face {
font-family: "Geist Variable";
@@ -27,38 +39,7 @@
font-family: var(--font-sans);
font-size: var(--text-xs);
line-height: var(--text-xs--line-height);
- color: var(--color-neutral-100);
+ color: var(--color-foreground);
background: var(--color-neutral-900);
- text-shadow: 0 1px 1px rgb(0 0 0 / 0.25);
}
}
-
-/* Raised-surface relief: light catching the inner top edge. Composes through --tw-shadow. */
-@utility shadow-ridge {
- --tw-shadow: inset 0 1px 0 rgb(255 255 255 / 0.07);
- box-shadow:
- var(--tw-inset-shadow, 0 0 #0000), var(--tw-inset-ring-shadow, 0 0 #0000),
- var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000),
- var(--tw-shadow);
-}
-
-/* A floating surface: the ridge highlight over a soft drop, so menus read like raised controls. */
-@utility shadow-float {
- --tw-shadow:
- inset 0 1px 0 rgb(255 255 255 / 0.07), 0 2px 6px rgb(0 0 0 / 0.3),
- 0 16px 32px -8px rgb(0 0 0 / 0.5);
- box-shadow:
- var(--tw-inset-shadow, 0 0 #0000), var(--tw-inset-ring-shadow, 0 0 #0000),
- var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000),
- var(--tw-shadow);
-}
-
-/* Composes through --tw-shadow so it stacks with ring utilities. */
-@utility shadow-groove {
- --tw-shadow:
- inset 0 1px 2px rgb(0 0 0 / 0.25), 0 1px 0 rgb(255 255 255 / 0.07);
- box-shadow:
- var(--tw-inset-shadow, 0 0 #0000), var(--tw-inset-ring-shadow, 0 0 #0000),
- var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000),
- var(--tw-shadow);
-}
diff --git a/src/main.tsx b/src/main.tsx
index 20ab5e1..24eb95f 100644
--- a/src/main.tsx
+++ b/src/main.tsx
@@ -1,12 +1,11 @@
+import { TooltipProvider } from "@roprgm/ui/tooltip";
import { Analytics } from "@vercel/analytics/react";
import { SpeedInsights } from "@vercel/speed-insights/react";
import { Component, type ReactNode } from "react";
import { createRoot } from "react-dom/client";
import { GpuProvider } from "vgpu-react";
-
import { App } from "@/app";
import { TextLink } from "@/components/ui/text-link";
-import { TooltipProvider } from "@/components/ui/tooltip";
import "./index.css";
/** GPU initialization throws during render; without WebGPU the page would otherwise stay blank. */
@@ -46,7 +45,7 @@ if (root) {
<>
<GpuBoundary>
<GpuProvider>
- <TooltipProvider>
+ <TooltipProvider delay={500}>
<App />
</TooltipProvider>
</GpuProvider>
diff --git a/tests/brush.e2e.ts b/tests/brush.e2e.ts
index c5b7270..4fc31ea 100644
--- a/tests/brush.e2e.ts
+++ b/tests/brush.e2e.ts
@@ -42,15 +42,15 @@ test("paint a brush mask, adjust it in the sidebar, erase, and undo", async ({
expect((await state()).scene?.layers).toHaveLength(2);
// Tool options sit over the canvas; the sidebar keeps the selected layer's adjustments.
const options = page.getByRole("group", { name: "Layer options" });
- const overlayButton = options.getByRole("button", {
- name: "Overlay",
+ const overlayButton = page.getByRole("button", {
+ name: "Mask overlay",
exact: true,
});
await expect(
options.getByRole("textbox", { name: "Size", exact: true }),
).toBeVisible();
await expect(
- page.getByRole("heading", { name: "Brush", exact: true }),
+ page.getByRole("heading", { name: "Mask adjustments", exact: true }),
).toBeVisible();
const bounds = await box(canvas);
const scale = Math.min(bounds.width / 1200, bounds.height / 800, 2);
@@ -207,10 +207,10 @@ test("paint a brush mask, adjust it in the sidebar, erase, and undo", async ({
const lit = await samples(page);
expect(lit[1][0]).toBeGreaterThan(original[1][0] + 20);
await page
- .getByRole("button", {
- name: "Subtract from Linear Gradient",
- exact: true,
- })
+ .getByRole("button", { name: "Linear Gradient actions", exact: true })
+ .click();
+ await page
+ .getByRole("menuitem", { name: "Subtract from mask", exact: true })
.click();
await page.getByRole("menuitem", { name: "Brush", exact: true }).click();
await expect(
diff --git a/tests/editing.e2e.ts b/tests/editing.e2e.ts
index 181fd56..ac630e9 100644
--- a/tests/editing.e2e.ts
+++ b/tests/editing.e2e.ts
@@ -61,7 +61,7 @@ test("edit a photo, inspect the preview and histograms, undo changes, and export
await test.step("image adjustments share a single section", async () => {
await expect(
- page.getByRole("heading", { name: "Image", exact: true }),
+ page.getByRole("heading", { name: "Adjustments", exact: true }),
).toBeVisible();
await expect(
page.getByRole("slider", { name: "Clarity", exact: true }),
@@ -376,7 +376,7 @@ test("edit a photo, inspect the preview and histograms, undo changes, and export
);
const bounds = await graph.boundingBox();
if (!bounds) throw new Error("Curve graph is missing.");
- expect((await box(graph.locator(".."))).height).toBe(200);
+ expect((await box(graph.locator(".."))).height).toBe(180);
await drag(
page,
[bounds.x + bounds.width / 2, bounds.y + bounds.height / 2],
@@ -497,7 +497,7 @@ test("edit a photo, inspect the preview and histograms, undo changes, and export
await page.keyboard.press("ArrowLeft");
await expect(selected).toHaveAccessibleName("Radial gradient");
await expect(
- page.getByRole("heading", { name: "Image", exact: true }),
+ page.getByRole("heading", { name: "Adjustments", exact: true }),
).toBeVisible();
await page.keyboard.press("ArrowLeft");
await page.keyboard.press("ArrowLeft");
diff --git a/tests/layers.e2e.ts b/tests/layers.e2e.ts
index cd38919..dda8cc3 100644
--- a/tests/layers.e2e.ts
+++ b/tests/layers.e2e.ts
@@ -62,7 +62,7 @@ test("draw a mask, edit its child effects, reorder layers and undo", async ({
).toHaveValue("0.00");
await test.step("Details is an optional effect, separate from image adjustments", async () => {
await expect(
- page.getByRole("heading", { name: "Image", exact: true }),
+ page.getByRole("heading", { name: "Adjustments", exact: true }),
).toBeVisible();
await expect(
page.getByRole("textbox", { name: "Clarity", exact: true }),
@@ -234,7 +234,10 @@ test("draw a mask, edit its child effects, reorder layers and undo", async ({
await test.step("a subtracting child changes coverage and Add restores the masked region", async () => {
const masked = await samples(page);
await page
- .getByRole("button", { name: "Subtract from Sky", exact: true })
+ .getByRole("button", { name: "Sky actions", exact: true })
+ .click();
+ await page
+ .getByRole("menuitem", { name: "Subtract from mask", exact: true })
.click();
await page
.getByRole("menuitem", { name: "Linear gradient", exact: true })
@@ -354,7 +357,7 @@ test("draw a mask, edit its child effects, reorder layers and undo", async ({
).toBeVisible();
const panel = page.getByRole("region", { name: "Editor controls" });
await expect(
- panel.getByRole("heading", { name: "Radial Gradient", exact: true }),
+ panel.getByRole("heading", { name: "Mask adjustments", exact: true }),
).toBeVisible();
await expect(
panel.getByRole("textbox", { name: "Feather", exact: true }),
@@ -380,10 +383,10 @@ test("draw a mask, edit its child effects, reorder layers and undo", async ({
).toBe(true);
await page.keyboard.press("ControlOrMeta+z");
await page
- .getByRole("button", {
- name: "Subtract from Radial Gradient",
- exact: true,
- })
+ .getByRole("button", { name: "Radial Gradient actions", exact: true })
+ .click();
+ await page
+ .getByRole("menuitem", { name: "Subtract from mask", exact: true })
.click();
await page
.getByRole("menuitem", { name: "Radial gradient", exact: true })