mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 04:57:00 +01:00
45 lines
1.6 KiB
TypeScript
45 lines
1.6 KiB
TypeScript
import * as React from "react";
|
|
import { createRoot } from "react-dom/client";
|
|
import { KnowledgeMap } from "@/components/memory/KnowledgeMap";
|
|
import { KnowledgeMap as MapView, type KnowledgeMapControls } from "@bitbaum/knowledge-map/react";
|
|
import { List, ListRow } from "@/components/ui/list-row";
|
|
import { Segmented } from "@/components/ui/segmented";
|
|
import { MAP_FIXTURE, BUSY_MAP } from "./knowledge-map.fixture";
|
|
window.fetch = async () =>
|
|
new Response(JSON.stringify({ ok: true }), { headers: { "content-type": "application/json" } });
|
|
const params = new URLSearchParams(window.location.search);
|
|
const empty = params.has("empty");
|
|
const fixture = params.has("busy") ? BUSY_MAP : MAP_FIXTURE;
|
|
const workspace = params.has("workspace");
|
|
const workspaceControls: KnowledgeMapControls = {
|
|
List,
|
|
ListRow,
|
|
Segmented,
|
|
Link: (props) => <a {...props} />,
|
|
SearchField: ({ value, onChange }) => (
|
|
<input
|
|
aria-label="Search workspace"
|
|
value={value}
|
|
onChange={(event) => onChange(event.target.value)}
|
|
/>
|
|
),
|
|
};
|
|
createRoot(document.getElementById("root")!).render(
|
|
<main className="app-page max-w-7xl">
|
|
{workspace ? (
|
|
<MapView
|
|
map={{ ...MAP_FIXTURE, visibility: "workspace" }}
|
|
controls={workspaceControls}
|
|
lenses={[
|
|
{ id: "package", label: "Tools" },
|
|
{ id: "all", label: "Everything" },
|
|
]}
|
|
emptyState={<p>No shared records yet.</p>}
|
|
selectedActions={(node) => <p>Review {node.name}</p>}
|
|
/>
|
|
) : (
|
|
<KnowledgeMap map={empty ? { ...MAP_FIXTURE, nodes: [], edges: [] } : fixture} />
|
|
)}
|
|
</main>,
|
|
);
|