|
1 | 1 | import type { DocHandle } from "@automerge/automerge-repo"; |
| 2 | +import Dialog from "@corvu/dialog"; |
2 | 3 | import { MultiProvider } from "@solid-primitives/context"; |
3 | 4 | import { useNavigate, useParams } from "@solidjs/router"; |
4 | | -import { |
5 | | - type Accessor, |
6 | | - For, |
7 | | - Match, |
8 | | - Switch, |
9 | | - createMemo, |
10 | | - createResource, |
11 | | - useContext, |
12 | | -} from "solid-js"; |
13 | | -import invariant from "tiny-invariant"; |
14 | | - |
15 | 5 | import type { Uuid } from "catlog-wasm"; |
| 6 | +import { type Accessor, Match, Switch, createMemo, createResource, useContext } from "solid-js"; |
| 7 | +import invariant from "tiny-invariant"; |
16 | 8 | import { RPCContext, RepoContext, retrieveDoc } from "../api"; |
17 | 9 | import { IconButton, InlineInput } from "../components"; |
18 | 10 | import { |
@@ -41,10 +33,11 @@ import { BrandedToolbar, HelpButton } from "../page"; |
41 | 33 | import { type TheoryLibrary, TheoryLibraryContext } from "../stdlib"; |
42 | 34 | import type { Theory } from "../theory"; |
43 | 35 | import { type IndexedMap, indexMap } from "../util/indexing"; |
| 36 | +import TheorySelector from "./theory_selector"; |
44 | 37 | import { type ModelDocument, newAnalysisDocument } from "./types"; |
45 | 38 |
|
46 | 39 | import "./model_document_editor.css"; |
47 | | - |
| 40 | +import "./theory_selector.css"; |
48 | 41 | import ChartNetwork from "lucide-solid/icons/chart-network"; |
49 | 42 |
|
50 | 43 | /** A model document "live" for editing. |
@@ -225,26 +218,31 @@ export function ModelPane(props: { |
225 | 218 | placeholder="Untitled" |
226 | 219 | /> |
227 | 220 | </div> |
228 | | - <div class="model-theory"> |
229 | | - <select |
230 | | - required |
231 | | - disabled={doc().notebook.cells.some((cell) => cell.tag === "formal")} |
232 | | - value={doc().theory ?? ""} |
233 | | - onInput={(evt) => { |
234 | | - const id = evt.target.value; |
235 | | - docHandle().change((model) => { |
236 | | - model.theory = id ? id : undefined; |
237 | | - }); |
238 | | - }} |
239 | | - > |
240 | | - <option value="" disabled selected hidden> |
241 | | - Choose a logic |
242 | | - </option> |
243 | | - <For each={Array.from(theories.metadata())}> |
244 | | - {(meta) => <option value={meta.id}>{meta.name}</option>} |
245 | | - </For> |
246 | | - </select> |
247 | | - </div> |
| 221 | + <Dialog |
| 222 | + initialOpen={false} |
| 223 | + modal={true} |
| 224 | + closeOnEscapeKeyDown={true} |
| 225 | + trapFocus={true} |
| 226 | + > |
| 227 | + <div> |
| 228 | + <Dialog.Trigger class="theory-selector"> |
| 229 | + <span> {liveDoc().theory()?.name || "Theory"} </span> |
| 230 | + </Dialog.Trigger> |
| 231 | + </div> |
| 232 | + <Dialog.Portal> |
| 233 | + <div class="overlay"> |
| 234 | + <Dialog.Content class="popup" id="theory-selector-popup"> |
| 235 | + <span> |
| 236 | + <TheorySelector |
| 237 | + docHandle={docHandle} |
| 238 | + theories={theories} |
| 239 | + doc={doc()} |
| 240 | + /> |
| 241 | + </span> |
| 242 | + </Dialog.Content> |
| 243 | + </div> |
| 244 | + </Dialog.Portal> |
| 245 | + </Dialog> |
248 | 246 | </div> |
249 | 247 | <MultiProvider |
250 | 248 | values={[ |
|
0 commit comments