import { useApp } from "../app-state"; export function TopBar() { const { state, dispatch, lsp } = useApp(); const lspChip = () => { switch (lsp.status) { case "ready": return ( LSP ); case "connecting": return ( LSP ); case "error": return ( LSP ); default: return null; } }; const previewChip = () => { // No preview without an open file (tinymist previews a document). if (!state.openFile) return null; if (lsp.previewReady) { return ( Preview ); } if (lsp.status === "ready") { return ( Preview · starting ); } return null; }; return ( typst-leaf · {state.currentProject ? ( <> {state.currentProject} {state.openFile && ( <> / {state.openFile} {state.fileDirty && *} > )} {lspChip()} {previewChip()} { document.dispatchEvent(new CustomEvent("typst-leaf:save")); }} disabled={!state.openFile} className="px-3 py-1 text-sm rounded bg-emerald-600 hover:bg-emerald-700 text-white disabled:opacity-40 disabled:cursor-not-allowed" > Save dispatch({ type: "setActivePanel", panel: state.activePanel === "settings" ? "files" : "settings" })} className={`p-1.5 rounded-md ${state.activePanel === "settings" ? "text-emerald-700 bg-emerald-50" : "text-zinc-500 hover:bg-stone-100"}`} title="Settings" > > ) : ( Select a project to begin )} ); }