Skip to content

Commit

Permalink
allow sidebar toggle via fab
Browse files Browse the repository at this point in the history
  • Loading branch information
thoughtspile committed Jun 7, 2024
1 parent d1b6ff8 commit 7f6c66c
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/app/Workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ type Modals = "analysis" | "charts";

export function Workspace(props: { table: ColumnTable }) {
const [modalStack, setModalStack] = createSignal<Modals[]>([]);
const openModal = (m: Modals) =>
setModalStack(
modalStack().includes(m) ? modalStack() : [...modalStack(), m],
);
const hasModal = (m: Modals) => modalStack().includes(m);
const closeModal = (m: Modals) =>
setModalStack(modalStack().filter((t) => t !== m));
const toggleModal = (m: Modals) =>
hasModal(m) ? closeModal(m) : setModalStack([...modalStack(), m]);
const [pipeline, setPipeline] = createSignal(createPipeline(props.table));

function onKey(e: KeyboardEvent) {
Expand Down Expand Up @@ -54,24 +53,24 @@ export function Workspace(props: { table: ColumnTable }) {
<ImportFab />
<Export table={pipeline().output} />
<Fab
onClick={() => openModal("charts")}
onClick={() => toggleModal("charts")}
icon={<FaSolidChartSimple />}
/>
<Fab
primary
onClick={() => openModal("analysis")}
onClick={() => toggleModal("analysis")}
icon={<FaSolidMagnifyingGlass />}
/>
</FabContainer>
<AnalysisPanel
pipeline={pipeline()}
update={setPipeline}
onClose={() => closeModal("analysis")}
visible={modalStack().includes("analysis")}
visible={hasModal("analysis")}
/>
<ChartsPanel
table={pipeline().output}
visible={modalStack().includes("charts")}
visible={hasModal("charts")}
onClose={() => closeModal("charts")}
/>
</div>
Expand Down

0 comments on commit 7f6c66c

Please sign in to comment.