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.

Browser UI on phones: sidebar as a drawer, full-screen Settings, compact top bar, two-column gallery

Gabriele Lozupone58232bc0a52a
diff --git a/src/App.tsx b/src/App.tsx
index 2518c2f..afe9d21 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, configure, setSignedOutHandler } from "./lib/api";
import { native } from "./lib/native";
-import { inBrowser } from "./lib/platform";
+import { inBrowser, isNarrow } from "./lib/platform";
import {
addExampleProjects, closeStarPrompt, dismissToast, getState, initStarPrompt, redoVersion, refreshLoras, refreshStatus, selectItem, setState, startEvents, startTour, submitComposer, toastError, toastInfo, undoVersion, useStore,
} from "./lib/store";
@@ -326,6 +326,7 @@ export default function App() {
return (
<div className="app">
{sidebar && !needsSetup && <Sidebar />}
+ {sidebar && !needsSetup && isNarrow() && <div className="sidebar-scrim" onClick={() => setState({ sidebar: false })} />}
<div className="workspace">
<TopBar />
<div className="main">
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx
index 62cbd78..3d883f9 100644
--- a/src/components/Sidebar.tsx
+++ b/src/components/Sidebar.tsx
@@ -3,6 +3,7 @@ import { useEffect, useState } from "react";
import { urls } from "../lib/api";
import { timeAgo } from "../lib/logic";
import { native } from "../lib/native";
+import { isNarrow } from "../lib/platform";
import { deleteProject, deleteProjects, newProject, renameProject, setState, switchProject, useStore } from "../lib/store";
import { IconButton, NameField } from "./ui";
import { KokonMark } from "./Welcome";
@@ -70,7 +71,14 @@ export function Sidebar() {
};
return (
- <aside className={`sidebar ${selecting ? "selecting" : ""}`}>
+ <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 });
+ }}
+ >
<div className="side-head" data-tauri-drag-region>
<Wordmark />
<IconButton title="Hide sidebar" onClick={() => setState({ sidebar: false })}>
diff --git a/src/lib/platform.ts b/src/lib/platform.ts
index 0723438..960acc4 100644
--- a/src/lib/platform.ts
+++ b/src/lib/platform.ts
@@ -9,5 +9,8 @@ export const isLinux = typeof navigator !== "undefined" && !isMac && /Linux/i.te
export const fileManager = isMac ? "Finder" : isLinux ? "the file manager" : "Explorer";
+/** A phone-sized screen (Kokon in a browser on another device): the sidebar becomes a drawer. Matches styles.css. */
+export const isNarrow = () => typeof window !== "undefined" && !!window.matchMedia?.("(max-width: 720px)").matches;
+
/** The UI runs in a browser, served by kokon-service to another device, not in the desktop app. */
export const inBrowser = typeof window !== "undefined" && !("__TAURI_INTERNALS__" in window);
diff --git a/src/lib/store.ts b/src/lib/store.ts
index 12bd904..88b9f56 100644
--- a/src/lib/store.ts
+++ b/src/lib/store.ts
@@ -5,6 +5,7 @@
// every project is kept as ids in `projects` (persisted) and re-loaded from the service when
// opened again.
+import { isNarrow } from "./platform";
import { useSyncExternalStore } from "react";
import { markFresh } from "../components/Cocoon";
import { api, ApiError, setPrivateInputs, subscribe } from "./api";
@@ -269,6 +270,8 @@ async function hydrate(items: StoredItem[]): Promise<SessionItem[]> {
}
const loadSidebar = () => {
+ // On a phone the sidebar is a drawer over the page: start with it closed.
+ if (isNarrow()) return false;
try {
return localStorage.getItem(SIDEBAR_KEY) !== "0";
} catch {
diff --git a/src/styles.css b/src/styles.css
index 487a8de..c50a9e8 100644
--- a/src/styles.css
+++ b/src/styles.css
@@ -991,3 +991,36 @@ kbd { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 6px; display
/* Settings, fixed at the foot of the sidebar */
.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; }
+
+/* ---------- 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); }
+ .sidebar-scrim { position: fixed; inset: 0; z-index: 44; background: rgba(13, 13, 12, 0.3); animation: fade 0.2s ease-out both; }
+ .side-select, .proj-rm { opacity: 1; }
+ .topbar { padding: env(safe-area-inset-top) 6px 0 8px; gap: 4px; }
+ .toolbar { flex: 0 1 auto; min-width: 0; }
+ .toolbar .status { margin-right: 2px; min-width: 0; max-width: 52vw; }
+ .status > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+ .brand .project-title { padding: 0 4px; }
+ /* the mark without the name, and no keyboard-shortcuts button: room for the project title */
+ .topbar .wordmark { flex: none; font-size: 0; gap: 0; }
+ .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; }
+ .stage-bar .actions { flex-wrap: wrap; justify-content: center; }
+ .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; }
+ .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-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; }
+ .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; padding: 4px 10px 20px; }
+}