feat: add sidebar collapsing at small sizes
This commit is contained in:
1 parent
b367f22277
commit
b9e74944c8
7 files changed
+37
-24
No files matched your search
@@ -81,13 +81,13 @@
|
|||||||
{#if admins}
|
{#if admins}
|
||||||
<span class="font-bold">Admins</span>
|
<span class="font-bold">Admins</span>
|
||||||
<div
|
<div
|
||||||
class="flex items-center -space-x-1 flex-wrap hover:space-x-1 transition-all
|
class="flex items-center flex-wrap group transition-all
|
||||||
cursor-pointer"
|
cursor-pointer"
|
||||||
>
|
>
|
||||||
{#each admins as admin}
|
{#each admins as admin}
|
||||||
<Popover openOnHover placement="top-start" class="transition-all">
|
<Popover openOnHover placement="top">
|
||||||
<a
|
<a
|
||||||
class="block ring rounded-full ring-slate-50 dark:ring-zinc-950 transition-all"
|
class="block ring rounded-full ring-slate-50 dark:ring-zinc-950 transition-all -mx-0.5 group-hover:mx-0.5"
|
||||||
href="/u/{admin.person.name}@{new URL(admin.person.actor_id)
|
href="/u/{admin.person.name}@{new URL(admin.person.actor_id)
|
||||||
.hostname}"
|
.hostname}"
|
||||||
slot="target"
|
slot="target"
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
|
|
||||||
@media (min-width: 768px) {
|
@media (min-width: 768px) {
|
||||||
.content {
|
.content {
|
||||||
grid-template-columns: 1fr 2fr;
|
grid-template-columns: min-content 2fr;
|
||||||
justify-items: end start;
|
justify-items: end start;
|
||||||
grid-template-areas: 'sidebar main';
|
grid-template-areas: 'sidebar main';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
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 type { Community } from 'lemmy-js-client'
|
||||||
import { Button } from 'mono-svelte'
|
import { Button } from 'mono-svelte'
|
||||||
import { flip } from 'svelte/animate'
|
import { flip } from 'svelte/animate'
|
||||||
@@ -14,7 +15,7 @@
|
|||||||
class="inline-flex w-full"
|
class="inline-flex w-full"
|
||||||
animate:flip={{ duration: 500, easing: expoOut }}
|
animate:flip={{ duration: 500, easing: expoOut }}
|
||||||
>
|
>
|
||||||
<Button
|
<SidebarButton
|
||||||
class="font-normal w-full h-max"
|
class="font-normal w-full h-max"
|
||||||
color="tertiary"
|
color="tertiary"
|
||||||
alignment="left"
|
alignment="left"
|
||||||
@@ -29,12 +30,12 @@
|
|||||||
slot="prefix"
|
slot="prefix"
|
||||||
/>
|
/>
|
||||||
</div>
|
</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>{follow.title}</span>
|
||||||
<span class="text-xs text-slate-600 dark:text-zinc-400">
|
<span class="text-xs text-slate-600 dark:text-zinc-400">
|
||||||
{new URL(follow.actor_id).hostname}
|
{new URL(follow.actor_id).hostname}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</Button>
|
</SidebarButton>
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
import { goto } from '$app/navigation'
|
import { goto } from '$app/navigation'
|
||||||
import { page } from '$app/stores'
|
import { page } from '$app/stores'
|
||||||
import { profile, setUserID, type Profile } from '$lib/auth.js'
|
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 ProfileAvatar from '$lib/lemmy/ProfileAvatar.svelte'
|
||||||
import { Button } from 'mono-svelte'
|
import { Button } from 'mono-svelte'
|
||||||
|
|
||||||
@@ -11,7 +12,7 @@
|
|||||||
let switching: boolean = false
|
let switching: boolean = false
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Button
|
<SidebarButton
|
||||||
color="tertiary"
|
color="tertiary"
|
||||||
alignment="left"
|
alignment="left"
|
||||||
loading={switching}
|
loading={switching}
|
||||||
@@ -35,18 +36,14 @@
|
|||||||
? '!bg-slate-100 dark:!bg-zinc-900'
|
? '!bg-slate-100 dark:!bg-zinc-900'
|
||||||
: ''}"
|
: ''}"
|
||||||
>
|
>
|
||||||
<ProfileAvatar
|
<ProfileAvatar profile={prof} {index} selected={$profile?.id == prof.id} />
|
||||||
profile={prof}
|
|
||||||
{index}
|
|
||||||
selected={$profile?.id == prof.id}
|
|
||||||
slot="prefix"
|
|
||||||
/>
|
|
||||||
<span
|
<span
|
||||||
class="flex flex-col gap-0 {$profile?.id == prof.id ? 'font-semibold' : ''}"
|
class="flex flex-col gap-0 {$profile?.id == prof.id ? 'font-semibold' : ''}"
|
||||||
|
slot="label"
|
||||||
>
|
>
|
||||||
{prof.username ?? prof.user?.local_user_view.person.name}
|
{prof.username ?? prof.user?.local_user_view.person.name}
|
||||||
<span class="text-slate-500 dark:text-zinc-400 font-normal text-xs">
|
<span class="text-slate-500 dark:text-zinc-400 font-normal text-xs">
|
||||||
{prof.instance}
|
{prof.instance}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</Button>
|
</SidebarButton>
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {
|
import {
|
||||||
ArrowLeftOnRectangle,
|
ArrowLeftOnRectangle,
|
||||||
|
ChevronDoubleRight,
|
||||||
Cog6Tooth,
|
Cog6Tooth,
|
||||||
GlobeAlt,
|
GlobeAlt,
|
||||||
Home,
|
Home,
|
||||||
@@ -26,9 +27,17 @@
|
|||||||
gap-1 max-h-[calc(100svh-4rem)] {$$props.class}"
|
gap-1 max-h-[calc(100svh-4rem)] {$$props.class}"
|
||||||
style={$$props.style}
|
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="/">
|
<SidebarButton href="/">
|
||||||
<Icon src={Home} mini={route == '/'} size="20" title="Frontpage" />
|
<Icon src={Home} mini={route == '/'} size="20" title="Frontpage" />
|
||||||
<span>Frontpage</span>
|
<span slot="label">Frontpage</span>
|
||||||
</SidebarButton>
|
</SidebarButton>
|
||||||
<SidebarButton href="/settings">
|
<SidebarButton href="/settings">
|
||||||
<Icon
|
<Icon
|
||||||
@@ -37,11 +46,11 @@
|
|||||||
size="20"
|
size="20"
|
||||||
title="Settings"
|
title="Settings"
|
||||||
/>
|
/>
|
||||||
<span>Settings</span>
|
<span slot="label">Settings</span>
|
||||||
</SidebarButton>
|
</SidebarButton>
|
||||||
<SidebarButton href="/communities">
|
<SidebarButton href="/communities">
|
||||||
<Icon mini={route == '/communities'} src={GlobeAlt} size="20" />
|
<Icon mini={route == '/communities'} src={GlobeAlt} size="20" />
|
||||||
<span>Communities</span>
|
<span slot="label">Communities</span>
|
||||||
</SidebarButton>
|
</SidebarButton>
|
||||||
{#if $profileData.profiles.length >= 1}
|
{#if $profileData.profiles.length >= 1}
|
||||||
<hr class="border-slate-300 dark:border-zinc-800 my-1" />
|
<hr class="border-slate-300 dark:border-zinc-800 my-1" />
|
||||||
@@ -52,7 +61,7 @@
|
|||||||
{/each}
|
{/each}
|
||||||
<SidebarButton href="/accounts">
|
<SidebarButton href="/accounts">
|
||||||
<Icon src={UserGroup} mini size="20" />
|
<Icon src={UserGroup} mini size="20" />
|
||||||
<span>Accounts</span>
|
<span slot="label">Accounts</span>
|
||||||
</SidebarButton>
|
</SidebarButton>
|
||||||
{/if}
|
{/if}
|
||||||
<hr class="border-slate-300 dark:border-zinc-800 my-1" />
|
<hr class="border-slate-300 dark:border-zinc-800 my-1" />
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { userSettings } from '$lib/settings.js'
|
||||||
import { Button } from 'mono-svelte'
|
import { Button } from 'mono-svelte'
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -7,7 +8,12 @@
|
|||||||
color="tertiary"
|
color="tertiary"
|
||||||
alignment="left"
|
alignment="left"
|
||||||
on:click
|
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 />
|
<slot />
|
||||||
|
<div class={$userSettings.expandSidebar ? 'contents' : 'max-lg:hidden'}>
|
||||||
|
<slot name="label" />
|
||||||
|
</div>
|
||||||
</Button>
|
</Button>
|
||||||
@@ -3043,10 +3043,10 @@ mlly@^1.2.0, mlly@^1.4.0:
|
|||||||
pkg-types "^1.0.3"
|
pkg-types "^1.0.3"
|
||||||
ufo "^1.1.2"
|
ufo "^1.1.2"
|
||||||
|
|
||||||
mono-svelte@^1.2.5:
|
mono-svelte@^1.3.1:
|
||||||
version "1.2.5"
|
version "1.3.1"
|
||||||
resolved "https://registry.yarnpkg.com/mono-svelte/-/mono-svelte-1.2.5.tgz#3abd04c51aed26c0daca572904ef6fea16f24ed3"
|
resolved "https://registry.yarnpkg.com/mono-svelte/-/mono-svelte-1.3.1.tgz#182355ecf56c18b9f2808c085b71e39530dfc7f7"
|
||||||
integrity sha512-eYr1evL3nFyad1BgHVVy9eIKWNJwud55uBipTCMwhj/rueZzsNswNujjXJgConQEo4wXxZ/hPHRrFZPmNd+W1w==
|
integrity sha512-GBNHEUchH2WuYb29f3SKdFj7CeqkIXLykL1g7M41CoR4hSyaMOxWtTmR7owZHOTvQ0ABZ7e76Qa0U945A/dcqg==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@floating-ui/core" "^1.5.0"
|
"@floating-ui/core" "^1.5.0"
|
||||||
svelte-floating-ui "^1.5.3"
|
svelte-floating-ui "^1.5.3"
|
||||||
|
|||||||
Reference in new issue
Block a user