feat: add sidebar collapsing

This commit is contained in:
Xyphyn committed 2023-07-31 12:53:57 -07:00
1 parent 13b5bcd581
commit 715c8f878b
4 files changed
+29 -9

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "photon-lemmy", "name": "photon-lemmy",
"version": "0.4.14", "version": "0.4.15",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "vite dev", "dev": "vite dev",
+22 -2
View File
@@ -1,6 +1,26 @@
<script lang="ts">
import { ChevronDoubleLeft, Icon } from 'svelte-hero-icons'
import Button from '../input/Button.svelte'
let expanded = true
</script>
<nav <nav
class="hidden xl:flex flex-col pl-4 pr-4 py-4 overflow-auto sticky top-16 bottom-0 class="hidden xl:flex flex-col pl-4 pr-4 py-4 overflow-auto sticky top-16 bottom-0
flex-1 gap-1 max-h-[calc(100vh-4rem)] w-full bg-slate-100 dark:bg-black" gap-1 max-h-[calc(100vh-4rem)] w-full bg-slate-100 dark:bg-black"
class:flex-1={expanded}
class:w-max={!expanded}
> >
<slot /> <Button
on:click={() => (expanded = !expanded)}
class="w-max !p-2 hover:bg-slate-200"
>
<Icon
src={ChevronDoubleLeft}
mini
size="16"
class="transition-transform {expanded ? '' : 'rotate-180'}"
/>
</Button>
<slot {expanded} />
</nav> </nav>
+5 -5
View File
@@ -42,20 +42,20 @@
class="flex flex-row w-full max-w-full lg:divide-x dark:divide-zinc-800 class="flex flex-row w-full max-w-full lg:divide-x dark:divide-zinc-800
divide-slate-200" divide-slate-200"
> >
<Sidebar> <Sidebar let:expanded>
<Button <Button
class="hover:bg-slate-200" class="hover:bg-slate-200 {expanded ? '' : '!p-1.5'}"
href="/" href="/"
color="tertiary" color="tertiary"
alignment="left" alignment="left"
> >
<Icon src={Home} solid size="20" /> <Icon src={Home} solid size="20" />
Frontpage <span class:hidden={!expanded}>Frontpage</span>
</Button> </Button>
{#if $user} {#if $user}
{#each $user.follows.map((f) => f.community) as follow} {#each $user.follows.map((f) => f.community) as follow}
<Button <Button
class="hover:bg-slate-200" class="hover:bg-slate-200 {expanded ? '' : '!p-1.5'}"
color="tertiary" color="tertiary"
alignment="left" alignment="left"
href="/c/{follow.name}@{new URL(follow.actor_id).hostname}" href="/c/{follow.name}@{new URL(follow.actor_id).hostname}"
@@ -66,7 +66,7 @@
width={20} width={20}
slot="icon" slot="icon"
/> />
{follow.title} <span class:hidden={!expanded}>{follow.title}</span>
</Button> </Button>
{/each} {/each}
{/if} {/if}
+1 -1
View File
@@ -3,7 +3,7 @@
// @ts-ignore // @ts-ignore
import { build, files } from '$service-worker' import { build, files } from '$service-worker'
const version = '0.4.14' const version = '0.4.15'
const timestamp = new Date().toLocaleString('en') const timestamp = new Date().toLocaleString('en')
const worker = self as unknown as ServiceWorkerGlobalScope const worker = self as unknown as ServiceWorkerGlobalScope
const FILES = `cache${timestamp}` const FILES = `cache${timestamp}`