Skip to content

Free open-source image editor for the browser

Improve responsive editor layout (#34)

Rodrigo Belfioreaa4e2bbc4912
diff --git a/src/app/editor/histogram.tsx b/src/app/editor/histogram.tsx
index 9e64a05..9270072 100644
--- a/src/app/editor/histogram.tsx
+++ b/src/app/editor/histogram.tsx
@@ -15,7 +15,7 @@ export function ImageHistogram() {
return (
<section
aria-label="Image histogram"
- className="group relative shrink-0 border-b border-black bg-neutral-900"
+ className="group relative shrink-0 border-b border-black bg-neutral-900 max-md:absolute max-md:bottom-full max-md:left-3 max-md:z-10 max-md:mb-3 max-md:h-14 max-md:w-44 max-md:overflow-hidden max-md:border-0 max-md:bg-neutral-800/80 max-md:backdrop-blur-sm"
>
<ClippingControls />
<Histogram
@@ -24,7 +24,7 @@ export function ImageHistogram() {
subscribe={renderer.subscribe}
colors={colors}
fillOpacity={0.2}
- className="h-25 w-full"
+ className="block h-25 w-full max-md:h-full"
aria-label="output histogram"
/>
</section>
diff --git a/src/components/ui/resizable-panel.tsx b/src/components/ui/resizable-panel.tsx
index a81e6e6..ad7f7f0 100644
--- a/src/components/ui/resizable-panel.tsx
+++ b/src/components/ui/resizable-panel.tsx
@@ -8,7 +8,7 @@ type ResizablePanelProps = ComponentProps<"aside"> & {
max?: number;
};
-/** Bottom half on mobile; right-side panel with a draggable left edge on desktop. */
+/** Bottom panel on mobile; right-side panel with a draggable left edge on desktop. */
export default function ResizablePanel({
width = 320,
onWidthChange,
@@ -26,7 +26,7 @@ export default function ResizablePanel({
return (
<aside
className={cn(
- "relative h-1/2 shrink-0 bg-panel max-md:w-full! max-md:border-t max-md:border-black md:h-auto",
+ "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 }}
diff --git a/src/features/tone-curves/tone-curves.tsx b/src/features/tone-curves/tone-curves.tsx
index 71de081..697fd2a 100644
--- a/src/features/tone-curves/tone-curves.tsx
+++ b/src/features/tone-curves/tone-curves.tsx
@@ -25,7 +25,7 @@ export function ToneCurves({ points, onChange, children }: ToneCurvesProps) {
</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">
+ <div className="relative aspect-square max-h-60 w-full rounded border border-black bg-neutral-900 shadow-groove md:max-h-50">
{children}
<Graph onChange={onChange} points={points} />
</div>
diff --git a/tests/editing.e2e.ts b/tests/editing.e2e.ts
index f482c8d..ca12615 100644
--- a/tests/editing.e2e.ts
+++ b/tests/editing.e2e.ts
@@ -378,6 +378,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);
await drag(
page,
[bounds.x + bounds.width / 2, bounds.y + bounds.height / 2],
@@ -1035,6 +1036,23 @@ test("edit a photo, inspect the preview and histograms, undo changes, and export
await mobile
.locator('input[type="file"]')
.setInputFiles("tests/fixtures/photo.svg");
+ const canvas = await box(
+ mobile.getByRole("region", { name: "Image canvas" }),
+ );
+ const histogram = await box(
+ mobile.getByRole("region", { name: "Image histogram" }),
+ );
+ const sidebar = mobile.locator("aside");
+ const sidebarBounds = await box(sidebar);
+ const editorBounds = await box(sidebar.locator(".."));
+ expect(sidebarBounds.height / editorBounds.height).toBeCloseTo(0.45, 2);
+ expect(histogram.width).toBe(176);
+ expect(histogram.height).toBe(56);
+ expect(histogram.x).toBeCloseTo(canvas.x + 12, 0);
+ const bottomGap =
+ canvas.y + canvas.height - histogram.y - histogram.height;
+ expect(bottomGap).toBeGreaterThanOrEqual(11);
+ expect(bottomGap).toBeLessThanOrEqual(12);
const exposure = mobile.getByRole("slider", {
name: "Exposure",
exact: true,