import { COVERS, DEFAULT_FOLDERS } from "./constants.jsx"; import { I } from "./icons.jsx"; import { FONT_UI } from "./theme"; const SYNC_LABELS = { synced: "All synced", syncing: "Syncing...", offline: "Offline mode", pending: "Changes pending", }; const syncColor = (status, T) => { if (status === "synced") return T.success; if (status === "syncing" || status === "pending") return T.warning; if (status === "offline") return T.muted; return T.danger; }; const iconButton = (T) => ({ display: "flex", alignItems: "center", justifyContent: "center", width: 32, height: 32, borderRadius: 8, border: "none", background: "transparent", cursor: "pointer", color: T.muted, }); const folderButton = (T, active) => ({ display: "flex", alignItems: "center", gap: 10, width: "100%", padding: "8px 12px", borderRadius: 10, border: "none", cursor: "pointer", fontSize: 13, fontWeight: 500, textAlign: "left", background: active ? T.sidebarActive : "transparent", color: active ? T.accentText : T.textSec, }); const countBadge = (T, color) => ({ marginLeft: "auto", fontSize: 11, color, background: color === T.danger ? T.danger + "15" : T.accentSoft, padding: "2px 7px", borderRadius: 10, }); /** * Navigation rail: search, the built-in views, and the notebook list. * * On a phone it becomes a full-screen overlay; `onClose` is what the backdrop * and every navigation action call so it does not stay in the way. */ export function Sidebar({ T, dark, onToggleDark, isMobile, open, onClose, searchQuery, onSearchChange, activeFolder, onSelectFolder, notebooks, activeNotes, trashedCount, onNewNotebook, onOpenAccount, onNotebookContextMenu, dnd, canInstall, onInstall, syncStatus, online, }) { const notesIn = (nbId) => activeNotes.filter((n) => n.folderId === nbId).length; return (
{isMobile && open && (
)}
✏️
InkNote
{I.search} onSearchChange(e.target.value)} placeholder="Search notes..." style={{ border: "none", background: "transparent", outline: "none", flex: 1, color: T.text, fontSize: 13, fontFamily: FONT_UI, }} />
{DEFAULT_FOLDERS.map((f) => ( ))}
Notebooks
{notebooks.map((nb) => (
dnd.onDragStart(e, nb.id)} onDragOver={(e) => dnd.onDragOver(e, nb.id)} onDrop={(e) => dnd.onDrop(e, nb.id)} onDragEnd={dnd.onDragEnd} onContextMenu={(e) => onNotebookContextMenu(e, nb)} style={{ display: "flex", alignItems: "center", borderRadius: 10, transition: "all .15s", background: dnd.overId === nb.id ? T.accentSoft : activeFolder === nb.id ? T.sidebarActive : "transparent", borderTop: dnd.overId === nb.id ? `2px solid ${T.accent}` : "2px solid transparent", }} > {!isMobile && ( {I.grip} )}
))}
{canInstall && ( )}
● {SYNC_LABELS[syncStatus] || "Sync error"} {!online && ( offline )}
); }