[docs] Refactor sidebar to have it pop out on mobile

This commit is contained in:
Ryan Gossiaux
2022-03-02 13:30:49 -08:00
parent fbb6ad9ded
commit 0b9d4823e8
4 changed files with 134 additions and 44 deletions

View File

@@ -1,30 +1,9 @@
<script lang="ts">
import TableOfContents from "./_TableOfContents.svelte";
import { page } from "$app/stores";
import Sidebar from "./_Sidebar.svelte";
let el: HTMLElement | null = null;
$: isHome = $page.path.endsWith("docs");
$: base = isHome ? "docs/" : "";
$: pages = [
{ url: "../docs", text: "Home" },
{ url: `${base}general-concepts`, text: "General concepts" },
{ url: `${base}tailwind-ui`, text: "Use with Tailwind UI" },
{ url: `${base}version-history`, text: "Version history" },
];
$: components = [
{ url: `${base}dialog`, text: "Dialog" },
{ url: `${base}disclosure`, text: "Disclosure" },
{ url: `${base}listbox`, text: "Listbox" },
{ url: `${base}menu`, text: "Menu" },
{ url: `${base}popover`, text: "Popover" },
{ url: `${base}radio-group`, text: "Radio Group" },
{ url: `${base}switch`, text: "Switch" },
{ url: `${base}tabs`, text: "Tabs" },
{ url: `${base}transition`, text: "Transition" },
];
</script>
<svelte:head>
@@ -33,25 +12,11 @@
<div class="flex">
<div class="w-52 min-w-fit hidden md:block flex-shrink-0">
<nav title="Pages" class="sticky top-20 ml-6 flex flex-col">
{#each pages as p (p.url)}
<a
href={p.url}
class:font-bold={$page.path.includes(p.url)}
class="py-1 hover:decoration-stone-400 hover:underline">{p.text}</a
>
{/each}
<hr class="w-24 my-4" />
{#each components as component (component.url)}
<a
href={component.url}
class:font-bold={$page.path.includes(component.url)}
class="py-1 hover:decoration-stone-400 hover:underline"
>{component.text}</a
>
{/each}
</nav>
<div class="sticky top-20">
<Sidebar />
</div>
</div>
<article class="prose max-w-3xl min-w-0 mt-5 px-6 pb-8" bind:this={el}>
<slot />
</article>