Skip to content

Commit

Permalink
toggle sections
Browse files Browse the repository at this point in the history
  • Loading branch information
mcnuttandrew committed Jan 24, 2024
1 parent 0909446 commit 6d969f4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 18 deletions.
39 changes: 25 additions & 14 deletions src/content-modules/LeftPanel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,33 @@
</section>

<section class="flex flex-col flex-1 overflow-auto p-2">
<Nav
tabs={["saved-pals", "controls"]}
isTabSelected={(x) => $configStore.leftRoute === x}
selectTab={(x) => {
// @ts-ignore
configStore.setLeftRoute(x);
}}
className="w-full"
/>

{#if $configStore.leftRoute === "saved-pals"}
<SavedPals />
{/if}
{#if $configStore.leftRoute === "controls"}
<div class="flex justify-between">
<div class="font-bold">Controls</div>
<Nav
tabs={["open", "close"]}
isTabSelected={(x) =>
(x === "open" && $configStore.controlsOpen) ||
(x === "close" && !$configStore.controlsOpen)}
selectTab={(x) => configStore.setControlsOpen(x === "open")}
/>
</div>
{#if $configStore.controlsOpen}
<Controls />
{/if}
<div class="w-full border-t-2 border-black my-6"></div>
<div class="flex justify-between">
<div class="font-bold">Saved Pals</div>
<Nav
tabs={["open", "close"]}
isTabSelected={(x) =>
(x === "open" && $configStore.savedPalsOpen) ||
(x === "close" && !$configStore.savedPalsOpen)}
selectTab={(x) => configStore.setSavedPalsOpen(x === "open")}
/>
</div>
{#if $configStore.savedPalsOpen}
<SavedPals />
{/if}
</section>
</div>

Expand Down
12 changes: 8 additions & 4 deletions src/stores/config-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { writable } from "svelte/store";

interface StoreData {
route: "examples" | "compare" | "eval";
leftRoute: "controls" | "saved-pals";
controlsOpen: boolean;
savedPalsOpen: boolean;
comparePal: string | undefined;
colorSim: "deuteranopia" | "protanopia" | "tritanopia" | "none";
includeQuotes: boolean;
Expand All @@ -16,7 +17,8 @@ interface StoreData {

const InitialStore: StoreData = {
route: "examples",
leftRoute: "controls",
controlsOpen: false,
savedPalsOpen: true,
comparePal: undefined,
colorSim: "none",
includeQuotes: false,
Expand Down Expand Up @@ -67,8 +69,10 @@ function createStore() {
persist((old) => ({ ...old, showColorBackground: n })),
setTooltipXY: (xy: StoreData["tooltipXY"]) =>
persist((old) => ({ ...old, tooltipXY: xy })),
setLeftRoute: (route: StoreData["leftRoute"]) =>
persist((old) => ({ ...old, leftRoute: route })),
setControlsOpen: (n: StoreData["controlsOpen"]) =>
persist((old) => ({ ...old, controlsOpen: n })),
setSavedPalsOpen: (n: StoreData["savedPalsOpen"]) =>
persist((old) => ({ ...old, savedPalsOpen: n })),
};
}

Expand Down

0 comments on commit 6d969f4

Please sign in to comment.