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: menus as bottom sheets, Save at the foot of Settings, 16 px prompt (no iOS zoom), round send button

Gabriele Lozuponeb8150772c44a
diff --git a/src/components/Settings.tsx b/src/components/Settings.tsx
index 296a4c2..6620530 100644
--- a/src/components/Settings.tsx
+++ b/src/components/Settings.tsx
@@ -317,7 +317,7 @@ export function Settings() {
))}
<span style={{ flex: 1 }} />
{tab !== "diagnostics" && tab !== "lora" && tab !== "devices" && (
- <button className="btn primary" style={{ justifyContent: "center" }} disabled={!dirty} onClick={save}>
+ <button className="btn primary nav-save" style={{ justifyContent: "center" }} disabled={!dirty} onClick={save}>
Save
</button>
)}
@@ -705,6 +705,8 @@ export function Settings() {
</span>
</>
)}
+ {!inBrowser && (
+ <>
<label className="field-row">
<span>Inference server port</span>
<input className="input" type="number" min={1024} max={65535} style={{ width: 100 }} value={cfg.serverPort} onChange={(e) => set({ serverPort: Number(e.target.value) || cfg.serverPort })} />
@@ -713,12 +715,22 @@ export function Settings() {
<span>Extra server arguments</span>
<input className="input" type="text" spellCheck={false} placeholder="e.g. --vae-conv-direct" value={cfg.extraServerArgs.join(" ")} onChange={(e) => set({ extraServerArgs: e.target.value.split(/\s+/).filter(Boolean) })} />
</label>
- <span className="muted">The server always listens on 127.0.0.1 only.</span>
+ </>
+ )}
+ {!inBrowser && <span className="muted">The server always listens on 127.0.0.1 only.</span>}
</>
)}
{tab === "lora" && <LoraSettings />}
{tab === "diagnostics" && <Diagnostics />}
+ {/* On a phone Save sits at the foot of the page (the tabs scroll sideways). */}
+ {tab !== "diagnostics" && tab !== "lora" && tab !== "devices" && (
+ <div className="modal-save">
+ <button className="btn primary" disabled={!dirty} onClick={save}>
+ Save
+ </button>
+ </div>
+ )}
</div>
</div>
</div>
diff --git a/src/components/ui.tsx b/src/components/ui.tsx
index 6dfa383..ff80a7f 100644
--- a/src/components/ui.tsx
+++ b/src/components/ui.tsx
@@ -1,5 +1,7 @@
import { Check } from "lucide-react";
import { useEffect, useLayoutEffect, useRef, useState, type ReactNode } from "react";
+import { createPortal } from "react-dom";
+import { isNarrow } from "../lib/platform";
/** Largest w×h box with the given aspect that fits the container. */
export function useFit(aspect: number) {
@@ -29,10 +31,15 @@ export function Popover(props: {
}) {
const [open, setOpen] = useState(false);
const ref = useRef<HTMLDivElement>(null);
+ // A phone: the menu opens as a sheet along the bottom of the screen, the full width, instead of
+ // next to its button (it would leave the screen on either side).
+ const sheet = isNarrow();
+ const sheetRef = useRef<HTMLDivElement>(null);
useEffect(() => {
if (!open) return;
const onDown = (e: MouseEvent) => {
- if (ref.current && !ref.current.contains(e.target as Node)) setOpen(false);
+ 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);
@@ -47,7 +54,7 @@ export function Popover(props: {
// at most that room and scrolls inside.
const [maxHeight, setMaxHeight] = useState<number>();
useLayoutEffect(() => {
- if (!open || !ref.current) return;
+ if (!open || !ref.current || sheet) return;
const fit = () => {
const r = ref.current?.getBoundingClientRect();
if (!r) return;
@@ -57,7 +64,7 @@ export function Popover(props: {
fit();
window.addEventListener("resize", fit);
return () => window.removeEventListener("resize", fit);
- }, [open, placement]);
+ }, [open, placement, sheet]);
const pos: Record<string, React.CSSProperties> = {
"top-start": { bottom: "calc(100% + 8px)", left: 0 },
"top-end": { bottom: "calc(100% + 8px)", right: 0 },
@@ -67,11 +74,22 @@ export function Popover(props: {
return (
<div ref={ref} style={{ position: "relative" }}>
{props.trigger(open, () => setOpen((o) => !o))}
- {open && (
- <div className={`popover ${props.className ?? ""}`} style={{ ...pos[placement], maxHeight, overflowY: "auto" }}>
- {props.children(() => setOpen(false))}
- </div>
- )}
+ {open &&
+ (sheet ? (
+ createPortal(
+ <>
+ <div className="sheet-scrim" />
+ <div ref={sheetRef} className={`popover sheet ${props.className ?? ""}`}>
+ {props.children(() => setOpen(false))}
+ </div>
+ </>,
+ document.body,
+ )
+ ) : (
+ <div className={`popover ${props.className ?? ""}`} style={{ ...pos[placement], maxHeight, overflowY: "auto" }}>
+ {props.children(() => setOpen(false))}
+ </div>
+ ))}
</div>
);
}
diff --git a/src/styles.css b/src/styles.css
index c50a9e8..da2409a 100644
--- a/src/styles.css
+++ b/src/styles.css
@@ -408,7 +408,7 @@ svg { display: block; flex: none; }
.controls .pill { height: 30px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--border-2); font-size: 12.5px; }
.pill:hover { background: var(--surface); color: var(--text); }
.pill.on { color: var(--text); background: var(--surface); }
-.send { width: 36px; height: 36px; border-radius: 50%; background: var(--invert-bg); color: var(--invert-text); display: grid; place-items: center; box-shadow: 0 6px 16px -6px rgba(13, 13, 13, 0.5); transition: transform 0.2s var(--ease), opacity 0.2s; }
+.send { width: 36px; height: 36px; flex: none; padding: 0; aspect-ratio: 1; border-radius: 50%; background: var(--invert-bg); color: var(--invert-text); display: grid; place-items: center; box-shadow: 0 6px 16px -6px rgba(13, 13, 13, 0.5); transition: transform 0.2s var(--ease), opacity 0.2s; }
.send:hover:not(:disabled) { transform: translateY(-1px); }
.send:disabled { opacity: 0.25; box-shadow: none; }
@@ -992,6 +992,8 @@ kbd { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 6px; display
.side-foot { flex: none; padding: 8px 8px 12px; border-top: 1px solid var(--border); }
.side-item.settings { width: 100%; height: 42px; font-size: 14.5px; gap: 11px; }
+.modal-save { display: none; }
+
/* ---------- phone-sized screens (Kokon in a browser on another device) ---------- */
@media (max-width: 720px) {
.sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 45; background: var(--ground); box-shadow: var(--shadow); padding-top: env(safe-area-inset-top); }
@@ -1013,12 +1015,18 @@ kbd { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 6px; display
.composer-wrap { padding: 0 8px calc(8px + env(safe-area-inset-bottom)); }
.composer { border-radius: 22px; }
/* iOS zooms the page into any field under 16 px */
- textarea, input[type="text"], input[type="password"], input[type="number"], .input, .select { font-size: 16px; }
+ textarea, input[type="text"], input[type="password"], input[type="number"], .input, .select, .prompt { font-size: 16px; }
.modal { width: 100vw; height: 100dvh; border-radius: 0; flex-direction: column; }
.modal-nav { width: auto; flex: none; flex-direction: row; align-items: center; overflow-x: auto; gap: 4px; padding: calc(8px + env(safe-area-inset-top)) 8px 8px; scrollbar-width: none; }
.modal-nav > button { flex: none; white-space: nowrap; }
.modal-nav > span { flex: none !important; }
- .modal-nav > .btn.primary { position: sticky; right: 0; box-shadow: -12px 0 12px var(--ground); }
+ .modal-nav .nav-save { display: none; }
+ .modal-save { display: flex; position: sticky; bottom: calc(-16px - env(safe-area-inset-bottom)); margin: auto -16px calc(-16px - env(safe-area-inset-bottom)); padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--border); }
+ .modal-save .btn { flex: 1; justify-content: center; height: 42px; }
+ /* menus: a sheet along the bottom of the screen (ui.tsx Popover) */
+ .sheet-scrim { position: fixed; inset: 0; z-index: 59; background: rgba(13, 13, 12, 0.3); animation: fade 0.2s ease-out both; }
+ .popover.sheet { position: fixed; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 60; min-width: 0; max-height: min(72dvh, 600px); overflow-y: auto; padding: 8px; border-radius: 20px; }
+ .popover.sheet .opt { padding: 11px 12px; font-size: 15px; }
.modal-body { padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
.path-row { flex-wrap: wrap; }
.gallery-bar { padding: 0 10px 10px; flex-wrap: wrap; }