Skip to content

armgit / kokon

Public Imported from GitHub
0

Edit photos by describing the change, on your own GPU. A free, open-source alternative to Nano Banana and ChatGPT image editing: photos stay on your computer, no daily limit. One installer for Windows, Mac and Linux sets up the best open model (Qwen-Image 2.1). MCP server for AI agents.

Phones: a layout of their own, and images that develop into view

Gabriele Lozuponeffe0a92c746a
diff --git a/index.html b/index.html
index a6c3abb..cefd9e4 100644
--- a/index.html
+++ b/index.html
@@ -12,6 +12,10 @@
<link rel="manifest" href="/manifest.webmanifest" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-title" content="Kokon" />
+ <!-- The colour of the phone's status bar (and Safari's bars): the page's ground for the phone's
+ own appearance; theme.js sets both to the theme chosen in Kokon. -->
+ <meta name="theme-color" content="#f4f4f4" media="(prefers-color-scheme: light)" />
+ <meta name="theme-color" content="#0a0a0a" media="(prefers-color-scheme: dark)" />
<!-- Painted before any JavaScript runs, so the window never shows an empty white page
(the dev server can take seconds to compile; the web view itself needs a moment).
React replaces #root's content when the app mounts. Colors match styles.css. -->
diff --git a/public/theme.js b/public/theme.js
index 7238a2a..9444a6a 100644
--- a/public/theme.js
+++ b/public/theme.js
@@ -11,7 +11,19 @@
try {
t = localStorage.getItem("qls.theme.v1");
} catch (e) {}
- document.documentElement.dataset.theme = t === "light" || t === "dark" ? t : dark.matches ? "dark" : "light";
+ var theme = t === "light" || t === "dark" ? t : dark.matches ? "dark" : "light";
+ document.documentElement.dataset.theme = theme;
+ // The status bar of a phone (Kokon added to the home screen) in the page's own ground colour
+ // (styles.css --ground), not the manifest's light one.
+ var ground = theme === "dark" ? (document.documentElement.dataset.platform === "mac" ? "#161616" : "#0a0a0a") : "#f4f4f4";
+ // Replaced, not edited: iOS (a home-screen app) seems to read a new tag but not a changed one.
+ document.querySelectorAll('meta[name="theme-color"]').forEach(function (m) {
+ var fresh = document.createElement("meta");
+ fresh.name = "theme-color";
+ fresh.content = ground;
+ if (m.media) fresh.media = m.media;
+ m.replaceWith(fresh);
+ });
}
apply();
dark.addEventListener("change", apply);
diff --git a/src/App.tsx b/src/App.tsx
index 3326fa9..805cad6 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -3,7 +3,7 @@ import { Star, X } from "lucide-react";
import { useEffect, useRef, useState } from "react";
import { api, ApiError, configure, setSignedOutHandler } from "./lib/api";
import { native } from "./lib/native";
-import { inBrowser } from "./lib/platform";
+import { inBrowser, isNarrow, useNarrow } from "./lib/platform";
import {
addExampleProjects, closeStarPrompt, loadProjects, dismissToast, getState, initStarPrompt, redoVersion, refreshLoras, refreshStatus, selectItem, setState, startEvents, startTour, submitComposer, toastError, toastInfo, undoVersion, useStore,
} from "./lib/store";
@@ -22,6 +22,7 @@ import { Shortcuts } from "./components/Shortcuts";
import { WhatsNew, whatsNewDue } from "./components/WhatsNew";
import { UpscalerCompare } from "./components/Upscalers";
import { KokonMark, Welcome } from "./components/Welcome";
+import { PhoneApp } from "./components/PhoneApp";
import { BareTitleBar } from "./components/TitleBar";
import { TopBar } from "./components/TopBar";
import { autoCheckForUpdate } from "./lib/updates";
@@ -120,13 +121,15 @@ export default function App() {
// Bumped after signing in, to run the start-up again.
const [attempt, setAttempt] = useState(0);
const [dragging, setDragging] = useState(false);
+ const narrow = useNarrow();
// First launch: the tour starts once the main window is free (after welcome and setup).
const tourPending = useRef(false);
const tourDue = boot === "ok" && !needsSetup && !overlay;
useEffect(() => {
if (!tourDue || !tourPending.current) return;
tourPending.current = false;
- startTour();
+ // The tour points at the desktop layout; a phone has its own.
+ if (!isNarrow()) startTour();
}, [tourDue]);
// Connect to (or start) the local service.
@@ -337,6 +340,29 @@ export default function App() {
);
}
+ // Settings and the other dialogs, over either layout.
+ const dialogs = (
+ <>
+ {overlay === "settings" && <SettingsDialog />}
+ {overlay === "welcome" && <Welcome />}
+ {overlay === "whats-new" && <WhatsNew />}
+ {overlay === "prompt-tips" && <PromptTips />}
+ {overlay === "shortcuts" && <Shortcuts />}
+ {compareUpscalers && <UpscalerCompare />}
+ </>
+ );
+
+ // A phone: its own layout (components/PhoneApp.tsx); setup keeps the usual one.
+ if (narrow && !needsSetup) {
+ return (
+ <div className="app phone">
+ <PhoneApp />
+ {dialogs}
+ <Toasts />
+ </div>
+ );
+ }
+
return (
<div className="app">
{sidebar && !needsSetup && <Sidebar />}
@@ -351,12 +377,7 @@ export default function App() {
</div>
{!needsSetup && overlay !== "inpaint" && overlay !== "expand" && overlay !== "gallery" && <Composer />}
</div>
- {overlay === "settings" && <SettingsDialog />}
- {overlay === "welcome" && <Welcome />}
- {overlay === "whats-new" && <WhatsNew />}
- {overlay === "prompt-tips" && <PromptTips />}
- {overlay === "shortcuts" && <Shortcuts />}
- {compareUpscalers && <UpscalerCompare />}
+ {dialogs}
<Tour />
<Toasts />
</div>
diff --git a/src/components/Cocoon.tsx b/src/components/Cocoon.tsx
index f37fc99..97a98b7 100644
--- a/src/components/Cocoon.tsx
+++ b/src/components/Cocoon.tsx
@@ -457,7 +457,8 @@ export function Hatch({ id, aspect, children }: { id?: string; aspect: number; c
}, []);
return (
- <div className="hatch" ref={ref}>
+ // data-hatching: images inside show at once (Develop.tsx), the hatch reveals them.
+ <div className="hatch" ref={ref} data-hatching={running ? "" : undefined}>
{/* The canvas stays visible while the logo opens on it. */}
{running && <div className="hatch-canvas" ref={canvasBox} />}
<div className="hatch-body" ref={body}>
diff --git a/src/components/Compare.tsx b/src/components/Compare.tsx
index 9750625..a6ce8a0 100644
--- a/src/components/Compare.tsx
+++ b/src/components/Compare.tsx
@@ -1,12 +1,15 @@
// Before / after views for results made from another image (edit, inpaint, expand, upscale).
+import { ChevronDown, SquareSplitHorizontal } from "lucide-react";
import { useEffect, useMemo, useRef, useState, type CSSProperties } from "react";
import { urls } from "../lib/api";
import { diffPixels, type CompareBase, type CompareMode } from "../lib/logic";
-import { inBrowser } from "../lib/platform";
+import { haptic } from "../lib/haptics";
+import { inBrowser, isNarrow, useNarrow } from "../lib/platform";
import { setState, stageImage, useStore } from "../lib/store";
import type { GenerationRecord } from "../lib/types";
-import { Seg, useFit } from "./ui";
+import { DevelopImg } from "./Develop";
+import { Option, Popover, Seg, useFit } from "./ui";
import { FullscreenButton } from "./Viewer";
import { ZoomPan } from "./ZoomPan";
@@ -31,10 +34,18 @@ export function CompareFrame({ g, base, fullscreen = false, maskSrc, onFullscree
const mode = useStore((s) => s.compare);
const flickerMs = useStore((s) => s.flickerMs);
const { ref, box } = useFit(g.width / g.height);
+ const phone = useNarrow();
const [split, setSplit] = useState(0.5);
const [holding, setHolding] = useState(false);
const [phase, setPhase] = useState<"before" | "after">("after");
const dragging = useRef(false);
+ // A finger shows the original only once it rests for a moment: a swipe to the next version
+ // (phone) must not flash it.
+ const hold = useRef<{ timer: number; x: number; y: number } | null>(null);
+ const endHold = () => {
+ if (hold.current) window.clearTimeout(hold.current.timer);
+ hold.current = null;
+ };
const boxRef = useRef<HTMLDivElement>(null);
const contentSize = useMemo(() => ({ width: g.width, height: g.height }), [g.width, g.height]);
// In a browser the Result view loads only the result, as a preview when it is as sharp
@@ -98,25 +109,31 @@ export function CompareFrame({ g, base, fullscreen = false, maskSrc, onFullscree
if (mode === "slider") {
dragging.current = true;
setFromPointer(e.clientX);
+ } else if (mode === "off" && e.pointerType === "touch") {
+ endHold();
+ hold.current = { timer: window.setTimeout(() => setHolding(true), 280), x: e.clientX, y: e.clientY };
} else if (mode === "off") setHolding(true);
}}
onPointerMove={(e) => {
+ if (hold.current && Math.hypot(e.clientX - hold.current.x, e.clientY - hold.current.y) > 10) endHold();
if (!dragging.current) return;
e.stopPropagation();
setFromPointer(e.clientX);
}}
onPointerUp={() => {
dragging.current = false;
+ endHold();
if (mode === "off") setHolding(false);
}}
onPointerCancel={() => {
dragging.current = false;
+ endHold();
setHolding(false);
}}
onDoubleClick={() => setState({ overlay: null })}
title={mode === "off" && !zoomed ? "Press and hold (or hold B) to see the original" : undefined}
>
- <img className="compare-img" src={after} alt={g.prompt} draggable={false} />
+ <DevelopImg className="compare-img" src={after} placeholder={urls.genThumb(g.id)} alt={g.prompt} />
{mode === "diff" && !holding && before && <DiffCanvas after={after} before={before} rect={base.rect} tagStyle={tag("left")} />}
{/* The area painted for the next edit, on the result (the original covers it when shown). */}
{maskSrc && <img className="stage-mask" src={maskSrc} alt="" draggable={false} />}
@@ -149,7 +166,8 @@ export function CompareFrame({ g, base, fullscreen = false, maskSrc, onFullscree
</>
)}
{label && <span className="compare-tag left" style={tag("left")}>{label}</span>}
- {!fullscreen && (
+ {!fullscreen && phone && <PhoneCompare />}
+ {!fullscreen && !phone && (
<div className="compare-overlay" onPointerDown={(e) => e.stopPropagation()} onDoubleClick={(e) => e.stopPropagation()}>
<CompareBar />
</div>
@@ -245,13 +263,67 @@ function DiffCanvas({ after, before, rect, tagStyle }: { after: string; before:
);
}
+const MODE_SUB: Record<CompareMode, string> = { off: "the new version", slider: "drag across it", flicker: "back and forth", diff: "what changed" };
+
+/** A phone: the views behind one small button on the picture (four side by side don't fit a
+ * narrow picture); its sheet offers them, and Flicker's speeds. */
+function PhoneCompare() {
+ const mode = useStore((s) => s.compare);
+ const flickerMs = useStore((s) => s.flickerMs);
+ return (
+ <div className="compare-pill-wrap" onPointerDown={(e) => e.stopPropagation()} onDoubleClick={(e) => e.stopPropagation()}>
+ <Popover
+ trigger={(open, toggle) => (
+ <button className={`compare-pill ${open ? "on" : ""}`} onClick={toggle} title="Compare with the original">
+ <SquareSplitHorizontal size={15} />
+ {MODES.find((m) => m.value === mode)?.label}
+ <ChevronDown size={13} />
+ </button>
+ )}
+ >
+ {(close) => (
+ <>
+ <div className="label">Compare with the original</div>
+ {MODES.map((m) => (
+ <Option
+ key={m.value}
+ selected={mode === m.value}
+ label={m.label}
+ sub={MODE_SUB[m.value]}
+ onClick={() => {
+ haptic();
+ setState({ compare: m.value });
+ if (m.value !== "flicker") close();
+ }}
+ />
+ ))}
+ {mode === "flicker" && (
+ <div className="compare-speed">
+ <span className="muted">Speed</span>
+ <Seg value={String(flickerMs)} options={SPEEDS} onChange={(v) => setState({ flickerMs: Number(v) })} />
+ </div>
+ )}
+ </>
+ )}
+ </Popover>
+ </div>
+ );
+}
+
/** View switch shown under a result that has an original to compare with. */
export function CompareBar() {
const mode = useStore((s) => s.compare);
const flickerMs = useStore((s) => s.flickerMs);
return (
<div className="compare-bar">
- <Seg value={mode} options={MODES} onChange={(v) => setState({ compare: v })} />
+ <Seg
+ value={mode}
+ options={MODES}
+ onChange={(v) => {
+ if (isNarrow()) haptic();
+ setState({ compare: v });
+ }}
+ />
{mode === "flicker" && <Seg value={String(flickerMs)} options={SPEEDS} onChange={(v) => setState({ flickerMs: Number(v) })} />}
</div>
);
diff --git a/src/components/Composer.tsx b/src/components/Composer.tsx
index 54a3577..c7e74f9 100644
--- a/src/components/Composer.tsx
+++ b/src/components/Composer.tsx
@@ -3,7 +3,8 @@ import { useEffect, useMemo, useRef, useState } from "react";
import { api, urls } from "../lib/api";
import { activeLoras, activeOverrides, aspectLabel, buildRequest, composing, editing, enhancerApplies, expansionPixels, formatDuration, hasOutpaint, imageName, MAX_LORAS, moveRef, needsPrompt, parseRatio, toggleLora, wantsPromptReview, type Ref } from "../lib/logic";
import { native } from "../lib/native";
-import { inBrowser } from "../lib/platform";
+import { haptic } from "../lib/haptics";
+import { inBrowser, useNarrow } from "../lib/platform";
import {
addAsReference, addInputs, cancelPromptReview, editShownImage, enhancerAvailable, getState, itemSource, openSettings, selectedItem, sessionLabels, setProjectLoras, setState, startNewImage, submitComposer, toastError, undoEnhancedPrompt, updateComposer, useStore, type SessionItem,
} from "../lib/store";
@@ -28,6 +29,10 @@ const INPAINT_ACTIONS: { value: InpaintAction; label: string; placeholder: strin
const INPAINT_VERB: Record<InpaintAction, string> = { edit: "Changing", remove: "Clearing", replace: "Replacing", add: "Adding to" };
+/** When a phone's open prompt box was last closed by a tap outside it: that tap only closes it
+ * (PhoneStage.tsx Swipe ignores it). */
+export let promptClosedAt = 0;
+
/** Images from this device (browser picker, drop, paste): uploaded to the service. */
export async function uploadFiles(files: File[]) {
const recs = [];
@@ -436,6 +441,37 @@ function PromptPlus() {
);
}
+/** A phone with the box closed: what the prompt works on, as a small picture (the image it edits,
+ * or a new image's first reference) or a spark for a new image from words alone, and in words. */
+function PromptContext() {
+ const c = useStore((s) => s.composer);
+ const nameOf = useRefNames();
+ const first = c.refs[0];
+ if (!first) {
+ return (
+ <span className="prompt-ctx-wrap">
+ <span className="prompt-ctx new">
+ <Sparkles size={16} />
+ </span>
+ <span className="prompt-ctx-label">New image</span>
+ </span>
+ );
+ }
+ const create = composing(c);
+ const n = c.refs.length;
+ return (
+ <span className="prompt-ctx-wrap">
+ <span className="prompt-ctx">
+ <img src={urls.sourceThumb(first.source)} alt="" draggable={false} />
+ {create ? n > 1 && <span className="num">{n}</span> : <span className="frame-badge"><Pencil size={9} /></span>}
+ </span>
+ <span className="prompt-ctx-label">
+ {create ? `New image · ${n === 1 ? "1 reference" : `${n} references`}` : n > 1 ? `Combining ${n} images` : `Editing ${(nameOf(first) ?? "this image").toLowerCase()}`}
+ </span>
+ </span>
+ );
+}
+
/** Under the prompt: the prompt in the box was written by Prompt+ from the user's words. */
function EnhancedFrom({ words }: { words: string }) {
return (
@@ -464,6 +500,33 @@ export function Composer() {
const review = useStore((s) => s.review);
const reviewJob = useStore((s) => (s.review ? s.jobs[s.review.jobId] : undefined));
const reviewing = !!review;
+ // A phone: one line over the image until tapped, then the whole box (over a scrim).
+ const phone = useNarrow();
+ const [opened, setOpened] = useState(false);
+ const expanded = !phone || opened || reviewing;
+ const collapse = () => {
+ taRef.current?.blur();
+ setOpened(false);
+ };
+ // A phone: a tap outside the box (and outside its menus) closes it; the screen above makes room
+ // for it while it is open, nothing covers the screen.
+ useEffect(() => {
+ if (!phone || !opened || reviewing) return;
+ const down = (e: PointerEvent) => {
+ const t = e.target as HTMLElement | null;
+ if (t?.closest(".composer-wrap, .popover, .sheet-scrim, .modal-scrim, .viewer")) return;
+ promptClosedAt = performance.now();
+ collapse();
+ };
+ // Capture phase: the image stops its own pointerdown (press to compare).
+ document.addEventListener("pointerdown", down, true);
+ return () => document.removeEventListener("pointerdown", down, true);
+ });
+ const submit = () => {
+ if (phone) haptic();
+ submitComposer();
+ if (phone && !wantsPromptReview(getState().composer)) collapse();
+ };
useEffect(() => {
const ta = taRef.current;
@@ -510,6 +573,9 @@ export function Composer() {
? "Describe the extended scene (optional details)…"
: "Describe the change…";
+ // The closed box on a phone has one short line.
+ const shortPlaceholder = !hasImages ? "Describe a new image…" : composing(c) ? "Describe the new image…" : c.mask ? "Describe the painted area…" : "Describe the change…";
+
const hint = (() => {
if (error) return error;
if (!plan) return "";
@@ -533,131 +599,168 @@ export function Composer() {
? c.customWidth / c.customHeight
: (parseRatio(c.aspect) ?? (plan ? plan.output.width / plan.output.height : 1));
+ const promptBox = (
+ <textarea
+ id="prompt"
+ ref={taRef}
+ className={`prompt ${reviewing ? "writing" : ""}`}
+ rows={1}
+ value={reviewing ? (reviewJob?.enhanced_prompt ?? "") : c.prompt}
+ readOnly={reviewing}
+ placeholder={expanded ? placeholder : shortPlaceholder}
+ // Emptying a prompt Prompt+ wrote starts over with the user's own words.
+ onChange={(e) => updateComposer({ prompt: e.target.value, ...(e.target.value.trim() ? {} : { enhancedFrom: null }) })}
+ onKeyDown={(e) => {
+ if (e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing) {
+ e.preventDefault();
+ submit();
+ } else if (e.key === "ArrowUp" && !c.prompt) {
+ const last = getState().lastPrompt;
+ if (last) {
+ e.preventDefault();
+ updateComposer({ prompt: last });
+ }
+ }
+ }}
+ onFocus={() => phone && setOpened(true)}
+ enterKeyHint={phone ? "send" : undefined}
+ spellCheck
+ />
+ );
+
+ const sendButton = reviewing ? (
+ <button className="send" title="Stop Prompt+ (your prompt stays)" aria-label="Stop Prompt+" onClick={() => cancelPromptReview()}>
+ <Square size={14} strokeWidth={2.4} />
+ </button>
+ ) : (
+ <button
+ className="send"
+ title={wantsPromptReview(c) ? "Write the prompt with Prompt+ (Enter)" : newImage ? "Create (Enter)" : "Apply (Enter)"}
+ aria-label={wantsPromptReview(c) ? "Write the prompt" : "Generate"}
+ disabled={!c.prompt.trim() && needsPrompt(c)}
+ onClick={submit}
+ >
+ {wantsPromptReview(c) ? <WandSparkles size={17} strokeWidth={2.2} /> : <ArrowUp size={18} strokeWidth={2.4} />}
+ </button>
+ );
+
return (
- <div className="composer-wrap">
- <div className="composer">
- <TargetBar />
- <textarea
- id="prompt"
- ref={taRef}
- className={`prompt ${reviewing ? "writing" : ""}`}
- rows={1}
- value={reviewing ? (reviewJob?.enhanced_prompt ?? "") : c.prompt}
- readOnly={reviewing}
- placeholder={placeholder}
- // Emptying a prompt Prompt+ wrote starts over with the user's own words.
- onChange={(e) => updateComposer({ prompt: e.target.value, ...(e.target.value.trim() ? {} : { enhancedFrom: null }) })}
- onKeyDown={(e) => {
- if (e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing) {
- e.preventDefault();
- submitComposer();
- } else if (e.key === "ArrowUp" && !c.prompt) {
- const last = getState().lastPrompt;
- if (last) {
- e.preventDefault();
- updateComposer({ prompt: last });
- }
- }
- }}
- spellCheck
- />
- {c.enhancedFrom && !reviewing && <EnhancedFrom words={c.enhancedFrom} />}
- <div className="controls">
- <AddImage />
+ <div className={`composer-wrap ${phone ? "phone" : ""} ${phone && expanded ? "open" : ""}`}>
+ <div className="composer" onClick={phone && !expanded ? () => taRef.current?.focus() : undefined}>
+ {/* A phone writes on a screen of its own: close it here (sending closes it too). */}
+ {phone && expanded && (
+ <div className="compose-head">
+ <button className="glass-btn" title="Close" aria-label="Close" onClick={collapse}>
+ <ChevronDown size={22} />
+ </button>
+ <span className="compose-hint" title={hintTitle}>
+ {hint}
+ </span>
+ </div>
+ )}
+ {expanded && <TargetBar />}
+ {phone ? (
+ <div className="prompt-row">
+ {promptBox}
+ {!expanded && (
+ <div className="closed-row">
+ <PromptContext />
+ {sendButton}
+ </div>
+ )}
+ </div>
+ ) : (
+ promptBox
+ )}
+ {expanded && c.enhancedFrom && !reviewing && <EnhancedFrom words={c.enhancedFrom} />}
+ {expanded && (
+ <div className="controls-row">
+ <div className="controls">
+ <AddImage />
+
+ {c.mask && (
+ <Seg value={c.inpaintAction} options={INPAINT_ACTIONS} onChange={(v) => updateComposer({ inpaintAction: v })} />
+ )}
- {c.mask && (
- <Seg value={c.inpaintAction} options={INPAINT_ACTIONS} onChange={(v) => updateComposer({ inpaintAction: v })} />
- )}
+ {shaped && (
+ <Popover
+ className="wide"
+ trigger={(open, toggle) => (
+ <button className={`pill ${open ? "on" : ""}`} onClick={toggle} title="Aspect ratio">
+ <RatioIcon ratio={aspectRatioNow} size={15} />
+ {aspectText}
+ <ChevronDown size={13} className="chev" />
+ </button>
+ )}
+ >
+ {(close) => <AspectGrid value={custom ? aspectLabel(c.customWidth, c.customHeight) : c.aspect} onPick={(r) => (pickAspect(r), close())} auto={{ sub: newImage ? "From the prompt, else square" : "Same as image 1" }} />}
+ </Popover>
+ )}
- {shaped && (
<Popover
className="wide"
trigger={(open, toggle) => (
- <button className={`pill ${open ? "on" : ""}`} onClick={toggle} title="Aspect ratio">
- <RatioIcon ratio={aspectRatioNow} size={15} />
- {aspectText}
+ <button className={`pill ${open ? "on" : ""}`} onClick={toggle} title="Resolution">
+ <Maximize size={14} />
+ {resolutionLabel(c.resolution, c.customWidth, c.customHeight)}
<ChevronDown size={13} className="chev" />
</button>
)}
>
- {(close) => <AspectGrid value={custom ? aspectLabel(c.customWidth, c.customHeight) : c.aspect} onPick={(r) => (pickAspect(r), close())} auto={{ sub: newImage ? "From the prompt, else square" : "Same as image 1" }} />}
+ {(close) => <ResolutionMenu plan={plan} close={close} />}
</Popover>
- )}
-
- <Popover
- className="wide"
- trigger={(open, toggle) => (
- <button className={`pill ${open ? "on" : ""}`} onClick={toggle} title="Resolution">
- <Maximize size={14} />
- {resolutionLabel(c.resolution, c.customWidth, c.customHeight)}
- <ChevronDown size={13} className="chev" />
- </button>
- )}
- >
- {(close) => <ResolutionMenu plan={plan} close={close} />}
- </Popover>
-
- <Popover
- trigger={(open, toggle) => (
- <button className={`pill ${open ? "on" : ""}`} onClick={toggle} title="Quality">
- <Gauge size={15} />
- <span className="lbl">{QUALITY.find((q) => q.value === c.quality)?.label}</span>
- <ChevronDown size={13} className="chev" />
- </button>
- )}
- >
- {(close) =>
- QUALITY.map((q) => <Option key={q.value} selected={c.quality === q.value} label={q.label} sub={q.sub} onClick={() => (updateComposer({ quality: q.value }), close())} />)
- }
- </Popover>
- {canEnhance && <PromptPlus />}
+ <Popover
+ trigger={(open, toggle) => (
+ <button className={`pill ${open ? "on" : ""}`} onClick={toggle} title="Quality">
+ <Gauge size={15} />
+ <span className="lbl">{QUALITY.find((q) => q.value === c.quality)?.label}</span>
+ <ChevronDown size={13} className="chev" />
+ </button>
+ )}
+ >
+ {(close) =>
+ QUALITY.map((q) => <Option key={q.value} selected={c.quality === q.value} label={q.label} sub={q.sub} onClick={() => (updateComposer({ quality: q.value }), close())} />)
+ }
+ </Popover>
- <LoraBadge />
+ {canEnhance && <PromptPlus />}
- <Popover
- placement="top-start"
- className="panel"
- trigger={(open, toggle) => (
- <button
- className={`icon-btn has-badge ${open ? "active" : ""}`}
- onClick={toggle}
- title={overrides.length ? `Advanced: overriding the preset (${overrides.join(", ")})` : "Advanced"}
- aria-label={overrides.length ? `Advanced settings, ${overrides.length} overrides active` : "Advanced settings"}
- >
- <SlidersHorizontal size={17} />
- {overrides.length > 0 && <span className="override-dot" />}
- </button>
- )}
- >
- {() => <AdvancedPanel plan={plan} />}
- </Popover>
+ <LoraBadge />
+ <Popover
+ placement="top-start"
+ className="panel"
+ trigger={(open, toggle) => (
+ <button
+ className={`icon-btn has-badge ${open ? "active" : ""}`}
+ onClick={toggle}
+ title={overrides.length ? `Advanced: overriding the preset (${overrides.join(", ")})` : "Advanced"}
+ aria-label={overrides.length ? `Advanced settings, ${overrides.length} overrides active` : "Advanced settings"}
+ >
+ <SlidersHorizontal size={17} />
+ {overrides.length > 0 && <span className="override-dot" />}
+ </button>
+ )}
+ >
+ {() => <AdvancedPanel plan={plan} />}
+ </Popover>
- <button className="icon-btn" onClick={() => setState({ overlay: "prompt-tips" })} title="Prompt tips" aria-label="Prompt tips">
- <Lightbulb size={17} />
- </button>
- <span className="spacer" />
- <span className="plan-hint" title={hintTitle}>
- {hint}
- </span>
- {reviewing ? (
- <button className="send" title="Stop Prompt+ (your prompt stays)" aria-label="Stop Prompt+" onClick={() => cancelPromptReview()}>
- <Square size={14} strokeWidth={2.4} />
- </button>
- ) : (
- <button
- className="send"
- title={wantsPromptReview(c) ? "Write the prompt with Prompt+ (Enter)" : newImage ? "Create (Enter)" : "Apply (Enter)"}
- aria-label={wantsPromptReview(c) ? "Write the prompt" : "Generate"}
- disabled={!c.prompt.trim() && needsPrompt(c)}
- onClick={() => submitComposer()}
- >
- {wantsPromptReview(c) ? <WandSparkles size={17} strokeWidth={2.2} /> : <ArrowUp size={18} strokeWidth={2.4} />}
+ <button className="icon-btn" onClick={() => setState({ overlay: "prompt-tips" })} title="Prompt tips" aria-label="Prompt tips">
+ <Lightbulb size={17} />
</button>
- )}
- </div>
+
+ <span className="spacer" />
+ <span className="plan-hint" title={hintTitle}>
+ {hint}
+ </span>
+ {!phone && sendButton}
+ </div>
+ {/* A phone: the buttons scroll; send stays outside them, so nothing slides under it. */}
+ {phone && sendButton}
+ </div>
+ )}
</div>
</div>
);
diff --git a/src/components/Develop.tsx b/src/components/Develop.tsx
new file mode 100644
index 0000000..142b592
--- /dev/null
+++ b/src/components/Develop.tsx
@@ -0,0 +1,48 @@
+// Images that develop into view instead of popping in over the checkerboard.
+
+import { useLayoutEffect, useRef, useState } from "react";
+
+/** An `<img>` that stays hidden until it is decoded, then sharpens in out of a soft blur. Until
+ * then a blurred `placeholder` (the thumbnail the timeline has already loaded) holds its place,
+ * or a quiet sheen when there is none; it fades off as the image sharpens under it. An image
+ * already in the cache shows at once, and so does one inside a hatching result (the Hatch reveals
+ * it itself). The element stays mounted from the start, so `decode()` callers (Hatch) see it;
+ * once shown, a new `src` swaps in place (the browser keeps the old picture until the new one is
+ * ready). */
+export function DevelopImg({ src, placeholder, className = "", alt = "", lazy = false }: { src?: string; placeholder?: string; className?: string; alt?: string; lazy?: boolean }) {
+ const ref = useRef<HTMLImageElement>(null);
+ // "wait": hidden; "develop": playing the entrance; "shown": plain.
+ const [phase, setPhase] = useState<"wait" | "develop" | "shown">("wait");
+ useLayoutEffect(() => {
+ const img = ref.current;
+ if (!img) return;
+ if ((img.complete && img.naturalWidth > 0) || img.closest("[data-hatching]")) setPhase("shown");
+ }, []);
+ const ready = () => {
+ const img = ref.current;
+ if (!img || phase !== "wait") return;
+ // decode() keeps the first frame of the entrance from showing a half-painted image.
+ img.decode().catch(() => {}).then(() => setPhase((p) => (p === "wait" ? "develop" : p)));
+ };
+ return (
+ <>
+ {phase !== "shown" && (
+ <span className={`develop-ph ${phase === "develop" ? "out" : ""}`} aria-hidden>
+ {/* Faded in once complete: on a slow line it would otherwise paint from the top down. */}
+ {placeholder && <img src={placeholder} alt="" draggable={false} onLoad={(e) => e.currentTarget.classList.add("on")} />}
+ </span>
+ )}
+ <img
+ ref={ref}
+ className={`${className} ${phase === "wait" ? "develop-wait" : phase === "develop" ? "develop-in" : ""}`}
+ src={src}
+ alt={alt}
+ loading={lazy ? "lazy" : undefined}
+ draggable={false}
+ onLoad={ready}
+ onError={() => setPhase("shown")}
+ onAnimationEnd={(e) => e.target === e.currentTarget && setPhase("shown")}
+ />
+ </>
+ );
+}
diff --git a/src/components/Gallery.tsx b/src/components/Gallery.tsx
index a565a37..a351074 100644
--- a/src/components/Gallery.tsx
+++ b/src/components/Gallery.tsx
@@ -6,6 +6,7 @@ import { inBrowser, isNarrow } from "../lib/platform";
import { forgetGeneration, openGeneration, setState, toastError, useStore } from "../lib/store";
import { MODE_LABEL, neighbourAfterRemoval, previewIndex } from "../lib/logic";
import type { GenerationRecord } from "../lib/types";
+import { DevelopImg } from "./Develop";
import { IconButton, Seg } from "./ui";
import { Fullscreen, isTyping, NavArrows, navKey, useMouseActive, ZoomImage, type ViewerNav } from "./Viewer";
@@ -229,7 +230,7 @@ export function Gallery() {
}}
title={g.prompt}
>
- <img src={urls.genThumb(g.id)} alt="" loading="lazy" draggable={false} />
+ <DevelopImg src={urls.genThumb(g.id)} lazy />
{selecting && <span className="pick-mark">{picked.has(g.id) && <Check size={14} strokeWidth={3} />}</span>}
<div className={`card-actions ${g.favorite ? "fav" : ""}`} onClick={(e) => e.stopPropagation()}>
<button title={g.favorite ? "Remove from favorites" : "Favorite"} onClick={() => toggleFav(g)}>
@@ -343,7 +344,9 @@ function Preview(props: {
<span className="muted preview-pos">{nav.pos}</span>
</div>
<div className="preview-stage" onPointerMove={wake} onMouseEnter={wake}>
- <img key={g.id} className="preview-img" src={urls.gen(g.id)} alt={g.prompt} draggable={false} onDoubleClick={() => setFull(true)} />
+ <div key={g.id} className="preview-img" onDoubleClick={() => setFull(true)}>
+ <DevelopImg src={urls.gen(g.id)} placeholder={urls.genThumb(g.id)} alt={g.prompt} />
+ </div>
<NavArrows nav={nav} visible={active} />
</div>
<div className="preview-bar">
diff --git a/src/components/PhoneApp.tsx b/src/components/PhoneApp.tsx
new file mode 100644
index 0000000..172f378
--- /dev/null
+++ b/src/components/PhoneApp.tsx
@@ -0,0 +1,373 @@
+// Kokon on a phone (a browser on another device): the library of projects, and a project's screen
+// with its image, versions and prompt. Laid out for an iPhone (safe areas, large round corners,
+// sheets from the bottom); App.tsx shows it on screens up to 720 px wide (platform.ts isNarrow).
+
+import { Check, ChevronLeft, EyeOff, Plus, Settings, SquarePen, Trash2, X } from "lucide-react";
+import { useEffect, useRef, useState, type ReactNode } from "react";
+import { createPortal } from "react-dom";
+import { urls } from "../lib/api";
+import { haptic } from "../lib/haptics";
+import { timeAgo } from "../lib/logic";
+import { native } from "../lib/native";
+import { deleteProject, deleteProjects, newProject, renameProject, setState, switchProject, useStore, type ProjectMeta } from "../lib/store";
+import { Composer } from "./Composer";
+import { DevelopImg } from "./Develop";
+import { ExpandEditor } from "./ExpandEditor";
+import { Gallery } from "./Gallery";
+import { InpaintEditor } from "./InpaintEditor";
+import { ProjectTitle } from "./Sidebar";
+import { Stage } from "./Stage";
+import { StatusIndicator, togglePrivateMode } from "./TopBar";
+import { KokonMark } from "./Welcome";
+
+/** The layout follows the visible part of the screen: when the keyboard opens, the app shrinks
+ * above it (iOS keeps the page's height and slides it up instead), so the prompt and the image
+ * stay in view. `--vv-h` / `--vv-top` feed `.phone-app`; `keyboard` on <html> while it is open. */
+function useVisualViewport() {
+ useEffect(() => {
+ const vv = window.visualViewport;
+ if (!vv) return;
+ const root = document.documentElement;
+ // The keyboard is up when the visible height is well under the tallest seen in this
+ // orientation (iOS shrinks innerHeight with it, so that can't be the reference).
+ let tallest = 0;
+ const turned = () => (tallest = 0);
+ const set = () => {
+ // Pinch zoom also shrinks the visual viewport: only follow it at 100 %.
+ if (Math.abs(vv.scale - 1) > 0.01) return;
+ tallest = Math.max(tallest, vv.height);
+ root.style.setProperty("--vv-h", `${vv.height}px`);
+ root.style.setProperty("--vv-top", `${vv.offsetTop}px`);
+ root.classList.toggle("keyboard", tallest - vv.height > 150);
+ };
+ set();
+ vv.addEventListener("resize", set);
+ vv.addEventListener("scroll", set);
+ window.addEventListener("orientationchange", turned);
+ return () => {
+ vv.removeEventListener("resize", set);
+ vv.removeEventListener("scroll", set);
+ window.removeEventListener("orientationchange", turned);
+ root.style.removeProperty("--vv-h");
+ root.style.removeProperty("--vv-top");
+ root.classList.remove("keyboard");
+ };
+ }, []);
+}
+
+export function PhoneApp() {
+ const overlay = useStore((s) => s.overlay);
+ // On a phone the sidebar's place is the library, a screen of its own.
+ const library = useStore((s) => s.sidebar) || overlay === "gallery";
+ useVisualViewport();
+ return (
+ <div className="phone-app">
+ {library ? <Library /> : <ProjectScreen />}
+ {overlay === "inpaint" && <InpaintEditor />}
+ {overlay === "expand" && <ExpandEditor />}
+ </div>
+ );
+}
+
+function ProjectScreen() {
+ const overlay = useStore((s) => s.overlay);
+ const privateMode = useStore((s) => s.privateMode);
+ return (
+ <div className="phone-screen project">
+ <header className="phone-top">
+ <button className="glass-btn" title="Projects" aria-label="Projects" onClick={() => setState({ sidebar: true })}>
+ <ChevronLeft size={24} strokeWidth={2.2} />
+ </button>
+ <div className="phone-title">
+ <ProjectTitle />
+ {privateMode && (
+ <button className="private-tag" onClick={togglePrivateMode} title="Private mode is on: tap to turn it off">
+ <EyeOff size={12} /> Private
+ </button>
+ )}
+ </div>
+ <div className="phone-top-end">
+ <StatusIndicator quiet />
+ <button className="glass-btn" title="New image" aria-label="New image" onClick={newProject}>
+ <SquarePen size={19} />
+ </button>
+ </div>
+ </header>
+ <div className="main">
+ <Stage />
+ </div>
+ {overlay !== "inpaint" && overlay !== "expand" && <Composer />}
+ </div>
+ );
+}
+
+/** A sheet from the bottom of the screen, over a scrim that closes it. */
+function Sheet({ onClose, children }: { onClose: () => void; children: ReactNode }) {
+ useEffect(() => {
+ const onKey = (e: KeyboardEvent) => e.key === "Escape" && onClose();
+ window.addEventListener("keydown", onKey);
+ return () => window.removeEventListener("keydown", onKey);
+ }, [onClose]);
+ return createPortal(
+ <>
+ <div className="sheet-scrim" onClick={onClose} />
+ <div className="popover sheet" role="dialog">
+ {children}
+ </div>
+ </>,
+ document.body,
+ );
+}
+
+/** Press and hold (or a right click): `onHold`; the click that ends a hold is swallowed. */
+function useLongPress(onHold: () => void) {
+ const timer = useRef<number | undefined>(undefined);
+ const start = useRef<{ x: number; y: number } | null>(null);
+ const held = useRef(false);
+ const cancel = () => {
+ window.clearTimeout(timer.current);
+ start.current = null;
+ };
+ return {
+ onTouchStart: (e: React.TouchEvent) => {
+ held.current = false;
+ start.current = { x: e.touches[0].clientX, y: e.touches[0].clientY };
+ timer.current = window.setTimeout(() => {
+ held.current = true;
+ onHold();
+ }, 460);
+ },
+ onTouchMove: (e: React.TouchEvent) => {
+ const s = start.current;
+ if (s && Math.hypot(e.touches[0].clientX - s.x, e.touches[0].clientY - s.y) > 8) cancel();
+ },
+ onTouchEnd: (e: React.TouchEvent) => {
+ cancel();
+ // The finger lifting after a hold would click whatever opened under it (the sheet's scrim).
+ if (held.current) {
+ e.preventDefault();
+ // Here, not when the hold fires: iOS plays it only inside a touch's own handler.
+ haptic();
+ }
+ },
+ onTouchCancel: cancel,
+ onContextMenu: (e: React.MouseEvent) => {
+ e.preventDefault();
+ if (!held.current) onHold();
+ },
+ onClickCapture: (e: React.MouseEvent) => {
+ if (!held.current) return;
+ held.current = false;
+ e.stopPropagation();
+ e.preventDefault();
+ },
+ };
+}
+
+/** The phone's home: the projects (or every image), private mode and Settings. */
+function Library() {
+ const projects = useStore((s) => s.projects);
+ const current = useStore((s) => s.projectId);
+ const privateMode = useStore((s) => s.privateMode);
+ const overlay = useStore((s) => s.overlay);
+ const images = overlay === "gallery";
+ const [picked, setPicked] = useState<Set<string> | null>(null);
+ const [menu, setMenu] = useState<ProjectMeta | null>(null);
+ const selecting = picked !== null;
+
+ // "Open in project" in All images leaves the gallery: the library closes onto that project.
+ const switchingTab = useRef(false);
+ const wasImages = useRef(images);
+ useEffect(() => {
+ if (wasImages.current && !images && !switchingTab.current) setState({ sidebar: false });
+ switchingTab.current = false;
+ wasImages.current = images;
+ }, [images]);
+
+ const showTab = (img: boolean) => {
+ if (img === images) return;
+ haptic();
+ switchingTab.current = true;
+ setPicked(null);
+ setState({ overlay: img ? "gallery" : null, sidebar: true });
+ };
+ const open = (id: string) => {
+ switchProject(id);
+ setState({ sidebar: false });
+ };
+ const toggle = (id: string) => {
+ const next = new Set(picked ?? []);
+ if (next.has(id)) next.delete(id);
+ else next.add(id);
+ setPicked(next);
+ };
+ const removePicked = async () => {
+ if (!picked?.size) return;
+ const n = picked.size;
+ if (!(await native.confirm(`Remove ${n} ${n === 1 ? "project" : "projects"} from the list? Their images stay in All images.`, "Remove projects"))) return;
+ deleteProjects([...picked]);
+ setPicked(null);
+ };
+
+ return (
+ <div className={`phone-screen library ${images ? "images" : ""}`}>
+ <header className="lib-head">
+ <div className="lib-title-row">
+ <h1>
+ <KokonMark size={22} />
+ Kokon
+ </h1>
+ {!images && projects.length > 0 && (
+ <button className="lib-text-btn" onClick={() => setPicked(selecting ? null : new Set())}>
+ {selecting ? "Done" : "Select"}
+ </button>
+ )}
+ <button className={`glass-btn ${privateMode ? "on" : ""}`} title={privateMode ? "Private mode is on: tap to turn it off" : "Private mode: nothing is saved"} aria-label="Private mode" aria-pressed={privateMode} onClick={togglePrivateMode}>
+ <EyeOff size={19} />
+ </button>
+ <button className="glass-btn" title="Settings" aria-label="Settings" onClick={() => setState({ overlay: "settings" })}>
+ <Settings size={19} />
+ </button>
+ </div>
+ <div className="seg lib-seg" role="tablist">
+ <button role="tab" aria-selected={!images} className={images ? "" : "on"} onClick={() => showTab(false)}>
+ Projects
+ </button>
+ <button role="tab" aria-selected={images} className={images ? "on" : ""} onClick={() => showTab(true)}>
+ All images
+ </button>
+ </div>
+ </header>
+ <div className="lib-body">
+ {images ? (
+ <Gallery />
+ ) : (
+ <div className="lib-scroll">
+ {privateMode && (
+ <div className="lib-private">
+ <EyeOff size={18} />
+ <span>
+ <strong>Private mode is on</strong>
+ Images are not saved, and are deleted when you turn it off.
+ </span>
+ <button className="lib-text-btn" onClick={togglePrivateMode}>
+ Turn off
+ </button>
+ </div>
+ )}
+ {projects.length === 0 ? (
+ <div className="lib-empty">
+ <strong>No projects yet</strong>
+ <span>Each image you make or bring in starts one; its versions stay together.</span>
+ </div>
+ ) : (
+ <div className="lib-grid">
+ {projects.map((p) => (
+ <ProjectCard
+ key={p.id}
+ p={p}
+ current={p.id === current && !selecting}
+ picked={selecting ? picked.has(p.id) : null}
+ onOpen={() => (selecting ? toggle(p.id) : open(p.id))}
+ onHold={() => (selecting ? toggle(p.id) : setMenu(p))}
+ />
+ ))}
+ </div>
+ )}
+ </div>
+ )}
+ </div>
+ {!images &&
+ (selecting ? (
+ <div className="lib-dock select">
+ <span className="select-count">{picked.size ? `${picked.size} selected` : "Tap projects to select"}</span>
+ <button className="btn danger" disabled={!picked.size} onClick={removePicked}>
+ <Trash2 size={15} /> Remove
+ </button>
+ </div>
+ ) : (
+ <div className="lib-dock">
+ <button
+ className="lib-new"
+ onClick={() => {
+ newProject();
+ setState({ sidebar: false });
+ }}
+ >
+ <Plus size={20} strokeWidth={2.4} /> New image
+ </button>
+ </div>
+ ))}
+ {menu && <ProjectSheet p={menu} onOpen={() => (setMenu(null), open(menu.id))} onClose={() => setMenu(null)} />}
+ </div>
+ );
+}
+
+function ProjectCard({ p, current, picked, onOpen, onHold }: { p: ProjectMeta; current: boolean; picked: boolean | null; onOpen: () => void; onHold: () => void }) {
+ const press = useLongPress(onHold);
+ return (
+ <button className={`lib-card ${current ? "current" : ""} ${picked ? "picked" : ""}`} onClick={onOpen} {...press} aria-pressed={picked ?? undefined}>
+ <span className="lib-cover">
+ {p.cover && <DevelopImg src={urls.sourceThumb(p.cover)} lazy />}
+ {picked !== null && <span className="pick-mark">{picked && <Check size={14} strokeWidth={3} />}</span>}
+ </span>
+ <span className="lib-card-title">{p.title}</span>
+ <span className="lib-card-sub">
+ {p.count} {p.count === 1 ? "image" : "images"} · {timeAgo(p.updatedAt)}
+ </span>
+ </button>
+ );
+}
+
+/** A project held down: its name (edit it in place), open, remove. */
+function ProjectSheet({ p, onOpen, onClose }: { p: ProjectMeta; onOpen: () => void; onClose: () => void }) {
+ const [name, setName] = useState(p.title);
+ const save = () => {
+ if (name.trim() && name.trim() !== p.title) renameProject(p.id, name);
+ };
+ return (
+ <Sheet
+ onClose={() => {
+ save();
+ onClose();
+ }}
+ >
+ <div className="sheet-head">
+ <span className="sheet-cover">{p.cover && <img src={urls.sourceThumb(p.cover)} alt="" draggable={false} />}</span>
+ <label className="sheet-name">
+ <span>Name</span>
+ <input
+ className="input"
+ value={name}
+ maxLength={120}
+ autoComplete="off"
+ spellCheck={false}
+ enterKeyHint="done"
+ onChange={(e) => setName(e.target.value)}
+ onBlur={save}
+ onKeyDown={(e) => e.key === "Enter" && (e.currentTarget as HTMLInputElement).blur()}
+ />
+ </label>
+ </div>
+ <button className="opt" onClick={onOpen}>
+ <span className="check">
+ <ChevronLeft size={17} style={{ transform: "scaleX(-1)" }} />
+ </span>
+ <span>Open</span>
+ </button>
+ <button
+ className="opt danger"
+ onClick={() => {
+ onClose();
+ deleteProject(p.id);
+ }}
+ >
+ <span className="check">
+ <X size={17} />
+ </span>
+ <span>Remove from list</span>
+ <span className="sub">Images stay in All images</span>
+ </button>
+ </Sheet>
+ );
+}
diff --git a/src/components/PhoneStage.tsx b/src/components/PhoneStage.tsx
new file mode 100644
index 0000000..db80138
--- /dev/null
+++ b/src/components/PhoneStage.tsx
@@ -0,0 +1,352 @@
+// The stage on a phone (Kokon in a browser on another device): the image is swiped between
+// versions and tapped for full screen, and what you can do with it sits in one row under it.
+// Stage.tsx uses these in place of its desktop bar.
+
+import { Brush, Copy, Download, Ellipsis, Expand, Heart, ImagePlus, Info, RefreshCw, SlidersHorizontal, TextCursorInput, Trash2, X } from "lucide-react";
+import { useEffect, useRef, useState, type ReactNode } from "react";
+import { createPortal } from "react-dom";
+import { api, urls } from "../lib/api";
+import { haptic } from "../lib/haptics";
+import { composerFromRecord, variationRequest } from "../lib/logic";
+import { canCopyImage, native } from "../lib/native";
+import {
+ editShownImage, getState, itemSource, removeSessionItem, reusePrompt, selectItem, setState, submitRequest, toastError, toastInfo, updateComposer, useStore, type SessionItem,
+} from "../lib/store";
+import type { GenerationRecord, LutEntry } from "../lib/types";
+import { promptClosedAt, uploadFiles } from "./Composer";
+import { DevelopImg } from "./Develop";
+import { LutButton } from "./Lut";
+import { ActionButton, InfoPanel, sourceSize, UpscaleButton } from "./Stage";
+import { Popover } from "./ui";
+import { KokonMark } from "./Welcome";
+
+/** Short prompts that show what a good one looks like (subject, action, place). */
+const IDEAS = [
+ "A red fox curled up asleep in fresh snow at sunrise",
+ "A cosy reading nook by a rainy window, warm lamp light",
+ "A monkey dribbling a basketball on an outdoor court",
+];
+
+/** A new project: start from a photo, or from words (an idea fills the prompt). */
+export function PhoneEmpty() {
+ const pick = async () => uploadFiles(await native.pickImageFiles());
+ const idea = (p: string) => {
+ updateComposer({ prompt: p });
+ // Focused in the tap itself: iOS shows the keyboard only then.
+ document.getElementById("prompt")?.focus();
+ };
+ return (
+ <div className="phone-empty">
+ <KokonMark size={34} />
+ <h1>What should we make?</h1>
+ <p>Describe a new image below, or start from a photo.</p>
+ <button className="phone-photo" onClick={pick}>
+ <span className="phone-photo-icon">
+ <ImagePlus size={22} />
+ </span>
+ <span className="phone-photo-text">
+ <strong>Edit a photo</strong>
+ <span>From your photos or the camera</span>
+ </span>
+ </button>
+ <div className="ideas">
+ <span className="ideas-label">Or try</span>
+ {IDEAS.map((p) => (
+ <button key={p} className="idea" onClick={() => idea(p)}>
+ {p}
+ </button>
+ ))}
+ </div>
+ </div>
+ );
+}
+
+/** Swipe sideways to the previous or next version; a tap on the picture opens full screen.
+ * Gestures that start on a control (buttons, the comparison slider) are left to it. */
+export function Swipe({ children, onTap }: { children: ReactNode; onTap?: () => void }) {
+ const session = useStore((s) => s.session);
+ const selected = useStore((s) => s.selected);
+ const ref = useRef<HTMLDivElement>(null);
+ const touch = useRef<{ x: number; y: number; t: number; dx: number; axis: "x" | "y" | null; skip: boolean; onImage: boolean } | null>(null);
+ // The version just swiped to slides in from that side.
+ const [enter, setEnter] = useState<{ key: string; from: "left" | "right" } | null>(null);
+ const at = session.findIndex((i) => i.key === selected);
+ const prev = at > 0 ? session[at - 1] : undefined;
+ const next = at >= 0 ? session[at + 1] : undefined;
+
+ const place = (dx: number, animate: boolean) => {
+ const el = ref.current;
+ if (!el) return;
+ el.style.transition = animate ? "transform 0.38s var(--ease), opacity 0.38s var(--ease)" : "none";
+ el.style.transform = dx ? `translateX(${dx}px)` : "";
+ el.style.opacity = dx ? String(1 - Math.min(0.5, Math.abs(dx) / 600)) : "";
+ };
+
+ return (
+ <div
+ className="swipe"
+ onTouchStart={(e) => {
+ const t = e.target as HTMLElement;
+ if (e.touches.length !== 1) {
+ touch.current = null;
+ return;
+ }
+ const p = e.touches[0];
+ touch.current = {
+ x: p.clientX,
+ y: p.clientY,
+ t: performance.now(),
+ dx: 0,
+ axis: null,
+ skip: !!t.closest("button, input, .compare-overlay, .compare-box.slider, .prompt-text"),
+ onImage: !!t.closest(".image-box, .compare-box"),
+ };
+ }}
+ onTouchMove={(e) => {
+ const s = touch.current;
+ if (!s || s.skip) return;
+ const p = e.touches[0];
+ const dx = p.clientX - s.x;
+ const dy = p.clientY - s.y;
+ if (!s.axis && Math.hypot(dx, dy) > 8) s.axis = Math.abs(dx) > Math.abs(dy) ? "x" : "y";
+ if (s.axis !== "x") return;
+ s.dx = dx;
+ // Past the first or last version the picture follows the finger only a little.
+ const end = (dx > 0 && !prev) || (dx < 0 && !next);
+ place(end ? dx * 0.22 : dx, false);
+ }}
+ onTouchEnd={() => {
+ const s = touch.current;
+ touch.current = null;
+ if (!s || s.skip) return;
+ const dt = performance.now() - s.t;
+ // This touch closed the open prompt box: it does nothing else.
+ if (promptClosedAt >= s.t - 50) return place(0, true);
+ if (s.axis === "x") {
+ const fast = Math.abs(s.dx) / Math.max(1, dt) > 0.45;
+ const go = Math.abs(s.dx) > 64 || fast ? (s.dx < 0 ? next : prev) : undefined;
+ if (!go) return place(0, true);
+ haptic();
+ const el = ref.current;
+ if (el) {
+ el.style.transition = "transform 0.16s ease-in, opacity 0.16s ease-in";
+ el.style.transform = `translateX(${s.dx < 0 ? -90 : 90}px)`;
+ el.style.opacity = "0";
+ }
+ window.setTimeout(() => {
+ setEnter({ key: go.key, from: s.dx < 0 ? "right" : "left" });
+ selectItem(go.key);
+ place(0, false);
+ }, 140);
+ } else if (!s.axis && dt < 320 && s.onImage) onTap?.();
+ }}
+ onTouchCancel={() => {
+ touch.current = null;
+ place(0, true);
+ }}
+ >
+ <div ref={ref} className="swipe-track">
+ <div key={selected ?? ""} className={`swipe-page ${enter && enter.key === selected ? `enter-${enter.from}` : ""}`}>
+ {children}
+ </div>
+ </div>
+ </div>
+ );
+}
+
+/** An iPhone or iPad (an iPad's Safari says "Macintosh" but has a touch screen). */
+const isIOS = typeof navigator !== "undefined" && (/iP(hone|ad|od)/.test(navigator.userAgent) || (/Mac/.test(navigator.userAgent) && navigator.maxTouchPoints > 1));
+
+/** Saves onto the phone: the share sheet (Save Image puts it in Photos) where the browser can
+ * share files, which needs HTTPS. Otherwise an iPhone shows the image to hold (`hold`): a download
+ * there opens a file preview, a dead end in a home-screen app, with nothing to go back with; other
+ * devices download it. */
+async function saveImage(url: string, name: string, hold: () => void) {
+ try {
+ if (navigator.canShare) {
+ const blob = await (await fetch(url)).blob();
+ const file = new File([blob], name, { type: blob.type || "image/png" });
+ if (navigator.canShare({ files: [file] })) {
+ await navigator.share({ files: [file] });
+ return;
+ }
+ }
+ } catch (e) {
+ if ((e as DOMException)?.name === "AbortError") return;
+ }
+ if (isIOS) hold();
+ else native.download(url, name);
+}
+
+/** The image to save, full screen and at full size: holding it brings the system's menu, whose
+ * Save to Photos puts it in Photos. */
+function HoldToSave({ src, thumb, onClose }: { src: string; thumb?: string; onClose: () => void }) {
+ useEffect(() => {
+ const onKey = (e: KeyboardEvent) => e.key === "Escape" && onClose();
+ window.addEventListener("keydown", onKey);
+ return () => window.removeEventListener("keydown", onKey);
+ }, [onClose]);
+ return createPortal(
+ <div className="hold-save" role="dialog" aria-label="Save the image">
+ <div className="hold-save-head">
+ <span>
+ Press and hold the picture, then tap <strong>Save to Photos</strong>.
+ </span>
+ <button className="glass-btn" title="Done" aria-label="Done" onClick={onClose}>
+ <X size={20} />
+ </button>
+ </div>
+ <div className="hold-save-img">
+ <DevelopImg src={src} placeholder={thumb} alt="Image to save" />
+ </div>
+ </div>,
+ document.body,
+ );
+}
+
+/** What you can do with the version shown, in one row that scrolls sideways under the image. */
+export function PhoneActions({ item, showOriginal, onLut }: { item: SessionItem; showOriginal: boolean; onLut: (lut: LutEntry) => void }) {
+ const g = item.gen;
+ const source = itemSource(item)!;
+ const [fav, setFav] = useState(!!g?.favorite);
+ const [hold, setHold] = useState<{ src: string; thumb: string } | null>(null);
+ const paint = (overlay: "inpaint" | "expand") => {
+ editShownImage();
+ setState({ overlay });
+ };
+ const save = () => {
+ const thumb = urls.sourceThumb(source);
+ if (g) {
+ const name = g.file_path.split(/[\\/]/).pop() ?? "image.png";
+ const src = showOriginal ? urls.genOriginal(g.id) : urls.gen(g.id);
+ saveImage(src, showOriginal ? name.replace(/(\.\w+)?$/, "-original.png") : name, () => setHold({ src, thumb }));
+ } else {
+ const src = urls.input(item.input!.id);
+ saveImage(src, item.input!.original_name ? decodeURIComponent(item.input!.original_name) : "image.png", () => setHold({ src, thumb }));
+ }
+ };
+ return (
+ <div className="actions phone-actions">
+ {g?.request && g.mode !== "upscale" && g.mode !== "lut" && (
+ <ActionButton
+ title="Again: same prompt and settings, new seed"
+ icon={<RefreshCw size={17} />}
+ label="Again"
+ onClick={() => {
+ const r = variationRequest(g);
+ if (r) submitRequest(r);
+ }}
+ />
+ )}
+ <ActionButton title="Paint the area to change" icon={<Brush size={17} />} label="Paint" onClick={() => paint("inpaint")} />
+ <ActionButton title="Extend the image beyond its borders" icon={<Expand size={17} />} label="Expand" onClick={() => paint("expand")} />
+ <UpscaleButton source={source} size={g ? { width: g.width, height: g.height } : { width: item.input!.width, height: item.input!.height }} original={g ? sourceSize(g) : null} parentId={g?.id} />
+ <LutButton onPick={onLut} />
+ {g && (
+ <ActionButton
+ title={fav ? "Remove from favorites" : "Favorite"}
+ icon={<Heart size={17} fill={fav ? "currentColor" : "none"} />}
+ label="Favorite"
+ active={fav}
+ onClick={async () => {
+ try {
+ await api.setFavorite(g.id, !fav);
+ setFav(!fav);
+ } catch (e) {
+ toastError(e);
+ }
+ }}
+ />
+ )}
+ <ActionButton title="Save to this device" icon={<Download size={17} />} label="Save" onClick={save} />
+ <PhoneMore item={item} g={g} showOriginal={showOriginal} />
+ {hold && <HoldToSave src={hold.src} thumb={hold.thumb} onClose={() => setHold(null)} />}
+ </div>
+ );
+}
+
+/** The rest, in a sheet: reuse the prompt, copy, details, remove. */
+function PhoneMore({ item, g, showOriginal }: { item: SessionItem; g?: GenerationRecord; showOriginal: boolean }) {
+ const [info, setInfo] = useState(false);
+ return (
+ <Popover
+ className={info ? "info-sheet" : undefined}
+ trigger={(open, toggle) => (
+ <ActionButton
+ title="More"
+ icon={<Ellipsis size={17} />}
+ label="More"
+ active={open}
+ onClick={() => {
+ setInfo(false);
+ toggle();
+ }}
+ />
+ )}
+ >
+ {(close) =>
+ info && g ? (
+ <InfoPanel g={g} />
+ ) : (
+ <>
+ {g?.prompt && (
+ <button className="opt" onClick={() => (close(), reusePrompt(g))}>
+ <span className="check">
+ <TextCursorInput size={17} />
+ </span>
+ <span>Reuse prompt</span>
+ </button>
+ )}
+ {g && g.mode !== "lut" && (
+ <button
+ className="opt"
+ onClick={() => {
+ close();
+ setState({ composer: { ...composerFromRecord(g, getState().composer), mode: "auto" } });
+ }}
+ >
+ <span className="check">
+ <SlidersHorizontal size={17} />
+ </span>
+ <span>Reuse prompt and settings</span>
+ </button>
+ )}
+ {canCopyImage && (
+ <button
+ className="opt"
+ onClick={async () => {
+ close();
+ try {
+ await native.copyImageUrl(g ? (showOriginal ? urls.genOriginal(g.id) : urls.gen(g.id)) : urls.input(item.input!.id));
+ toastInfo("Image copied");
+ } catch (e) {
+ toastError(e);
+ }
+ }}
+ >
+ <span className="check">
+ <Copy size={17} />
+ </span>
+ <span>Copy image</span>
+ </button>
+ )}
+ {g && (
+ <button className="opt" onClick={() => setInfo(true)}>
+ <span className="check">
+ <Info size={17} />
+ </span>
+ <span>Details</span>
+ </button>
+ )}
+ <button className="opt danger" onClick={() => (close(), removeSessionItem(item.key))}>
+ <span className="check">
+ <Trash2 size={17} />
+ </span>
+ <span>Remove from project</span>
+ </button>
+ </>
+ )
+ }
+ </Popover>
+ );
+}
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx
index 511e598..62cbd78 100644
--- a/src/components/Sidebar.tsx
+++ b/src/components/Sidebar.tsx
@@ -1,11 +1,9 @@
-import { Check, EyeOff, Images, PanelLeftClose, Pencil, Settings, SquarePen, Trash2, X } from "lucide-react";
+import { Check, Images, PanelLeftClose, Pencil, Settings, SquarePen, Trash2, X } from "lucide-react";
import { useEffect, useState } from "react";
import { urls } from "../lib/api";
import { timeAgo } from "../lib/logic";
import { native } from "../lib/native";
-import { isNarrow, useNarrow } from "../lib/platform";
import { deleteProject, deleteProjects, newProject, renameProject, setState, switchProject, useStore } from "../lib/store";
-import { togglePrivateMode } from "./TopBar";
import { IconButton, NameField } from "./ui";
import { KokonMark } from "./Welcome";
@@ -27,9 +25,6 @@ export function Sidebar() {
const empty = useStore((s) => s.session.length === 0);
const overlay = useStore((s) => s.overlay);
const gallery = overlay === "gallery";
- const privateMode = useStore((s) => s.privateMode);
- // On a phone the menu covers the screen.
- const narrow = useNarrow();
const [renaming, setRenaming] = useState<string | null>(null);
// Selection: null = off; otherwise the picked project ids (and the last one clicked, for Shift).
const [picked, setPicked] = useState<Set<string> | null>(null);
@@ -75,18 +70,11 @@ export function Sidebar() {
};
return (
- <aside
- className={`sidebar ${selecting ? "selecting" : ""}`}
- // On a phone the drawer closes once you pick where to go.
- onClick={(e) => {
- const t = e.target as HTMLElement;
- if (isNarrow() && !selecting && t.closest(".side-item, .proj") && !t.closest(".proj-rm, .name-field")) setState({ sidebar: false });
- }}
- >
+ <aside className={`sidebar ${selecting ? "selecting" : ""}`}>
<div className="side-head" data-tauri-drag-region>
<Wordmark />
- <IconButton title={narrow ? "Close menu" : "Hide sidebar"} onClick={() => setState({ sidebar: false })}>
- {narrow ? <X size={22} /> : <PanelLeftClose size={18} />}
+ <IconButton title="Hide sidebar" onClick={() => setState({ sidebar: false })}>
+ <PanelLeftClose size={18} />
</IconButton>
</div>
<nav className="side-nav">
@@ -96,12 +84,6 @@ export function Sidebar() {
<button className={`side-item ${gallery ? "on" : ""}`} onClick={() => setState({ overlay: gallery ? null : "gallery" })}>
<Images size={16} /> All images
</button>
- {/* On a phone the top bar has no room for it. */}
- {narrow && (
- <button className="side-item" onClick={togglePrivateMode}>
- <EyeOff size={16} /> Private mode<span className="side-state">{privateMode ? "On" : "Off"}</span>
- </button>
- )}
</nav>
{projects.length > 0 && (
<div className="side-label">
diff --git a/src/components/Stage.tsx b/src/components/Stage.tsx
index e3547ed..7938c56 100644
--- a/src/components/Stage.tsx
+++ b/src/components/Stage.tsx
@@ -15,10 +15,12 @@ import type { GenerationRecord, GenerationRequest, JobView, LutEntry, Mode, Size
import { Cocoon, Hatch } from "./Cocoon";
import { CompareFrame, CompareFullscreen } from "./Compare";
import { PROMPT_FADE_MS, usePromptLeave, useTypewriter, useJobPercent, wordStyle } from "./jobMotion";
+import { DevelopImg } from "./Develop";
import { LutBar, LutButton, LutOverlay } from "./Lut";
import { IconButton, Popover, useFit } from "./ui";
import { Fullscreen, FullscreenButton, isTyping, ZoomImage, type ViewerNav } from "./Viewer";
-import { fileManager, inBrowser, shortcut } from "../lib/platform";
+import { fileManager, inBrowser, shortcut, useNarrow } from "../lib/platform";
+import { PhoneActions, PhoneEmpty, Swipe } from "./PhoneStage";
export const MODE_ICON: Record<Mode | "lut", React.ReactNode> = {
auto: <Wand2 size={11} />,
@@ -227,7 +229,7 @@ function Failed({ job, item }: { job: JobView; item: SessionItem }) {
);
}
-function InfoPanel({ g }: { g: GenerationRecord }) {
+export function InfoPanel({ g }: { g: GenerationRecord }) {
const pipeline = pipelineSummary(g);
const lut = lutInfo(g);
const rows: [string, string][] = lut ? [
@@ -320,7 +322,7 @@ function UpscaleMenu(props: { source: string; size: Size; original?: Size | null
}
/** A main action under the image: icon and word (the word hides when the stage is narrow). */
-function ActionButton(props: { title: string; icon: React.ReactNode; label: string; onClick: () => void; active?: boolean }) {
+export function ActionButton(props: { title: string; icon: React.ReactNode; label: string; onClick: () => void; active?: boolean }) {
return (
<button className={`act ${props.active ? "active" : ""}`} title={props.title} aria-label={props.label} onClick={props.onClick}>
{props.icon}
@@ -329,7 +331,7 @@ function ActionButton(props: { title: string; icon: React.ReactNode; label: stri
);
}
-function UpscaleButton(props: { source: string; size: Size; original?: Size | null; parentId?: string | null }) {
+export function UpscaleButton(props: { source: string; size: Size; original?: Size | null; parentId?: string | null }) {
return (
<Popover
placement="top-end"
@@ -389,10 +391,15 @@ function MoreMenu({ item, path }: { item: SessionItem; path: string | null }) {
);
}
+/** The size of the image an edit was made from (the upscale menu offers it back), or null. */
+export function sourceSize(g: GenerationRecord): Size | null {
+ return g.references[0] && g.mode !== "generate" && g.mode !== "compose" && g.mode !== "upscale" && g.mode !== "lut" ? { width: g.references[0].width, height: g.references[0].height } : null;
+}
+
function GenActions({ item, g, showOriginal, onLut }: { item: SessionItem; g: GenerationRecord; showOriginal: boolean; onLut: (lut: LutEntry) => void }) {
// Save, copy and "show in folder" act on the image on screen: the result or its pre-upscale original.
const shownPath = (showOriginal && g.pipeline?.original_path) || g.file_path;
- const original = g.references[0] && g.mode !== "generate" && g.mode !== "compose" && g.mode !== "upscale" && g.mode !== "lut" ? { width: g.references[0].width, height: g.references[0].height } : null;
+ const original = sourceSize(g);
const [fav, setFav] = useState(g.favorite);
return (
<div className="actions">
@@ -509,7 +516,7 @@ function PlainFrame({ src, source, alt, w, h, maskSrc, overlay, fill, onFullscre
return (
<div className="stage-frame" ref={ref}>
<div className="image-box" style={{ width: bw, height: bw * (h / w) }}>
- <img className="stage-img fill" src={img} alt={alt} draggable={false} />
+ <DevelopImg className="stage-img fill" src={img} placeholder={source ? urls.sourceThumb(source) : undefined} alt={alt} />
{maskSrc && <img className="stage-mask" src={maskSrc} alt="" draggable={false} />}
{overlay}
<FullscreenButton onOpen={onFullscreen} />
@@ -519,7 +526,8 @@ function PlainFrame({ src, source, alt, w, h, maskSrc, overlay, fill, onFullscre
}
/** Under the image: which image this is and what made it, then what you can do with it. */
-function StageBar(props: { item: SessionItem; label: string; showOriginal: boolean; setShowOriginal: (on: boolean) => void; lutBar: React.ReactNode; onLut: (lut: LutEntry) => void }) {
+/** `phone`: the prompt stays in Details, the actions are the phone's row. */
+function StageBar(props: { item: SessionItem; label: string; showOriginal: boolean; setShowOriginal: (on: boolean) => void; lutBar: React.ReactNode; onLut: (lut: LutEntry) => void; phone?: boolean }) {
const { item, label, showOriginal, setShowOriginal } = props;
const g = item.gen;
const lut = g && lutInfo(g);
@@ -537,16 +545,18 @@ function StageBar(props: { item: SessionItem; label: string; showOriginal: boole
<WandSparkles size={13} />
</span>
)}
+ {!props.phone && (
<span className="stage-prompt" title={g?.original_prompt ? `${g.prompt}\n\nYour prompt: ${g.original_prompt}` : g?.prompt ?? name}>
{g ? g.original_prompt || g.prompt || (g.mode === "upscale" ? `${g.references[0]?.width ?? "?"}×${g.references[0]?.height ?? "?"} → ${w}×${h}` : lut ? `${lutLabel(lut)} · ${Math.round(lut.intensity * 100)} %` : "") : name}
</span>
+ )}
{from && !props.lutBar ? (
<span className="seg dims-seg" role="radiogroup" aria-label="Which image to show">
<button className={showOriginal ? "" : "on"} role="radio" aria-checked={!showOriginal} onClick={() => setShowOriginal(false)} title={`The result, enlarged by ${upscalerLabel(g!.pipeline!.enlarged_with)}`}>
- Upscaled {w}×{h}
+ Upscaled<span className="seg-dims"> {w}×{h}</span>
</button>
<button className={showOriginal ? "on" : ""} role="radio" aria-checked={showOriginal} onClick={() => setShowOriginal(true)} title="What the model made, before the upscaler enlarged it">
- Original {from.width}×{from.height}
+ Original<span className="seg-dims"> {from.width}×{from.height}</span>
</button>
</span>
) : (
@@ -555,7 +565,14 @@ function StageBar(props: { item: SessionItem; label: string; showOriginal: boole
</span>
)}
</div>
- {props.lutBar ?? (g ? <GenActions key={`actions-${g.id}`} item={item} g={g} showOriginal={showOriginal} onLut={props.onLut} /> : <InputActions item={item} onLut={props.onLut} />)}
+ {props.lutBar ??
+ (props.phone ? (
+ <PhoneActions key={`actions-${item.key}`} item={item} showOriginal={showOriginal} onLut={props.onLut} />
+ ) : g ? (
+ <GenActions key={`actions-${g.id}`} item={item} g={g} showOriginal={showOriginal} onLut={props.onLut} />
+ ) : (
+ <InputActions item={item} onLut={props.onLut} />
+ ))}
</div>
);
}
@@ -713,7 +730,8 @@ function Timeline({ labels }: { labels: Record<string, string> }) {
else selectItem(it.key);
}}
onPointerDown={(e) => {
- if (e.button === 0 && src) drag.current = { key: it.key, src, x0: e.clientX, y0: e.clientY, moved: false };
+ // A finger scrolls the timeline; dragging onto the prompt is for a mouse.
+ if (e.button === 0 && src && e.pointerType !== "touch") drag.current = { key: it.key, src, x0: e.clientX, y0: e.clientY, moved: false };
}}
onPointerMove={(e) => {
const d = drag.current;
@@ -742,7 +760,7 @@ function Timeline({ labels }: { labels: Record<string, string> }) {
>
<span className="frame-box">
<span className="frame-img">
- {src && <img src={urls.sourceThumb(src)} alt="" draggable={false} />}
+ {src && <DevelopImg src={urls.sourceThumb(src)} />}
{pendingSrc && <img className="dim" src={urls.sourceThumb(pendingSrc)} alt="" draggable={false} />}
{pending && !failed && job && job.status !== "queued" && <JobPercent job={job} request={it.request} />}
{failed && (
@@ -833,6 +851,8 @@ let lastIntensity = 1;
export function Stage() {
const item = useStore(selectedItem);
const session = useStore((s) => s.session);
+ // A phone: swipe between versions, a row of actions and a filmstrip (PhoneStage.tsx).
+ const phone = useNarrow();
const job = useStore((s) => (item?.jobId ? s.jobs[item.jobId] : undefined));
const labels = useMemo(() => sessionLabels(session), [session]);
// The result whose pre-upscale original is on screen instead of it.
@@ -895,14 +915,16 @@ export function Stage() {
if (!item) {
return (
- <div className="stage">
- <Empty />
+ <div className={`stage ${phone ? "phone-stage" : ""}`}>
+ {phone ? <PhoneEmpty /> : <Empty />}
<Timeline labels={labels} />
</div>
);
}
+ // The picture (or the job's card), and under it the bar with what to do with it.
let view: React.ReactNode;
+ let bar: React.ReactNode = null;
if (item.kind === "job") {
view = !job ? (
<div className="stage-frame">
@@ -952,7 +974,6 @@ export function Stage() {
/>
);
view = (
- <>
<Hatch key={item.key} id={g?.id} aspect={w / h}>
{lutActive ? (
<PlainFrame
@@ -972,14 +993,15 @@ export function Stage() {
<PlainFrame key={src} source={source} alt={item.gen?.prompt ?? item.input?.original_name ?? ""} w={w} h={h} maskSrc={maskSrc} fill={!!item.gen} onFullscreen={openFull} />
)}
</Hatch>
- <StageBar item={item} label={labels[item.key]} showOriginal={showOriginal} setShowOriginal={(on) => setOriginalOf(on && g ? g.id : null)} lutBar={lutBar} onLut={startLut} />
- </>
);
+ bar = <StageBar item={item} label={labels[item.key]} showOriginal={showOriginal} setShowOriginal={(on) => setOriginalOf(on && g ? g.id : null)} lutBar={lutBar} onLut={startLut} phone={phone} />;
}
return (
- <div className="stage">
- {view}
+ <div className={`stage ${phone ? "phone-stage" : ""}`}>
+ {phone ? <Swipe onTap={canFull && !lutActive ? openFull : undefined}>{view}</Swipe> : view}
+ {/* A phone keeps the bar's room even without one (a job), so the timeline never moves. */}
+ {phone ? <div className="phone-bar">{bar}</div> : bar}
<Timeline labels={labels} />
{fullscreen}
</div>
diff --git a/src/components/TopBar.tsx b/src/components/TopBar.tsx
index 3522286..c473b72 100644
--- a/src/components/TopBar.tsx
+++ b/src/components/TopBar.tsx
@@ -1,10 +1,11 @@
// The top bar: the project's title, then undo/redo, the update pill, the status capsule,
// private mode, shortcuts and (only while the sidebar is hidden) Settings, then the window's
// buttons. Its own file so the launch video (marketing/video) shows the same bar.
-import { ArrowDownToLine, CircleHelp, EyeOff, Menu, PanelLeft, Redo2, Settings, SquarePen, Undo2 } from "lucide-react";
+import { ArrowDownToLine, CircleHelp, EyeOff, PanelLeft, Redo2, Settings, SquarePen, Undo2 } from "lucide-react";
import { api } from "../lib/api";
import { native } from "../lib/native";
-import { shortcut, useNarrow } from "../lib/platform";
+import { haptic } from "../lib/haptics";
+import { isNarrow, shortcut } from "../lib/platform";
import { getState, isMissingModel, newProject, openModelSetup, redoVersion, refreshStatus, setPrivateMode, setState, toastError, undoKey, undoVersion, useStore } from "../lib/store";
import { installUpdate } from "../lib/updates";
import { SilkSpin } from "./Cocoon";
@@ -13,7 +14,7 @@ import { WindowControls } from "./TitleBar";
import { IconButton } from "./ui";
/** `quiet`: nothing while the model is loaded and idle (the phone bar has no room for "all is well"). */
-function StatusIndicator({ quiet = false }: { quiet?: boolean }) {
+export function StatusIndicator({ quiet = false }: { quiet?: boolean }) {
const connected = useStore((s) => s.connected);
const server = useStore((s) => s.server);
const busy = useStore((s) => Object.values(s.jobs).some((j) => !["done", "failed", "cancelled"].includes(j.status)));
@@ -110,44 +111,16 @@ function PrivateToggle() {
);
}
-/** Private mode from the phone menu: turning it off asks first (its images are deleted). */
+/** Private mode from the phone's library: turning it off asks first (its images are deleted). */
export function togglePrivateMode() {
+ if (isNarrow()) haptic();
setPrivateMode(!getState().privateMode, () => native.confirm("Turn off private mode? The images made in private mode will be deleted.", "Private mode"));
}
-/** Phone: the menu, the project's title, and only what a thumb needs next to it. Private mode
- * and Settings are in the full-screen menu; the status shows only while it is not "Ready". */
-function PhoneBar() {
- const overlay = useStore((s) => s.overlay);
- const privateMode = useStore((s) => s.privateMode);
- return (
- <div className="topbar phone">
- <IconButton title="Menu" onClick={() => setState({ sidebar: true })}>
- <Menu size={22} />
- </IconButton>
- <div className="brand">{overlay === "gallery" ? <span className="project-title">All images</span> : <ProjectTitle />}</div>
- <div className="toolbar">
- <StatusIndicator quiet />
- {privateMode && (
- <IconButton title="Private mode is on: tap to turn it off" onClick={togglePrivateMode} active>
- <EyeOff size={20} />
- </IconButton>
- )}
- <HistoryButtons />
- <IconButton title="New image" onClick={newProject}>
- <SquarePen size={20} />
- </IconButton>
- </div>
- </div>
- );
-}
-
export function TopBar() {
const overlay = useStore((s) => s.overlay);
const needsSetup = useStore((s) => s.needsSetup);
const sidebar = useStore((s) => s.sidebar);
- const narrow = useNarrow();
- if (narrow && !needsSetup) return <PhoneBar />;
return (
<div className="topbar" data-tauri-drag-region>
<div className="brand" data-tauri-drag-region>
diff --git a/src/components/ui.tsx b/src/components/ui.tsx
index 20c7d78..810ee99 100644
--- a/src/components/ui.tsx
+++ b/src/components/ui.tsx
@@ -37,15 +37,17 @@ export function Popover(props: {
const sheetRef = useRef<HTMLDivElement>(null);
useEffect(() => {
if (!open) return;
- const onDown = (e: MouseEvent) => {
+ // pointerdown, not mousedown: iOS sends no mouse events for a tap on the sheet's scrim. In the
+ // capture phase: the image stops its own pointerdown (press to compare, the slider).
+ const onDown = (e: PointerEvent) => {
const t = e.target as Node;
if (ref.current && !ref.current.contains(t) && !sheetRef.current?.contains(t)) setOpen(false);
};
const onKey = (e: KeyboardEvent) => e.key === "Escape" && setOpen(false);
- document.addEventListener("mousedown", onDown);
+ document.addEventListener("pointerdown", onDown, true);
document.addEventListener("keydown", onKey);
return () => {
- document.removeEventListener("mousedown", onDown);
+ document.removeEventListener("pointerdown", onDown, true);
document.removeEventListener("keydown", onKey);
};
}, [open]);
diff --git a/src/lib/haptics.ts b/src/lib/haptics.ts
new file mode 100644
index 0000000..26128c6
--- /dev/null
+++ b/src/lib/haptics.ts
@@ -0,0 +1,23 @@
+// A light tap of the phone's vibration motor, where a native app gives one (a version swiped to,
+// a long press, a prompt sent). Android browsers have the Vibration API. Safari on an iPhone has
+// none, but since iOS 17.4 a click on an `<input type="checkbox" switch>` plays the system's
+// switch haptic, so a hidden one is clicked (the method of the MIT `ios-haptics` package, from
+// cobalt.tools). Called from a tap or gesture handler; if a later iOS drops it, nothing happens.
+
+export function haptic() {
+ try {
+ if (navigator.vibrate?.(8)) return;
+ const label = document.createElement("label");
+ label.ariaHidden = "true";
+ label.style.display = "none";
+ const input = document.createElement("input");
+ input.type = "checkbox";
+ input.setAttribute("switch", "");
+ label.appendChild(input);
+ document.head.appendChild(label);
+ label.click();
+ label.remove();
+ } catch {
+ /* no haptics here */
+ }
+}
diff --git a/src/lib/store.ts b/src/lib/store.ts
index 2a96b51..860d2f1 100644
--- a/src/lib/store.ts
+++ b/src/lib/store.ts
@@ -379,8 +379,8 @@ async function hydrate(items: StoredItem[], projectId?: string): Promise<Session
}
const loadSidebar = () => {
- // On a phone the sidebar is a drawer over the page: start with it closed.
- if (isNarrow()) return false;
+ // On a phone the sidebar's place is the library (PhoneApp.tsx): it opens there, on the projects.
+ if (isNarrow()) return true;
try {
return localStorage.getItem(SIDEBAR_KEY) !== "0";
} catch {
@@ -431,7 +431,8 @@ export function setState(patch: Partial<State> | ((s: State) => Partial<State>))
state = { ...state, ...p };
if (p.composer) savePrefs(state.composer);
if (state.session !== prev.session || state.selected !== prev.selected || state.projectId !== prev.projectId) syncProject(prev);
- if (p.sidebar !== undefined) {
+ // On a phone "sidebar" is the library being open: not the desktop sidebar's saved choice.
+ if (p.sidebar !== undefined && !isNarrow()) {
try {
localStorage.setItem(SIDEBAR_KEY, p.sidebar ? "1" : "0");
} catch {
@@ -707,7 +708,8 @@ export function newProject() {
? { projectId: newKey(), session: [], selected: null, overlay: null, redo: [], composer: emptyComposer(s.composer) }
: { overlay: null, composer: { ...emptyComposer(s.composer), prompt: s.composer.prompt } },
);
- focusPrompt();
+ // A phone shows the new project's start first; the writing screen opens when the box is tapped.
+ if (!isNarrow()) focusPrompt();
}
/** Private mode on: a fresh project whose images stay out of the gallery, the output folder
@@ -728,7 +730,7 @@ export async function setPrivateMode(on: boolean, confirmDiscard: () => Promise<
// The project being left was saved already (normal mode) or is discarded (private mode).
setState((st) => ({ privateMode: on, projectId: newKey(), session: [], selected: null, overlay: null, redo: [], composer: emptyComposer(st.composer) }));
if (on) toastInfo("Private mode: images are not saved, and are deleted when you turn it off or close the app.");
- focusPrompt();
+ if (!isNarrow()) focusPrompt();
}
let switching = 0;
diff --git a/src/main.tsx b/src/main.tsx
index 5a40e1e..a11aa81 100644
--- a/src/main.tsx
+++ b/src/main.tsx
@@ -2,6 +2,7 @@ import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import App from "./App";
import "./styles.css";
+import "./phone.css";
import { syncWindowTheme } from "./lib/theme";
syncWindowTheme();
diff --git a/src/phone.css b/src/phone.css
new file mode 100644
index 0000000..66fe557
--- /dev/null
+++ b/src/phone.css
@@ -0,0 +1,368 @@
+/* Kokon on a phone (components/PhoneApp.tsx, PhoneStage.tsx and the composer's phone variant).
+ Built around an iPhone: safe areas, large continuous-looking corners, glass bars and sheets
+ from the bottom; the rest of Kokon's look (monochrome, the cocoon's motion curve) is kept. */
+
+@media (max-width: 720px) {
+ :root {
+ --radius-img: 24px;
+ /* translucent material for buttons and bars over the page or the image */
+ --glass: rgba(255, 255, 255, 0.72);
+ --glass-strong: rgba(255, 255, 255, 0.86);
+ --glass-edge: inset 0 0 0 0.5px rgba(0, 0, 0, 0.07), 0 1px 2px rgba(0, 0, 0, 0.05), 0 8px 22px -10px rgba(0, 0, 0, 0.2);
+ }
+ :root[data-theme="dark"] {
+ --glass: rgba(44, 44, 44, 0.62);
+ --glass-strong: rgba(34, 34, 34, 0.86);
+ --glass-edge: inset 0 0 0 0.5px rgba(255, 255, 255, 0.1), 0 8px 22px -10px rgba(0, 0, 0, 0.7);
+ }
+}
+
+/* ---------- the shell: it follows the visible part of the screen (the keyboard pushes it up) ---------- */
+.app.phone { display: block; }
+.phone-app { position: fixed; left: 0; right: 0; top: var(--vv-top, 0px); height: var(--vv-h, 100dvh); display: flex; flex-direction: column; overflow: hidden; background: var(--ground); }
+.phone-screen { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
+/* moving between the library and a project: the project comes from the right, the library back from the left */
+.phone-screen.project { animation: phone-push 0.42s var(--ease) both; }
+.phone-screen.library { animation: phone-pop 0.42s var(--ease) both; }
+@keyframes phone-push { from { opacity: 0; transform: translateX(36px); } to { opacity: 1; transform: none; } }
+@keyframes phone-pop { from { opacity: 0; transform: translateX(-36px); } to { opacity: 1; transform: none; } }
+.phone-app .main { flex: 1; min-height: 0; display: flex; position: relative; }
+/* the brush and expand editors over the whole screen, clear of the notch and the home bar */
+.phone-app > .overlay { z-index: 30; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
+.phone-app > .overlay .editor-stage { padding: 8px 12px; }
+.phone-app > .overlay .editor-tools { padding: 8px 10px 12px; gap: 8px; }
+.phone-app > .overlay .editor-tools .group { border-radius: 22px; }
+
+/* round glass buttons: the top bars, the library */
+.glass-btn { width: 44px; height: 44px; flex: none; border-radius: 50%; display: grid; place-items: center; color: var(--text); background: var(--glass); -webkit-backdrop-filter: blur(20px) saturate(1.8); backdrop-filter: blur(20px) saturate(1.8); box-shadow: var(--glass-edge); transition: transform 0.25s var(--ease), background 0.2s, color 0.2s; }
+.glass-btn:active { transform: scale(0.9); }
+.glass-btn.on { background: var(--invert-bg); color: var(--invert-text); }
+
+/* ---------- a project: top bar ---------- */
+.phone-top { flex: none; display: flex; align-items: center; gap: 8px; padding: calc(env(safe-area-inset-top) + 6px) 12px 6px; min-height: 58px; position: relative; z-index: 5; }
+.phone-title { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; }
+.phone-title .project-title { display: block; max-width: 100%; height: 34px; line-height: 34px; padding: 0 12px; border-radius: 17px; font-size: 16.5px; font-weight: 620; letter-spacing: -0.025em; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
+.phone-title .project-title:active { background: var(--surface); }
+.phone-title .project-title.placeholder { color: var(--text-3); font-weight: 500; }
+.phone-title .title-pencil { display: none; }
+.phone-title .name-field.title-field { width: 100%; height: 36px; border-radius: 12px; text-align: center; font-weight: 600; }
+.private-tag { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px; border-radius: 10px; background: var(--invert-bg); color: var(--invert-text); font-size: 11px; font-weight: 600; letter-spacing: 0.01em; }
+.phone-top-end { display: flex; align-items: center; gap: 8px; flex: none; }
+/* the status only while it says something (loading, working, an error): a glass dot */
+.phone-top .status { width: 44px; height: 44px; padding: 0; justify-content: center; border-radius: 50%; background: var(--glass); box-shadow: var(--glass-edge); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
+.phone-top .status > span:not(.dot) { display: none; }
+.phone-top .status .silk-spin { margin: 0; }
+
+/* ---------- a project: the stage ----------
+ The rows under the picture keep a fixed place (the bar's room is kept even without one), so
+ moving between versions of other shapes never moves them: only the picture changes, sitting
+ on top of them. */
+.phone-stage { padding: 2px 0 0; justify-content: flex-start; }
+.phone-stage::before { top: 38%; }
+.swipe { flex: 1; min-height: 0; width: 100%; display: flex; touch-action: pan-y; }
+.swipe-track, .swipe-page { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
+.swipe-page { padding: 0 12px; }
+.swipe-page.enter-right { animation: page-right 0.46s var(--ease) both; }
+.swipe-page.enter-left { animation: page-left 0.46s var(--ease) both; }
+@keyframes page-right { from { opacity: 0; transform: translateX(64px); } to { opacity: 1; transform: none; } }
+@keyframes page-left { from { opacity: 0; transform: translateX(-64px); } to { opacity: 1; transform: none; } }
+/* the picture in the middle of the room above the rows, which stay where they are */
+.phone-stage .stage-frame { align-items: center; }
+.swipe-page { padding-top: 6px; padding-bottom: 6px; }
+/* no "save image" callout on a long press: that press shows the original */
+.phone-stage img { -webkit-touch-callout: none; }
+/* controls on the picture: glass in the theme's colours */
+.phone-stage .fullscreen-btn { top: 10px; right: 10px; width: 36px; height: 36px; border-radius: 50%; opacity: 1; color: var(--text); background: var(--glass); box-shadow: var(--glass-edge); -webkit-backdrop-filter: blur(16px) saturate(1.6); backdrop-filter: blur(16px) saturate(1.6); }
+.phone-stage .fullscreen-btn:hover, .phone-stage .fullscreen-btn:focus-visible { background: var(--glass); }
+/* the comparison views: one glass button on the picture, its sheet lists them */
+.compare-pill-wrap { position: absolute; left: 10px; bottom: 10px; z-index: 2; }
+.compare-pill { height: 34px; padding: 0 11px 0 10px; border-radius: 17px; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 520; color: var(--text); background: var(--glass); box-shadow: var(--glass-edge); -webkit-backdrop-filter: blur(16px) saturate(1.6); backdrop-filter: blur(16px) saturate(1.6); }
+.compare-pill.on { background: var(--invert-bg); color: var(--invert-text); }
+.compare-speed { display: flex; align-items: center; gap: 12px; padding: 8px 14px 4px; }
+.compare-speed .seg { flex: 1; }
+/* (the desktop's switch on the picture, no longer shown on a phone) */
+.phone-stage .compare-overlay { left: 8px; right: 8px; bottom: 10px; transform: none; opacity: 1; display: flex; justify-content: center; pointer-events: none; }
+.phone-stage .compare-overlay .compare-bar { flex-direction: column-reverse; align-items: center; gap: 6px; pointer-events: auto; }
+.phone-stage .compare-overlay .seg { border-radius: 17px; padding: 3px; background: var(--glass); box-shadow: var(--glass-edge); -webkit-backdrop-filter: blur(16px) saturate(1.6); backdrop-filter: blur(16px) saturate(1.6); }
+.phone-stage .compare-overlay .seg button { height: 30px; padding: 0 11px; border-radius: 14px; font-size: 12.5px; color: var(--text-2); }
+.phone-stage .compare-overlay .seg button:hover { color: var(--text); }
+.phone-stage .compare-overlay .seg button.on { background: var(--pick-bg); color: var(--text); box-shadow: var(--pick); font-weight: 500; }
+.phone-stage .compare-tag { border-radius: 10px; top: 10px; }
+.phone-stage .compare-tag.left { left: 10px; }
+.phone-stage .pending { border-radius: var(--radius-img); }
+.phone-stage .stage-frame > .failed { padding: 0 20px; }
+
+/* under the picture: what it is, then what to do with it, in a room of fixed height */
+.phone-bar { flex: none; width: 100%; min-height: 128px; display: flex; flex-direction: column; }
+.phone-stage .stage-bar { max-width: none; margin-top: 12px; gap: 12px; }
+.phone-stage .stage-meta { padding: 0 16px; gap: 6px; flex-wrap: nowrap; font-size: 12.5px; white-space: nowrap; }
+.phone-stage .stage-meta .ver { font-size: 14px; }
+.phone-stage .stage-meta .dims-seg button { height: 22px; padding: 0 9px; font-size: 12px; }
+.phone-stage .seg-dims { display: none; }
+/* a row of round buttons with their names under them, scrolled sideways when it doesn't fit */
+.phone-stage .phone-actions { width: 100%; padding: 2px 14px 2px; gap: 2px; overflow-x: auto; scrollbar-width: none; justify-content: safe center; background: none; box-shadow: none; border-radius: 0;
+ /* the edges fade: more buttons are a swipe away */
+ -webkit-mask-image: linear-gradient(to right, transparent, #000 12px, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, transparent, #000 12px, #000 calc(100% - 28px), transparent); }
+.phone-actions::-webkit-scrollbar { display: none; }
+.phone-actions > * { flex: none; }
+.phone-actions .act { width: 62px; height: auto; padding: 0; flex-direction: column; gap: 5px; font-size: 11.5px; font-weight: 500; color: var(--text-2); background: none; border-radius: 0; }
+.phone-actions .act svg { width: 46px; height: 46px; padding: 14.5px; border-radius: 50%; background: var(--bg); color: var(--text); box-shadow: var(--lift); transition: transform 0.25s var(--ease), background 0.2s, color 0.2s; }
+.phone-actions .act:hover, .phone-actions .act.active { background: none; color: var(--text); }
+.phone-actions .act.active svg { background: var(--invert-bg); color: var(--invert-text); }
+.phone-actions .act:active svg { transform: scale(0.9); }
+.phone-actions .act-label { display: block; }
+/* a LUT being previewed: its bar as one card */
+.phone-stage .lut-bar { margin: 0 12px; padding: 6px; border-radius: 26px; flex-wrap: wrap; gap: 4px; max-width: calc(100% - 24px); }
+.phone-stage .lut-bar .lut-intensity { flex: 1 1 160px; }
+.phone-stage .lut-bar .lut-intensity input { width: auto; flex: 1; }
+.phone-stage .lut-bar .btn.primary { height: 36px; border-radius: 18px; padding: 0 18px; }
+
+/* the versions: the desktop's timeline (lines and arcs), scrolled by the finger */
+.phone-stage .timeline { flex: none; margin: 14px 0 6px; padding: 0 16px 4px; scrollbar-width: none; }
+.phone-stage .timeline::-webkit-scrollbar { display: none; }
+.phone-stage .frame-img .develop-ph { border-radius: 0; }
+.phone-stage .frame:active .frame-img { transform: scale(0.94); }
+
+/* a new project */
+.phone-empty { flex: 1; width: 100%; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; justify-content: center; gap: 8px; padding: 12px 20px 16px; animation: rise 0.8s var(--ease) both; }
+.phone-empty .kokon-mark { margin-bottom: 10px; color: var(--mark); }
+.phone-empty h1 { margin: 0; font-size: 31px; line-height: 1.08; font-weight: 700; letter-spacing: -0.04em; color: var(--text); }
+.phone-empty > p { margin: 0 0 14px; font-size: 16px; line-height: 1.4; color: var(--text-2); }
+.phone-photo { display: flex; align-items: center; gap: 14px; padding: 14px 18px 14px 14px; border-radius: 28px; background: var(--bg); box-shadow: var(--lift); text-align: left; transition: transform 0.25s var(--ease); }
+.phone-photo-icon { width: 50px; height: 50px; flex: none; border-radius: 18px; display: grid; place-items: center; background: var(--invert-bg); color: var(--invert-text); }
+.phone-photo-text { display: flex; flex-direction: column; gap: 1px; }
+.phone-photo-text strong { font-size: 16.5px; font-weight: 620; letter-spacing: -0.015em; }
+.phone-photo-text span { font-size: 13.5px; color: var(--text-3); }
+.ideas { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
+.ideas-label { padding-left: 6px; font-size: 13px; color: var(--text-3); }
+.idea { padding: 13px 18px; border-radius: 22px; background: var(--surface); color: var(--text-2); font-size: 15px; line-height: 1.35; text-align: left; transition: transform 0.25s var(--ease), background 0.2s; }
+.phone-photo:active, .idea:active { transform: scale(0.97); }
+
+/* the keyboard is up: the picture keeps the room, the rows under it give it up */
+html.keyboard .phone-stage .phone-bar, html.keyboard .phone-stage .timeline, html.keyboard .phone-empty .ideas { display: none; }
+
+/* ---------- the prompt ----------
+ Closed: a card at the bottom, the words on top and, under them, what the prompt works on and
+ send. Tapped: a screen of its own for writing (the picture and its rows step aside), with the
+ choices and send over the keyboard. */
+/* In Safari (its toolbar under the page) the card has 28 px corners. Added to the home screen, it
+ sits on the screen's round corners (a home bar: a bottom inset): as far from the bottom as from
+ the sides, its lower corners following the screen's (about 47-62 pt on recent iPhones, less the
+ 10 px gap; the upper ones stay 28 px), and the picture and send round, nested in them. On the
+ keyboard: 28 px again. */
+.composer-wrap.phone { --card-r: 28px; --card-r-bottom: 28px; position: relative; z-index: 20; padding: 6px 10px max(8px, calc(env(safe-area-inset-bottom) - 14px)); }
+@media (display-mode: standalone) {
+ html:not(.keyboard) .composer-wrap.phone { --card-r-bottom: clamp(28px, calc(env(safe-area-inset-bottom) * 1.3), 46px); padding-bottom: 10px; }
+ html:not(.keyboard) .composer-wrap.phone:not(.open) .composer { padding: 16px 14px 14px 20px; }
+ html:not(.keyboard) .composer-wrap.phone:not(.open) .closed-row { margin-left: -6px; }
+ html:not(.keyboard) .composer-wrap.phone:not(.open) .prompt-ctx,
+ html:not(.keyboard) .composer-wrap.phone:not(.open) .prompt-ctx img { width: 44px; height: 44px; border-radius: 50%; }
+ html:not(.keyboard) .composer-wrap.phone:not(.open) .send { width: 44px; height: 44px; }
+}
+html.keyboard .composer-wrap.phone { padding-bottom: 8px; }
+.composer-wrap.phone .composer { border-radius: var(--card-r) var(--card-r) var(--card-r-bottom) var(--card-r-bottom); padding: 14px 10px 10px 14px; background: var(--glass-strong); -webkit-backdrop-filter: blur(24px) saturate(1.8); backdrop-filter: blur(24px) saturate(1.8); box-shadow: var(--shadow); }
+.composer-wrap.phone .composer::before { border-radius: calc(var(--card-r) + 1px) calc(var(--card-r) + 1px) calc(var(--card-r-bottom) + 1px) calc(var(--card-r-bottom) + 1px); }
+.prompt-row { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
+.composer-wrap.phone:not(.open) .prompt { height: 26px !important; line-height: 26px; padding: 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
+.closed-row { display: flex; align-items: center; gap: 10px; }
+.prompt-ctx-wrap { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
+.prompt-ctx-label { min-width: 0; font-size: 13px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
+.composer-wrap.phone .send { width: 42px; height: 42px; }
+.prompt-ctx { position: relative; width: 40px; height: 40px; flex: none; border-radius: 14px; display: grid; place-items: center; background: var(--surface); color: var(--text-2); }
+.prompt-ctx img { display: block; width: 40px; height: 40px; min-width: 0; max-width: none; object-fit: cover; border-radius: 14px; }
+.prompt-ctx .frame-badge { right: -3px; bottom: -3px; width: 18px; height: 18px; box-shadow: 0 0 0 2px var(--bg); }
+.prompt-ctx .num { position: absolute; right: -4px; top: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--invert-bg); color: var(--invert-text); font-size: 10.5px; font-weight: 600; display: grid; place-items: center; box-shadow: 0 0 0 2px var(--bg); }
+
+/* writing: the box takes the screen above the keyboard */
+.phone-screen.project:has(.composer-wrap.open) .phone-top, .phone-screen.project:has(.composer-wrap.open) .main { display: none; }
+.composer-wrap.phone.open { flex: 1; min-height: 0; display: flex; flex-direction: column; padding-top: calc(env(safe-area-inset-top) + 6px); animation: fade 0.25s ease-out both; }
+.composer-wrap.phone.open .composer { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 10px 10px 10px 12px; background: var(--bg); box-shadow: var(--lift); -webkit-backdrop-filter: none; backdrop-filter: none; }
+.composer-wrap.phone.open .prompt-row { flex: 1; min-height: 0; }
+.composer-wrap.phone.open .prompt { flex: 1; height: auto !important; max-height: none; padding: 6px 4px; font-size: 18px; line-height: 1.45; overflow-y: auto; }
+.compose-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
+.compose-head .glass-btn { width: 40px; height: 40px; background: var(--surface); box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
+.compose-hint { min-width: 0; padding-right: 6px; font-size: 12.5px; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
+
+/* the open box: one kind of button, filled and borderless; a switch that is on is ink */
+.composer-wrap.phone .target { gap: 8px; padding: 0 0 10px; margin-bottom: 4px; }
+.composer-wrap.phone .mode-switch { border-radius: 19px; padding: 3px; }
+.composer-wrap.phone .mode-switch button { height: 32px; min-width: 38px; justify-content: center; padding: 0 10px; border-radius: 16px; }
+.composer-wrap.phone .target-icon, .composer-wrap.phone .ref, .composer-wrap.phone .ref img { border-radius: 14px; }
+.composer-wrap.phone .tool { height: 38px; min-width: 38px; padding: 0 11px; justify-content: center; border: 0; border-radius: 19px; background: var(--surface); color: var(--text); }
+.composer-wrap.phone .tool.on { background: var(--invert-bg); color: var(--invert-text); }
+.composer-wrap.phone .tool-group .tool.on { border-radius: 19px 0 0 19px; padding-right: 6px; }
+.composer-wrap.phone .tool-x { height: 38px; padding: 0 11px 0 6px; border-radius: 0 19px 19px 0; background: var(--invert-bg); color: var(--invert-text); }
+/* the box's buttons scroll sideways, fading at the edge; the send button sits beside them */
+/* (the fade is an overlay, not a mask: iOS Safari does not scroll a masked row by touch) */
+.composer-wrap.phone .controls-row { position: relative; display: flex; align-items: center; gap: 8px; margin-top: 8px; }
+.composer-wrap.phone .controls-row::after { content: ""; position: absolute; top: 0; bottom: 0; right: 50px; width: 24px; background: linear-gradient(to right, transparent, var(--bg)); pointer-events: none; }
+.composer-wrap.phone .controls { flex: 1; min-width: 0; gap: 6px; margin-top: 0; padding-right: 20px; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; touch-action: pan-x; scrollbar-width: none; }
+.composer-wrap.phone .controls::-webkit-scrollbar { display: none; }
+.composer-wrap.phone .controls > * { flex: none; }
+.composer-wrap.phone .controls .spacer { flex: 1 0 4px; }
+.composer-wrap.phone .controls .pill { height: 38px; padding: 0 13px; gap: 7px; border: 0; border-radius: 19px; background: var(--surface); color: var(--text); font-size: 13.5px; font-weight: 500; }
+.composer-wrap.phone .controls .pill.on:not(.toggle) { background: var(--surface-3); }
+.composer-wrap.phone .controls .pill.toggle.on { background: var(--invert-bg); color: var(--invert-text); }
+.composer-wrap.phone .controls .pill .lbl { display: inline; }
+.composer-wrap.phone .controls .icon-btn { width: 38px; height: 38px; border-radius: 50%; background: var(--surface); color: var(--text); }
+.composer-wrap.phone .controls .icon-btn.active { background: var(--surface-3); }
+.composer-wrap.phone .controls .seg { border-radius: 19px; padding: 3px; }
+.composer-wrap.phone .controls .seg button { height: 32px; border-radius: 16px; padding: 0 10px; font-size: 13px; }
+.composer-wrap.phone .controls .spacer, .composer-wrap.phone .controls .plan-hint { display: none; }
+.composer-wrap.phone .controls .icon-btn[title="Prompt tips"] { display: none; }
+.composer-wrap.phone .send:disabled { opacity: 1; background: var(--surface-3); color: var(--text-3); box-shadow: none; }
+
+/* ---------- the brush and expand editors ---------- */
+.phone-app > .overlay .overlay-head { height: auto; min-height: 58px; padding: 6px 12px 6px 18px; flex-wrap: wrap; row-gap: 0; }
+.phone-app > .overlay .overlay-head h2 { font-size: 17px; font-weight: 620; letter-spacing: -0.02em; }
+.phone-app > .overlay .overlay-head .muted { order: 3; flex-basis: 100%; margin-top: -6px; padding-bottom: 4px; font-size: 12.5px; }
+.phone-app > .overlay .overlay-head .icon-btn { width: 44px; height: 44px; border-radius: 50%; background: var(--glass); box-shadow: var(--glass-edge); color: var(--text); }
+/* the tools: one card at the bottom; groups as filled capsules, round buttons, Done in ink */
+.phone-app > .overlay .editor-tools { margin: 0 10px 10px; padding: 10px; gap: 8px 6px; justify-content: space-between; border-radius: 28px; background: var(--bg); box-shadow: var(--shadow); }
+.phone-app > .overlay .editor-tools .group { padding: 3px; gap: 2px; border-radius: 22px; background: var(--surface); box-shadow: none; }
+.phone-app > .overlay .editor-tools .icon-btn { width: 40px; height: 40px; border-radius: 50%; color: var(--text); }
+.phone-app > .overlay .editor-tools .icon-btn:hover:not(:disabled) { background: var(--surface-3); }
+.phone-app > .overlay .editor-tools .icon-btn.active { background: var(--invert-bg); color: var(--invert-text); }
+.phone-app > .overlay .editor-tools .pill { height: 40px; padding: 0 13px; border-radius: 20px; color: var(--text); font-size: 13.5px; }
+/* the brush editor: tools and undo on the first line, size and Done on the second */
+.phone-app > .overlay .editor-tools > .group:has(.slider) { order: 3; flex: 1 1 auto; }
+.phone-app > .overlay .editor-tools > .btn.primary { order: 4; }
+.phone-app > .overlay .editor-tools .slider { height: 40px; flex: 1; padding: 0 14px; gap: 12px; font-size: 13.5px; color: var(--text-2); }
+.phone-app > .overlay .editor-tools .slider input { width: auto; flex: 1; }
+.phone-app > .overlay .editor-tools .btn.primary { height: 46px; padding: 0 22px; border-radius: 23px; font-size: 15px; font-weight: 600; }
+/* the expand editor: the four sides in a row of fields, then px/% and Done */
+.phone-app > .overlay .editor-tools > div:not(.group) { width: 100%; }
+.phone-app > .overlay .expand-fields { width: 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
+.phone-app > .overlay .expand-fields label { flex-direction: column; align-items: stretch; gap: 4px; font-size: 12px; text-align: center; }
+.phone-app > .overlay .expand-fields .num-input { width: 100%; height: 40px; border: 0; border-radius: 14px; background: var(--surface); text-align: center; font-size: 16px; }
+.phone-app > .overlay .expand-fields > div { width: auto !important; grid-column: span 2; }
+.phone-app > .overlay .expand-fields .seg { height: 46px; border-radius: 23px; padding: 4px; }
+.phone-app > .overlay .expand-fields .seg button { height: 38px; border-radius: 19px; font-size: 14px; }
+.phone-app > .overlay .expand-fields .btn.primary { grid-column: span 2; justify-content: center; }
+.phone-app > .overlay .handle.h { width: 8px; height: 48px; border-radius: 4px; }
+.phone-app > .overlay .handle.v { width: 48px; height: 8px; border-radius: 4px; }
+/* zoom in the brush editor: a glass capsule in the theme's colours */
+.phone-app .zoom-controls { padding: 4px; border-radius: 20px; color: var(--text); background: var(--glass); box-shadow: var(--glass-edge); -webkit-backdrop-filter: blur(16px) saturate(1.6); backdrop-filter: blur(16px) saturate(1.6); }
+.phone-app .zoom-btn { height: 34px; min-width: 34px; border-radius: 17px; color: var(--text-2); }
+.phone-app .zoom-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
+.phone-app .zoom-minimap { border-radius: 14px; }
+
+/* ---------- the library ---------- */
+.lib-head { flex: none; display: flex; flex-direction: column; gap: 14px; padding: calc(env(safe-area-inset-top) + 10px) 16px 12px; }
+.lib-title-row { display: flex; align-items: center; gap: 8px; }
+.lib-title-row h1 { flex: 1; min-width: 0; margin: 0; display: flex; align-items: center; gap: 10px; font-size: 32px; font-weight: 720; letter-spacing: -0.045em; color: var(--text); }
+.lib-title-row h1 .kokon-mark { color: var(--text); }
+.lib-text-btn { height: 36px; padding: 0 12px; border-radius: 18px; font-size: 15.5px; font-weight: 520; color: var(--text); }
+.lib-text-btn:active { background: var(--surface); }
+.lib-seg { padding: 3px; border-radius: 15px; }
+.lib-seg button { height: 34px; border-radius: 12px; font-size: 14px; font-weight: 520; }
+.lib-body { flex: 1; min-height: 0; position: relative; }
+.lib-scroll { position: absolute; inset: 0; overflow-y: auto; padding: 4px 16px calc(112px + env(safe-area-inset-bottom)); }
+.lib-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 14px; }
+@media (min-width: 540px) { .lib-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
+.lib-card { display: flex; flex-direction: column; gap: 2px; min-width: 0; text-align: left; -webkit-touch-callout: none; animation: rise 0.55s var(--ease) backwards; }
+.lib-card:nth-child(2) { animation-delay: 0.04s; }
+.lib-card:nth-child(3) { animation-delay: 0.08s; }
+.lib-card:nth-child(4) { animation-delay: 0.12s; }
+.lib-card:nth-child(n + 5) { animation-delay: 0.16s; }
+.lib-cover { position: relative; display: block; aspect-ratio: 1; margin-bottom: 8px; border-radius: 26px; overflow: hidden; background: var(--surface-2); box-shadow: var(--lift); transition: transform 0.3s var(--ease), box-shadow 0.25s; }
+.lib-cover > img { width: 100%; height: 100%; object-fit: cover; display: block; }
+.lib-cover .develop-ph { border-radius: 0; }
+.lib-card:active .lib-cover { transform: scale(0.96); }
+.lib-card.current .lib-cover { box-shadow: 0 0 0 2.5px var(--ground), 0 0 0 4.5px var(--text); }
+.lib-card.picked .lib-cover { transform: scale(0.93); }
+.lib-cover .pick-mark { left: auto; right: 10px; top: 10px; width: 26px; height: 26px; z-index: 2; }
+.lib-card.picked .pick-mark { background: var(--invert-bg); color: var(--invert-text); box-shadow: 0 0 0 2px var(--invert-text); }
+.lib-card-title { padding: 0 6px; font-size: 15px; font-weight: 600; letter-spacing: -0.015em; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
+.lib-card-sub { padding: 0 6px; font-size: 13px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
+.lib-private { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; padding: 14px 10px 14px 16px; border-radius: 24px; background: var(--invert-bg); color: var(--invert-text); font-size: 13.5px; line-height: 1.35; }
+.lib-private > svg { flex: none; }
+.lib-private > span { flex: 1; min-width: 0; opacity: 0.85; }
+.lib-private strong { display: block; font-size: 15px; font-weight: 600; opacity: 1; }
+.lib-private .lib-text-btn { color: inherit; flex: none; }
+.lib-empty { display: flex; flex-direction: column; gap: 6px; padding: 48px 12px; text-align: center; color: var(--text-3); font-size: 14.5px; }
+.lib-empty strong { color: var(--text); font-size: 17px; }
+/* New image: a floating button over the bottom of the list */
+.lib-dock { position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; justify-content: center; padding: 28px 16px max(14px, env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--ground) 55%); pointer-events: none; }
+.lib-dock > * { pointer-events: auto; }
+.lib-new { height: 56px; padding: 0 28px 0 24px; border-radius: 28px; display: inline-flex; align-items: center; gap: 8px; background: var(--invert-bg); color: var(--invert-text); font-size: 17px; font-weight: 600; letter-spacing: -0.01em; box-shadow: 0 14px 32px -12px rgba(0, 0, 0, 0.5); transition: transform 0.25s var(--ease); }
+.lib-new:active { transform: scale(0.95); }
+.lib-dock.select { left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); justify-content: space-between; align-items: center; padding: 8px 8px 8px 20px; border-radius: 30px; background: var(--glass-strong); -webkit-backdrop-filter: blur(24px) saturate(1.8); backdrop-filter: blur(24px) saturate(1.8); box-shadow: var(--shadow); pointer-events: auto; animation: rise 0.3s var(--ease) both; }
+.lib-dock.select .btn { height: 44px; border-radius: 22px; padding: 0 18px; font-size: 15px; }
+
+/* All images, inside the library */
+.library .lib-body > .overlay { background: transparent; animation: none; }
+.library .lib-body > .overlay > .overlay-head { display: none; }
+.library .gallery-bar { padding: 0 16px 12px; gap: 6px; }
+.library .gallery-bar .search { flex: 1 1 100%; max-width: none; height: 40px; border-radius: 14px; }
+.library .gallery-bar .btn { height: 36px; border-radius: 18px; }
+.library .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 0 4px calc(24px + env(safe-area-inset-bottom)); }
+.library .card { border-radius: 10px; box-shadow: none; }
+.library .card .develop-ph { border-radius: 0; }
+.library .gallery-select { bottom: max(12px, env(safe-area-inset-bottom)); border-radius: 26px; min-width: 0; left: 12px; right: 12px; transform: none; flex-wrap: wrap; }
+/* one image of All images: the whole screen */
+.library:has(.preview) .lib-head { display: none; }
+.library .preview .overlay-head { height: auto; min-height: 52px; padding: env(safe-area-inset-top) 12px 0 8px; }
+
+/* one image of All images: a glass back button, round buttons and Open in project in ink */
+.library .preview { background: var(--ground); }
+.library .preview .overlay-head { gap: 10px; }
+.library .preview .overlay-head .icon-btn, .library .preview-bar .icon-btn { width: 44px; height: 44px; border-radius: 50%; color: var(--text); background: var(--glass); box-shadow: var(--glass-edge); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
+.library .preview-bar .icon-btn.active { background: var(--invert-bg); color: var(--invert-text); }
+.library .preview .preview-prompt { font-size: 15px; font-weight: 520; }
+.library .preview .preview-pos { font-size: 13px; padding-right: 4px; }
+.library .preview-stage { margin: 4px 12px; }
+.library .preview-bar { gap: 8px; padding: 12px 16px max(14px, env(safe-area-inset-bottom)); }
+.library .preview-bar .dims { display: none; }
+.library .preview-bar .btn.primary { height: 48px; margin-left: 4px; padding: 0 22px; border-radius: 24px; font-size: 15px; font-weight: 600; }
+
+/* Save on an iPhone without HTTPS: the picture to hold, whose system menu saves it to Photos */
+.hold-save { position: fixed; inset: 0; z-index: 210; display: flex; flex-direction: column; background: #000; color: #fff; animation: fade 0.25s ease-out both; }
+.hold-save-head { flex: none; display: flex; align-items: center; gap: 12px; padding: calc(env(safe-area-inset-top) + 8px) 12px 10px 20px; font-size: 15px; line-height: 1.35; }
+.hold-save-head > span { flex: 1; color: rgba(255, 255, 255, 0.85); }
+.hold-save-head strong { color: #fff; font-weight: 600; }
+.hold-save-head .glass-btn { color: #fff; background: rgba(255, 255, 255, 0.14); box-shadow: none; }
+.hold-save-img { flex: 1; min-height: 0; position: relative; display: grid; place-items: center; padding: 8px 12px calc(env(safe-area-inset-bottom) + 16px); }
+/* the image's own long-press menu (Save to Photos) is what this view is for */
+.hold-save-img > img:not(.develop-ph img) { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 18px; -webkit-touch-callout: default; -webkit-user-select: auto; user-select: auto; }
+.hold-save-img .develop-ph { inset: 8px 12px calc(env(safe-area-inset-bottom) + 16px); border-radius: 18px; background: #111; }
+.hold-save-img .develop-ph img { object-fit: contain; }
+
+/* ---------- sheets (menus) like iOS: a grabber, large corners, rising from the bottom ---------- */
+@media (max-width: 720px) {
+ .popover.sheet { border-radius: 32px; padding: 22px 10px 10px; animation: sheet-up 0.42s var(--ease) both; }
+ .popover.sheet::before { content: ""; position: absolute; top: 8px; left: 50%; width: 36px; height: 5px; margin-left: -18px; border-radius: 3px; background: var(--surface-3); }
+ .popover.sheet.panel { padding: 24px 16px 16px; }
+ .popover.sheet .opt { width: 100%; min-height: 50px; padding: 0 14px; gap: 14px; border-radius: 18px; font-size: 16px; }
+ .popover.sheet .opt .check { width: 18px; }
+ .popover.sheet .opt > span:nth-child(2) { white-space: nowrap; }
+ .popover.sheet .opt .sub { font-size: 13px; text-align: right; }
+ .popover.sheet .opt.danger { color: var(--bad); }
+ .popover.sheet .label { padding: 2px 14px 8px; font-size: 13px; letter-spacing: 0; text-transform: none; }
+ .popover.sheet .btn { height: 44px; border-radius: 16px; font-size: 15px; justify-content: center; }
+ .popover.sheet .info-panel { padding: 4px 6px !important; }
+ .sheet-scrim { background: rgba(0, 0, 0, 0.3); }
+ @keyframes sheet-up { from { opacity: 0; transform: translateY(48px); } to { opacity: 1; transform: none; } }
+ /* a project held down: its picture and name */
+ .sheet-head { display: flex; align-items: center; gap: 14px; padding: 2px 6px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
+ .sheet-cover { width: 60px; height: 60px; flex: none; border-radius: 18px; overflow: hidden; background: var(--surface-2); }
+ .sheet-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
+ .sheet-name { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--text-3); }
+ .sheet-name .input { height: 44px; border-radius: 14px; padding: 0 12px; font-weight: 600; }
+ /* full screen: no keyboard hints; the close button clear of the notch, the bars of the home bar */
+ .viewer-hint { display: none; }
+ .viewer-bar { top: calc(env(safe-area-inset-top) + 10px); right: 12px; }
+ .viewer-close { width: 44px; height: 44px; border-radius: 50%; -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
+ .viewer-tag { border-radius: 12px; padding: 5px 10px; }
+ .viewer-compare-bar { bottom: calc(14px + env(safe-area-inset-bottom)); }
+ .viewer .zoom-controls { border-radius: 18px; }
+ .viewer-compare-bar .compare-bar { border-radius: 18px; }
+ .viewer-compare-bar .seg button { padding: 0 12px; }
+ /* messages at the top of the screen, like a banner */
+ .app.phone .toasts { top: calc(env(safe-area-inset-top) + 8px); bottom: auto; left: 10px; right: 10px; }
+ .app.phone .toast, .app.phone .star-prompt { border-radius: 24px; padding: 14px 16px; }
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .phone-screen.project, .phone-screen.library, .swipe-page.enter-right, .swipe-page.enter-left, .lib-card, .phone-empty, .popover.sheet { animation: none; }
+}
diff --git a/src/styles.css b/src/styles.css
index 78ffa21..6f25e04 100644
--- a/src/styles.css
+++ b/src/styles.css
@@ -29,6 +29,8 @@
--pick-bg: #ffffff;
--glow: rgba(255, 255, 255, 0.95);
--checker: #ebebeb;
+ /* the light that runs across an image still loading */
+ --sheen: rgba(255, 255, 255, 0.55);
--sidebar: transparent;
--radius: 14px;
--radius-img: 14px;
@@ -64,6 +66,7 @@
--pick-bg: #333333;
--glow: rgba(255, 255, 255, 0.045);
--checker: #181818;
+ --sheen: rgba(255, 255, 255, 0.07);
--sidebar: transparent;
color-scheme: dark;
}
@@ -587,7 +590,10 @@ pre.diag { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font
.compare-overlay .seg button { height: 26px; padding: 0 10px; color: rgba(255, 255, 255, 0.8); }
.compare-overlay .seg button:hover { color: #fff; }
.compare-overlay .seg button.on { background: rgba(255, 255, 255, 0.92); color: #111; box-shadow: none; }
-.compare-box { position: relative; border-radius: var(--radius-img); overflow: hidden; touch-action: none; user-select: none; background-image: conic-gradient(var(--checker) 25%, transparent 0 50%, var(--checker) 0 75%, transparent 0); background-size: 16px 16px; }
+/* The checkerboard (transparent areas) is on the result image itself: while it loads, the box
+ shows its developing placeholder instead (Develop.tsx). */
+.compare-box { position: relative; border-radius: var(--radius-img); overflow: hidden; touch-action: none; user-select: none; }
+.compare-img { background-image: conic-gradient(var(--checker) 25%, transparent 0 50%, var(--checker) 0 75%, transparent 0); background-size: 16px 16px; }
.compare-box.slider { cursor: ew-resize; }
/* the area painted for the next edit, drawn like in the inpaint editor */
.stage-mask { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: var(--radius-img); mix-blend-mode: difference; opacity: 0.75; pointer-events: none; }
@@ -607,6 +613,25 @@ pre.diag { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font
.compare-tag.left { left: 8px; }
.compare-tag.right { right: 8px; }
+/* An image developing into view (Develop.tsx): hidden until decoded, over a blurred thumbnail or a
+ slow sheen, then it sharpens in while the placeholder fades off. Replaces the checkerboard
+ that used to show while a picture loaded. */
+.develop-ph { position: absolute; inset: 0; z-index: 1; overflow: hidden; border-radius: var(--radius-img); background: var(--surface); pointer-events: none; transition: opacity 0.55s var(--ease); }
+.develop-ph.out { opacity: 0; }
+.develop-ph img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: blur(16px) saturate(1.15); transform: scale(1.1); opacity: 0; transition: opacity 0.4s ease-out; }
+.develop-ph img.on { opacity: 1; }
+/* the sheen starts after a moment, so a quick load never flickers */
+.develop-ph::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 30%, var(--sheen) 50%, transparent 70%) no-repeat; background-size: 220% 100%; opacity: 0; animation: develop-sheen 1.9s 0.3s ease-in-out infinite; }
+@keyframes develop-sheen { 0% { opacity: 1; background-position: 130% 0; } 100% { opacity: 1; background-position: -30% 0; } }
+.develop-wait { opacity: 0; }
+.develop-in { animation: develop-in 0.75s var(--ease) both; }
+@keyframes develop-in { from { opacity: 0; filter: blur(14px) saturate(1.2); transform: scale(1.025); } 45% { opacity: 1; } to { opacity: 1; filter: none; transform: none; } }
+@media (prefers-reduced-motion: reduce) {
+ .develop-ph::after { animation: none; }
+ .develop-in { animation: develop-fade 0.3s both; }
+}
+@keyframes develop-fade { from { opacity: 0; } to { opacity: 1; } }
+
/* image box + full-screen button */
.image-box { position: relative; }
/* LUT preview: the LUT image over the result, its opacity = the intensity. */
@@ -675,7 +700,10 @@ pre.diag { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font
.preview-prompt { flex: 1; min-width: 0; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-pos { font-size: 13px; font-variant-numeric: tabular-nums; }
.preview-stage { position: relative; flex: 1; min-height: 0; }
-.preview-img { position: absolute; top: 0; bottom: 0; left: 76px; width: calc(100% - 152px); height: 100%; object-fit: contain; user-select: none; }
+.preview-img { position: absolute; top: 0; bottom: 0; left: 76px; width: calc(100% - 152px); height: 100%; user-select: none; }
+.preview-img > img { width: 100%; height: 100%; object-fit: contain; display: block; }
+.preview-img .develop-ph { background: none; }
+.preview-img .develop-ph img { object-fit: contain; }
.preview-bar { display: flex; align-items: center; gap: 6px; padding: 10px 16px 14px; flex: none; }
.preview-bar .spacer { flex: 1; }
.preview-bar .btn.primary { margin-left: 6px; }
@@ -1005,62 +1033,13 @@ kbd { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 6px; display
.modal-save { display: none; }
-/* ---------- phone-sized screens (Kokon in a browser on another device) ---------- */
-@keyframes menu-in { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: none; } }
-@media (prefers-reduced-motion: reduce) { .sidebar { animation: none !important; } }
+/* ---------- phone-sized screens (Kokon in a browser on another device) ----------
+ The phone's own layout is in phone.css; these cover what it shares with the desktop one
+ (setup, Settings, menus, the gallery). */
@media (max-width: 720px) {
- /* the menu covers the screen, with rows a thumb can hit */
- .sidebar { position: fixed; inset: 0; width: auto; z-index: 45; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); background: var(--ground); animation: menu-in 0.2s ease-out both; }
- .side-head { height: 56px; padding: 0 6px 0 20px; }
- .side-head .wordmark { font-size: 17px; }
- .side-head .icon-btn { width: 44px; height: 44px; }
- .side-nav { padding: 4px 12px 12px; gap: 4px; }
- .side-item { height: 50px; padding: 0 14px; gap: 14px; font-size: 16px; border-radius: 14px; }
- .side-item svg { width: 20px; height: 20px; }
- .side-state { margin-left: auto; font-size: 14px; color: var(--text-3); }
- .side-label { font-size: 13px; padding: 10px 14px 6px 26px; }
- .side-select { opacity: 1; height: 34px; padding: 0 12px; font-size: 14px; }
- .side-list { padding: 2px 12px 16px; gap: 4px; }
- .proj { padding: 9px; gap: 14px; }
- .proj .cover { width: 52px; height: 52px; border-radius: 12px; }
- .proj-title { font-size: 15.5px; }
- .proj-sub { font-size: 13px; margin-top: 2px; }
- .proj-rm, .proj:hover .proj-rm { display: grid; width: 40px; height: 40px; border-radius: 12px; color: var(--text-3); }
- .proj-rm svg { width: 17px; height: 17px; }
- .side-foot { padding: 8px 12px 12px; }
- .side-item.settings { height: 50px; font-size: 16px; }
- /* the top bar: menu, title, then undo/redo and New image; 40 px targets */
- .topbar.phone { height: 56px; box-sizing: content-box; padding: env(safe-area-inset-top) 6px 0 6px; gap: 2px; justify-content: flex-start; }
- .topbar.phone .icon-btn { width: 42px; height: 42px; border-radius: 13px; }
- .topbar.phone .brand { flex: 1; min-width: 0; justify-content: center; }
- .topbar.phone .project-title { font-size: 15px; height: 40px; padding: 0 10px; max-width: 100%; }
- .topbar.phone .title-pencil { display: none; }
- .topbar.phone .name-field.title-field { width: 100%; height: 40px; }
- .topbar.phone .toolbar { margin-left: 0; gap: 0; }
- /* the status capsule only while it says something (loading, working, an error): its dot or spinner */
- .topbar.phone .status { margin: 0 4px; padding: 0; width: 34px; height: 34px; justify-content: center; }
- .topbar.phone .status > span:not(.dot) { display: none; }
/* during setup the usual bar stays (mark, status, Settings), without the shortcuts */
- .topbar:not(.phone) { padding: env(safe-area-inset-top) 6px 0 12px; }
+ .topbar { padding: env(safe-area-inset-top) 6px 0 12px; }
.topbar .icon-btn[title="Shortcuts (?)"] { display: none; }
- .stage { padding: 4px 10px 8px; }
- .empty h1 { font-size: 24px; }
- .empty .hint { display: none; }
- .stage-bar { margin-top: 10px; }
- /* name, mode and upscaled/original wrap onto two centred lines instead of leaving the screen */
- .stage-meta { flex-wrap: wrap; row-gap: 6px; padding: 0 4px; }
- .stage-bar .actions { flex-wrap: wrap; justify-content: center; }
- .composer-wrap { padding: 0 8px max(8px, calc(env(safe-area-inset-bottom) - 14px)); }
- .composer { border-radius: 22px; }
- /* the composer's buttons scroll sideways; the send button stays at the right edge */
- .controls { overflow-x: auto; scrollbar-width: none; margin-right: -2px; padding-right: 2px; }
- .controls::-webkit-scrollbar { display: none; }
- .controls > * { flex: none; }
- .controls .spacer { flex: 1 0 4px; }
- .controls .send { position: sticky; right: 0; z-index: 1; box-shadow: 0 0 0 4px var(--bg), 0 6px 16px -6px rgba(13, 13, 13, 0.5); }
- /* opaque even when off, so buttons scrolling under it don't show through */
- .controls .send:disabled { opacity: 1; background: var(--surface-3); color: var(--text-3); box-shadow: 0 0 0 4px var(--bg); }
- .controls .icon-btn[title="Prompt tips"] { display: none; }
/* iOS zooms the page into any field under 16 px */
textarea, input:not([type]), input[type="text"], input[type="password"], input[type="number"], input[type="search"], .input, .select, .prompt, .name-field, .name-field.title-field { font-size: 16px; }
/* no double-tap zoom on buttons */