Free open-source image editor for the browser
Adopt @roprgm/ui 0.6.0 (#49)
Rodrigo Belfioref8774b5c9398
diff --git a/bun.lock b/bun.lockindex df8bd24..a4bf87f 100644--- a/bun.lock+++ b/bun.lock@@ -8,7 +8,7 @@"@base-ui/react": "^1.8.0","@dnd-kit/core": "^6.3.1","@fontsource-variable/geist": "^5.3.0",- "@roprgm/ui": "^0.5.1",+ "@roprgm/ui": "^0.6.0","@tailwindcss/vite": "^4.3.3","@vercel/analytics": "^2.0.1","@vercel/speed-insights": "^2.0.0",@@ -129,7 +129,7 @@"@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=="],+ "@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-4FYKD35zz2TgKLqL5rxjCD5GPoIYSNPWb2py/zABB4vwGmqA+oDrXlX/H13/5pyPPhR9Ff6/pZhIlj7AtA75eA=="],"@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=="],diff --git a/package.json b/package.jsonindex e5d8985..cc73126 100644--- a/package.json+++ b/package.json@@ -15,7 +15,7 @@"@base-ui/react": "^1.8.0","@dnd-kit/core": "^6.3.1","@fontsource-variable/geist": "^5.3.0",- "@roprgm/ui": "^0.5.1",+ "@roprgm/ui": "^0.6.0","@tailwindcss/vite": "^4.3.3","@vercel/analytics": "^2.0.1","@vercel/speed-insights": "^2.0.0",diff --git a/src/app/editor/adjust/index.tsx b/src/app/editor/adjust/index.tsxindex b521527..b45073f 100644--- a/src/app/editor/adjust/index.tsx+++ b/src/app/editor/adjust/index.tsx@@ -53,7 +53,7 @@ function CurveInputHistogram({ id }: { id: string }) {function LayerCurve({ id, toneCurve }: { id: string; toneCurve: ToneCurve }) {const document = useDocument();return (- <div className="px-3 pb-3">+ <div className="px-(--padding) pb-(--padding)"><ToneCurvespoints={toneCurve}onChange={(points) => setToneCurve(document, points, id)}@@ -94,7 +94,7 @@ function SelectedControls({ layer }: { layer: Layer }) {return <HealControls id={layer.id} patches={layer.patches} />;case "exposure":return (- <section className="p-3">+ <section className="p-(--padding)"><Sliderlabel="Exposure"value={layer.exposure}diff --git a/src/app/editor/comparison-control.tsx b/src/app/editor/comparison-control.tsxindex e8568b0..d06016f 100644--- a/src/app/editor/comparison-control.tsx+++ b/src/app/editor/comparison-control.tsx@@ -53,7 +53,7 @@ export function ComparisonControl() {<IconButtonlabel="Compare before and after"shortcut="Hold \"- size="icon-sm"+ size="icon"aria-pressed={comparison !== "edited"}className="aria-pressed:bg-neutral-700 aria-pressed:text-neutral-100"onClick={() =>diff --git a/src/app/editor/export/index.tsx b/src/app/editor/export/index.tsxindex 2372924..11b8d7d 100644--- a/src/app/editor/export/index.tsx+++ b/src/app/editor/export/index.tsx@@ -80,7 +80,7 @@ function FormatSelect({value: format.id,label: format.label,}))}- className="h-7 w-28"+ className="w-28"onValueChange={(id) => {const format = formats.find((format) => format.id === id);if (format) onChange(format);@@ -181,12 +181,12 @@ function SaveScene() {return (<sectionaria-label="Scene export"- className="flex flex-col gap-3 border-black border-t p-4"+ className="flex flex-col gap-3 border-black border-t p-(--padding)"><p className="text-neutral-500">Saves the photo and every edit in one file. Open it to continue editing.</p>- <Button className="w-full" onClick={save}>+ <Button size="lg" className="w-full" onClick={save}>Save scene</Button>{error && (@@ -251,7 +251,7 @@ export function ExportMode({ onClose }: { onClose: () => void }) {<PanelBody header={<PanelHeader title="Export" onClose={onClose} />}><sectionaria-label="Image export"- className="flex flex-col gap-5 p-4"+ className="flex flex-col gap-5 p-(--padding)"><FormatSelect value={format} onChange={setFormat} />{format.lossy && (@@ -276,7 +276,7 @@ export function ExportMode({ onClose }: { onClose: () => void }) {{pending && <Spinner className="size-3" />}</span></SizeFields>- <Button className="w-full" onClick={save}>+ <Button size="lg" className="w-full" onClick={save}>Save image</Button>{error && (diff --git a/src/app/editor/history.tsx b/src/app/editor/history.tsxindex 28e06f0..391fe7d 100644--- a/src/app/editor/history.tsx+++ b/src/app/editor/history.tsx@@ -18,7 +18,7 @@ export function HistoryControls() {<IconButtonlabel="Undo"shortcut="Mod Z"- size="icon-sm"+ size="icon"disabled={!undoCount}onClick={history.undo}>@@ -29,7 +29,7 @@ export function HistoryControls() {<IconButtonlabel="Redo"shortcut="Mod Shift Z"- size="icon-sm"+ size="icon"disabled={!redoCount}onClick={history.redo}>diff --git a/src/app/editor/index.tsx b/src/app/editor/index.tsxindex b505da6..831fc84 100644--- a/src/app/editor/index.tsx+++ b/src/app/editor/index.tsx@@ -77,7 +77,7 @@ function ExportButton() {<Tooltip content="Export the photo or save a scene" shortcut="E"><Buttonaria-pressed={exporting}- className="ml-1 h-7 px-4 aria-pressed:bg-raised-hover"+ className="ml-1 px-4 aria-pressed:bg-raised-hover"onClick={() => setTool(exporting ? tools[0] : exportTool)}>Exportdiff --git a/src/app/editor/tool-rail.tsx b/src/app/editor/tool-rail.tsxindex 0560cbf..19c92c5 100644--- a/src/app/editor/tool-rail.tsx+++ b/src/app/editor/tool-rail.tsx@@ -26,7 +26,7 @@ export function ToolTabList({<Tabselected={entry === selected}disabled={!onSelect}- size="icon"+ size="icon-lg"aria-label={entry.label}onClick={() => onSelect?.(entry)}>diff --git a/src/components/editor/panel.tsx b/src/components/editor/panel.tsxindex 394951f..4646131 100644--- a/src/components/editor/panel.tsx+++ b/src/components/editor/panel.tsx@@ -62,12 +62,7 @@ export function PanelHeader({<Header title={title} className="border-black/50 border-b">{children}{onClose && (- <IconButton- label="Close"- shortcut="Esc"- size="icon-sm"- onClick={onClose}- >+ <IconButton label="Close" shortcut="Esc" size="icon" onClick={onClose}><CloseIcon className="size-4" /></IconButton>)}diff --git a/src/features/adjustments/controls.tsx b/src/features/adjustments/controls.tsxindex 1b90f12..b375ee3 100644--- a/src/features/adjustments/controls.tsx+++ b/src/features/adjustments/controls.tsx@@ -73,7 +73,7 @@ export function AdjustmentControls({temperature?: ReactNode;}) {return (- <section className="flex flex-col gap-2 p-3">+ <section className="flex flex-col gap-1.5 p-(--padding)"><AdjustmentSliders id={id} adjustments={adjustments} controls={tone} />{temperature}<AdjustmentSlidersdiff --git a/src/features/color-mixer/controls.tsx b/src/features/color-mixer/controls.tsxindex d17deab..f57a078 100644--- a/src/features/color-mixer/controls.tsx+++ b/src/features/color-mixer/controls.tsx@@ -71,10 +71,11 @@ export function ColorMixerControls({const [channel, setChannel] = useState<MixerChannel>("hue");const id = useId();return (- <section className="p-3">+ <section className="p-(--padding)"><TabListaria-label="Color Mixer adjustment"- className="mb-3 gap-0.5 rounded-md bg-neutral-900 p-0.5 shadow-sunken"+ variant="segmented"+ className="mb-3">{channels.map(({ id: value, label }) => (<Tab@@ -83,7 +84,7 @@ export function ColorMixerControls({aria-controls={`${id}-sliders`}selected={channel === value}onClick={() => setChannel(value)}- className="h-7 min-w-0 flex-1 rounded-sm px-1"+ className="min-w-0 flex-1 px-1">{label}</Tab>diff --git a/src/features/crop/view.tsx b/src/features/crop/view.tsxindex b09493d..d03102f 100644--- a/src/features/crop/view.tsx+++ b/src/features/crop/view.tsx@@ -116,14 +116,14 @@ export function CropEditor({ onClose }: { onClose: () => void }) {}}><PanelBody header={<PanelHeader title="Crop" onClose={onClose} />}>- <section aria-label="Crop tool" className="space-y-5 p-4">+ <section aria-label="Crop tool" className="space-y-5 p-(--padding)"><div className="flex items-center justify-between text-neutral-400">Aspect ratio<Selectaria-label="Aspect ratio"value={ratio === null ? "free" : `${ratio}`}items={ratioOptions}- className="h-7 w-24"+ className="w-24"onValueChange={(value) => value !== null && changeRatio(value)}/></div>@@ -134,7 +134,8 @@ export function CropEditor({ onClose }: { onClose: () => void }) {<h3 className="col-span-3 text-neutral-400">Rotate & flip</h3><Buttonvariant="ghost"- className="h-6 justify-self-end px-2"+ size="sm"+ className="justify-self-end"onClick={reset}>Reset@@ -174,8 +175,8 @@ export function CropEditor({ onClose }: { onClose: () => void }) {</p></section></PanelBody>- <div className="p-3">- <Button className="w-full" onClick={apply}>+ <div className="p-(--padding-optical)">+ <Button size="lg" className="w-full" onClick={apply}>Apply crop</Button></div>diff --git a/src/features/details/controls.tsx b/src/features/details/controls.tsxindex eb82069..e7ef0f9 100644--- a/src/features/details/controls.tsx+++ b/src/features/details/controls.tsx@@ -18,7 +18,7 @@ export function DetailsControls({["sharpenRadius", "Radius", 0.1],] as const;return (- <section className="flex flex-col gap-2 p-3">+ <section className="flex flex-col gap-1.5 p-(--padding)">{controls.map(([name, label, step]) => (<Sliderkey={name}diff --git a/src/features/fill/controls.tsx b/src/features/fill/controls.tsxindex 2f45342..b2ba74f 100644--- a/src/features/fill/controls.tsx+++ b/src/features/fill/controls.tsx@@ -16,7 +16,7 @@ export function FillControls({ id, fill }: { id: string; fill: Fill }) {return () => input?.removeEventListener("change", commit);}, [document]);return (- <section className="flex flex-col gap-3 p-3">+ <section className="flex flex-col gap-3 p-(--padding)"><label className="flex items-center justify-between text-neutral-400">Color<span className="flex items-center gap-2">@@ -42,7 +42,7 @@ export function FillControls({ id, fill }: { id: string; fill: Fill }) {aria-label="Blend"value={fill.blend}items={blends.map(([value, label]) => ({ value, label }))}- className="h-7 w-28"+ className="w-28"onValueChange={(blend) => blend && setFill(document, { blend }, id)}/></div>diff --git a/src/features/heal/controls.tsx b/src/features/heal/controls.tsxindex 232c526..a5690ec 100644--- a/src/features/heal/controls.tsx+++ b/src/features/heal/controls.tsx@@ -39,7 +39,7 @@ function PatchActions({trigger={<IconButtonlabel="Patch actions"- size="icon-sm"+ size="icon"className="pointer-coarse:size-10"><Icon className="size-4">diff --git a/src/features/layers/brush-options.tsx b/src/features/layers/brush-options.tsxindex 204ddb2..8bdf0fb 100644--- a/src/features/layers/brush-options.tsx+++ b/src/features/layers/brush-options.tsx@@ -1,6 +1,7 @@import { Chip } from "@roprgm/ui/chip";import { Slider } from "@roprgm/ui/slider";import { Tooltip } from "@roprgm/ui/tooltip";+import { cn } from "cn";import { useBrushTool } from "@/components/editor/brush-tool";import { barSlider, useBarDensity } from "@/components/editor/toolbar-density";@@ -12,7 +13,10 @@ const modes = [/** The next stroke's mode, size, edge, and flow, in the bar over the canvas. Alt shows on the Erase chip. */export function BrushOptions() {const { settings, erase, maxSize, setPreview, update } = useBrushTool();- const variant = barSlider(useBarDensity());+ const density = useBarDensity();+ const variant = barSlider(density);+ // In the overflow menu the group spans the column, so the two modes share it evenly.+ const menu = density === "menu";return (<><fieldset@@ -23,7 +27,7 @@ export function BrushOptions() {<Tooltip key={mode} content={hint} shortcut={shortcut}><Chiparia-pressed={erase === (mode === "erase")}- className="h-6"+ className={cn("h-6", menu && "flex-1 justify-center")}onClick={() => update({ erase: mode === "erase" })}>{label}diff --git a/src/features/layers/controls.tsx b/src/features/layers/controls.tsxindex dff6270..873f8d6 100644--- a/src/features/layers/controls.tsx+++ b/src/features/layers/controls.tsx@@ -275,7 +275,7 @@ export function LayersControls({trigger={<IconButtonlabel="Add effect"- size="icon-sm"+ size="icon"className="pointer-coarse:size-10"><Icon className="size-4">diff --git a/src/features/layers/menu.tsx b/src/features/layers/menu.tsxindex d3a5818..b6cb0b9 100644--- a/src/features/layers/menu.tsx+++ b/src/features/layers/menu.tsx@@ -124,7 +124,7 @@ export function LayerActions(props: {trigger={<IconButtonlabel={`${props.layer.name} actions`}- size="icon-sm"+ size="icon"className="pointer-coarse:size-10"><Icon className="size-4">diff --git a/src/features/layers/overlay-toggle.tsx b/src/features/layers/overlay-toggle.tsxindex a7afe69..9378ca9 100644--- a/src/features/layers/overlay-toggle.tsx+++ b/src/features/layers/overlay-toggle.tsx@@ -22,7 +22,7 @@ export function OverlayToggle() {<IconButtonlabel="Mask overlay"shortcut="O"- size="icon-sm"+ size="icon"aria-pressed={shown}onClick={toggle}className="pointer-coarse:size-10 aria-pressed:bg-pressed aria-pressed:text-foreground"diff --git a/src/features/layers/toolbar.tsx b/src/features/layers/toolbar.tsxindex 295c693..05f7c01 100644--- a/src/features/layers/toolbar.tsx+++ b/src/features/layers/toolbar.tsx@@ -54,17 +54,20 @@ export function CanvasToolbar({ children }: { children?: ReactNode }) {);const bar = useRef<HTMLFieldSetElement>(null);const [step, setStep] = useState(0);+ // The canvas's width, kept so a resize always renders again, even when the bar is already at its+ // roomiest step, and the overflow below is measured anew.+ const [width, setWidth] = useState(0);const hasLayerOptions = layer.kind !== "image" && layer.kind !== "heal";const shown = Boolean(children) || hasLayerOptions;const content = `${Boolean(children)}/${layer.kind}/${layer.kind === "mask" ? layer.mask.kind : ""}`;// New content or a resized canvas starts again from the roomiest layout.- useLayoutEffect(() => setStep(0), [content]);+ useLayoutEffect(() => setStep(0), [content, width]);useLayoutEffect(() => {const canvas = bar.current?.parentElement;if (!shown || !canvas) {return;}- const observer = new ResizeObserver(() => setStep(0));+ const observer = new ResizeObserver(() => setWidth(canvas.clientWidth));observer.observe(canvas);return () => observer.disconnect();}, [shown]);@@ -91,8 +94,9 @@ export function CanvasToolbar({ children }: { children?: ReactNode }) {aria-label="Layer options"{...gesture}// No wrapping, so running out of room overflows, which is what the steps above measure. A button or- // group first nests its corners 4px in; a text label first, such as a slider's, needs 8px more.- 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 [&>:first-child:not(button,fieldset)]:ml-2"+ // group at either end nests its corners 4px in; a text label first, such as a slider's, needs 8px+ // more, and a slider last 6px more, since a compact slider's value pulls 4px past its cell.+ 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 backdrop-blur-sm [&>:first-child:not(button,fieldset)]:ml-2 [&>:last-child:not(button,fieldset)]:mr-1.5"><Density value={step === 0 ? "full" : "compact"}>{inlineTool}@@ -103,7 +107,7 @@ export function CanvasToolbar({ children }: { children?: ReactNode }) {trigger={<IconButtonlabel="More options"- size="icon-sm"+ size="icon"className="rounded-full"><Icon className="size-4">diff --git a/src/features/tone-curves/tone-curves.tsx b/src/features/tone-curves/tone-curves.tsxindex bd846e0..3185aff 100644--- a/src/features/tone-curves/tone-curves.tsx+++ b/src/features/tone-curves/tone-curves.tsx@@ -18,7 +18,7 @@ export function ToneCurves({ points, onChange, children }: ToneCurvesProps) {<Buttonvariant="ghost"aria-label="Reset curve"- className="h-6 px-2"+ size="sm"onClick={() => onChange(defaultCurve)}>Resetdiff --git a/src/features/vignette/controls.tsx b/src/features/vignette/controls.tsxindex b8912d8..1cfc487 100644--- a/src/features/vignette/controls.tsx+++ b/src/features/vignette/controls.tsx@@ -13,7 +13,7 @@ export function VignetteControls({}) {const document = useDocument();return (- <section className="flex flex-col gap-2 p-3">+ <section className="flex flex-col gap-1.5 p-(--padding)"><Sliderlabel="Intensity"value={vignette.intensity}diff --git a/src/index.css b/src/index.cssindex d0156e1..31a77a3 100644--- a/src/index.css+++ b/src/index.css@@ -1,19 +1,14 @@@import "tailwindcss";-/* Color tokens, shadows, focus ring, text shadow, and the `thumb:` variant that the shared components use. */-@import "@roprgm/ui/theme.css";+/* The library's tokens, primitives, and utilities, drawn by its default theme. */+@import "@roprgm/ui/themes/default.css";@theme {--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. */+/* The editor's panels, header, and rail. Controls inside mix their fills from it. */@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);}@@ -40,6 +35,10 @@font-size: var(--text-xs);line-height: var(--text-xs--line-height);color: var(--color-foreground);- background: var(--color-neutral-900);+ }++ /* The page is a layer too, so controls on the canvas mix their fills from its color. */+ :root {+ --layer: var(--color-neutral-900);}}