feat: add sidebar collapsing at small sizes

This commit is contained in:
Xyphyn committed 2023-10-07 11:37:20 -07:00
1 parent b367f22277
commit b9e74944c8
7 files changed
+37 -24

No files matched your search

+1 -1
View File
@@ -68,7 +68,7 @@
@media (min-width: 768px) {
.content {
grid-template-columns: 1fr 2fr;
grid-template-columns: min-content 2fr;
justify-items: end start;
grid-template-areas: 'sidebar main';
}
@@ -1,5 +1,6 @@
<script lang="ts">
import Avatar from '$lib/components/ui/Avatar.svelte'
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
import type { Community } from 'lemmy-js-client'
import { Button } from 'mono-svelte'
import { flip } from 'svelte/animate'
@@ -14,7 +15,7 @@
class="inline-flex w-full"
animate:flip={{ duration: 500, easing: expoOut }}
>
<Button
<SidebarButton
class="font-normal w-full h-max"
color="tertiary"
alignment="left"
@@ -29,12 +30,12 @@
slot="prefix"
/>
</div>
<div class="flex flex-col max-w-full break-words">
<div class="flex flex-col max-w-full break-words" slot="label">
<span>{follow.title}</span>
<span class="text-xs text-slate-600 dark:text-zinc-400">
{new URL(follow.actor_id).hostname}
</span>
</div>
</Button>
</SidebarButton>
</div>
{/each}
@@ -2,6 +2,7 @@
import { goto } from '$app/navigation'
import { page } from '$app/stores'
import { profile, setUserID, type Profile } from '$lib/auth.js'
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
import ProfileAvatar from '$lib/lemmy/ProfileAvatar.svelte'
import { Button } from 'mono-svelte'
@@ -11,7 +12,7 @@
let switching: boolean = false
</script>
<Button
<SidebarButton
color="tertiary"
alignment="left"
loading={switching}
@@ -35,18 +36,14 @@
? '!bg-slate-100 dark:!bg-zinc-900'
: ''}"
>
<ProfileAvatar
profile={prof}
{index}
selected={$profile?.id == prof.id}
slot="prefix"
/>
<ProfileAvatar profile={prof} {index} selected={$profile?.id == prof.id} />
<span
class="flex flex-col gap-0 {$profile?.id == prof.id ? 'font-semibold' : ''}"
slot="label"
>
{prof.username ?? prof.user?.local_user_view.person.name}
<span class="text-slate-500 dark:text-zinc-400 font-normal text-xs">
{prof.instance}
</span>
</span>
</Button>
</SidebarButton>
+13 -4
View File
@@ -1,6 +1,7 @@
<script lang="ts">
import {
ArrowLeftOnRectangle,
ChevronDoubleRight,
Cog6Tooth,
GlobeAlt,
Home,
@@ -26,9 +27,17 @@
gap-1 max-h-[calc(100svh-4rem)] {$$props.class}"
style={$$props.style}
>
<Button
on:click={() =>
($userSettings.expandSidebar = !$userSettings.expandSidebar)}
size="square-md"
class="flex-shrink-0 lg:hidden"
>
<Icon src={ChevronDoubleRight} size="16" mini />
</Button>
<SidebarButton href="/">
<Icon src={Home} mini={route == '/'} size="20" title="Frontpage" />
<span>Frontpage</span>
<span slot="label">Frontpage</span>
</SidebarButton>
<SidebarButton href="/settings">
<Icon
@@ -37,11 +46,11 @@
size="20"
title="Settings"
/>
<span>Settings</span>
<span slot="label">Settings</span>
</SidebarButton>
<SidebarButton href="/communities">
<Icon mini={route == '/communities'} src={GlobeAlt} size="20" />
<span>Communities</span>
<span slot="label">Communities</span>
</SidebarButton>
{#if $profileData.profiles.length >= 1}
<hr class="border-slate-300 dark:border-zinc-800 my-1" />
@@ -52,7 +61,7 @@
{/each}
<SidebarButton href="/accounts">
<Icon src={UserGroup} mini size="20" />
<span>Accounts</span>
<span slot="label">Accounts</span>
</SidebarButton>
{/if}
<hr class="border-slate-300 dark:border-zinc-800 my-1" />
@@ -1,4 +1,5 @@
<script lang="ts">
import { userSettings } from '$lib/settings.js'
import { Button } from 'mono-svelte'
</script>
@@ -7,7 +8,12 @@
color="tertiary"
alignment="left"
on:click
class="hover:bg-slate-100 font-normal {$$props.class}"
class="hover:bg-slate-100 font-normal {$userSettings.expandSidebar
? ''
: 'max-lg:!p-1 [&>*]:max-lg:!justify-center'} {$$props.class}"
>
<slot />
<div class={$userSettings.expandSidebar ? 'contents' : 'max-lg:hidden'}>
<slot name="label" />
</div>
</Button>