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",
"version": "0.4.14",
"version": "0.4.15",
"private": true,
"scripts": {
"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
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>
+5 -5
View File
@@ -42,20 +42,20 @@
class="flex flex-row w-full max-w-full lg:divide-x dark:divide-zinc-800
divide-slate-200"
>
<Sidebar>
<Sidebar let:expanded>
<Button
class="hover:bg-slate-200"
class="hover:bg-slate-200 {expanded ? '' : '!p-1.5'}"
href="/"
color="tertiary"
alignment="left"
>
<Icon src={Home} solid size="20" />
Frontpage
<span class:hidden={!expanded}>Frontpage</span>
</Button>
{#if $user}
{#each $user.follows.map((f) => f.community) as follow}
<Button
class="hover:bg-slate-200"
class="hover:bg-slate-200 {expanded ? '' : '!p-1.5'}"
color="tertiary"
alignment="left"
href="/c/{follow.name}@{new URL(follow.actor_id).hostname}"
@@ -66,7 +66,7 @@
width={20}
slot="icon"
/>
{follow.title}
<span class:hidden={!expanded}>{follow.title}</span>
</Button>
{/each}
{/if}
+1 -1
View File
@@ -3,7 +3,7 @@
// @ts-ignore
import { build, files } from '$service-worker'
const version = '0.4.14'
const version = '0.4.15'
const timestamp = new Date().toLocaleString('en')
const worker = self as unknown as ServiceWorkerGlobalScope
const FILES = `cache${timestamp}`