design: restructure andd redesign sidebar

This commit is contained in:
James Xylight committed 2025-08-23 14:59:35 -07:00
1 parent 0b3c1f7856
commit 0247d6dc4d
24 files changed
+281 -353

No files matched your search

+10 -32
View File
@@ -10,8 +10,7 @@
import Link from '../input/Link.svelte'
import Expandable from '../ui/Expandable.svelte'
import LabelStat from '../ui/LabelStat.svelte'
import CommonList from '../ui/layout/CommonList.svelte'
import SidebarButton from '../ui/sidebar/SidebarButton.svelte'
import ItemList from './generic/ItemList.svelte'
import { optimizeImageURL } from './post/helpers'
interface Props {
@@ -115,36 +114,15 @@
{$t('cards.site.admins')}
</span>
{/snippet}
<CommonList
animate={false}
size="xs"
items={admins}
class="px-1 py-0.5"
>
{#snippet item(admin)}
<SidebarButton
class="font-normal w-full h-max"
color="none"
alignment="left"
href={userLink(admin.person)}
>
{#snippet customIcon()}
<Avatar
url={admin.person.avatar}
alt={admin.person.name}
width={28}
/>{/snippet}
{#snippet label()}
<div class="flex flex-col max-w-full break-words">
<span>{admin.person.display_name ?? admin.person.name}</span>
<span class="text-xs text-slate-600 dark:text-zinc-400">
{new URL(admin.person.actor_id).hostname}
</span>
</div>
{/snippet}
</SidebarButton>
{/snippet}
</CommonList>
<ItemList
items={admins.map(i => ({
id: i.person.id,
name: i.person.display_name || i.person.name,
url: userLink(i.person),
avatar: i.person.avatar,
instance: new URL(i.person.actor_id).hostname,
}))}
/>
</Expandable>
{/if}
@@ -76,8 +76,6 @@
import Entity from '$lib/components/ui/Entity.svelte'
import Expandable from '$lib/components/ui/Expandable.svelte'
import LabelStat from '$lib/components/ui/LabelStat.svelte'
import CommonList from '$lib/components/ui/layout/CommonList.svelte'
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
import { t } from '$lib/i18n/translations'
import { client, getClient } from '$lib/lemmy.svelte.js'
import { errorMessage } from '$lib/lemmy/error'
@@ -107,6 +105,7 @@
NoSymbol,
Plus,
} from 'svelte-hero-icons'
import ItemList from '../generic/ItemList.svelte'
let loading = $state({
blocking: false,
@@ -214,40 +213,15 @@
{$t('cards.community.moderators')}
</span>
{/snippet}
<CommonList
animate={false}
size="xs"
items={moderators}
class="px-1 py-0.5"
>
{#snippet item(moderator)}
<SidebarButton
class="font-normal w-full h-max"
color="none"
alignment="left"
href={userLink(moderator.moderator)}
>
{#snippet customIcon()}
<Avatar
url={moderator.moderator.avatar}
alt={moderator.moderator.name}
width={28}
/>
{/snippet}
{#snippet label()}
<div class="flex flex-col max-w-full break-words">
<span>
{moderator.moderator.display_name ??
moderator.moderator.name}
</span>
<span class="text-xs text-slate-600 dark:text-zinc-400">
{new URL(moderator.moderator.actor_id).hostname}
</span>
</div>
{/snippet}
</SidebarButton>
{/snippet}
</CommonList>
<ItemList
items={moderators.map(i => ({
id: i.moderator.id,
name: i.moderator.display_name || i.moderator.name,
url: userLink(i.moderator),
avatar: i.moderator.avatar,
instance: new URL(i.moderator.actor_id).hostname,
}))}
/>
</Expandable>
{/if}
</div>
@@ -31,8 +31,6 @@
import ItemList from '../generic/ItemList.svelte'
import { amMod, isAdmin } from '../moderation/moderation'
import { block, blockInstance, purgeCommunity } from './CommunityCard.svelte'
import CommonList from '$lib/components/ui/layout/CommonList.svelte'
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
interface Props {
community: Community
@@ -2,8 +2,6 @@
import Avatar from '$lib/components/ui/Avatar.svelte'
import CommonList from '$lib/components/ui/layout/CommonList.svelte'
import { Button } from 'mono-svelte'
import { flip } from 'svelte/animate'
import { expoOut } from 'svelte/easing'
interface Props {
items: {
@@ -18,7 +16,7 @@
let { items }: Props = $props()
</script>
<CommonList animate={false} size="xs" {items}>
<CommonList animate={false} class="px-1 py-0.5" size="xs" {items}>
{#snippet item(item)}
<Button
class="font-normal w-full h-max block"
@@ -94,7 +94,7 @@
buttonColor.secondary,
'rounded-full h-full font-medium flex items-center *:p-2 relative',
'hover:bg-white dark:hover:bg-zinc-900 overflow-hidden transition-colors shrink-0',
'text-inherit! divide-x divide-slate-200 dark:divide-zinc-800 shadow-xs',
'text-inherit! divide-x divide-slate-200 dark:divide-zinc-800',
loading && 'animate-pulse opacity-75 pointer-events-none',
voteRatio < 85 && settings.voteRatioBar && 'vote-ratio',
]}
@@ -89,8 +89,6 @@
bind:score={post.counts.score}
bind:upvotes={post.counts.upvotes}
bind:downvotes={post.counts.downvotes}
showCounts={profile.current?.user?.local_user_view?.local_user
?.show_scores ?? true}
/>
<Button
@@ -190,7 +190,7 @@
{:else}
<VirtualList
id="feed"
class="divide-y-2 -mx-3 sm:-mx-6 divide-slate-200 dark:divide-zinc-900"
class="divide-y-2 -mx-3 sm:-mx-6 divide-slate-100 dark:divide-zinc-900"
items={posts}
{initialOffset}
overscan={3}
@@ -35,7 +35,6 @@
class={[
'flex flex-col-reverse sm:flex-row overflow-hidden gap-4 embed-card z-0 relative',
'dark:bg-zinc-950 group-hover/link:bg-slate-50 dark:group-hover/link:bg-zinc-900 transition-colors',
'shadow-xs',
]}
rounding="2xl"
element="article"
@@ -2,6 +2,7 @@
import type { ClassValue } from 'svelte/elements'
const sizes = {
xs: 'text-xs px-3 mt-3 mb-1',
sm: 'text-sm',
md: 'text-base',
lg: 'text-lg',
+1 -1
View File
@@ -44,7 +44,7 @@
<div class="absolute inset-0 h-96 overflow-x-hidden -z-10">
<img
src={banner || avatar}
class="w-full h-48 blur-3xl"
class="w-full h-64 object-cover blur-3xl opacity-30 dark:opacity-30"
height="192"
alt="User banner"
/>
+1 -1
View File
@@ -55,7 +55,7 @@
</div>
<div class={['content flex-1', settings.newWidth && 'limit-width']}>
{@render sidebar?.({
class: `hidden md:flex sticky top-0 lg:top-16 left-0 h-max bg-slate-100 dark:bg-zinc-950 z-40 max-h-screen`,
class: `hidden md:flex sticky top-0 lg:top-16 left-0 h-max bg-slate-100 dark:bg-zinc-950 z-40 max-h-[calc(100vh-4rem)] min-h-[calc(100vh-4rem)]`,
style: 'grid-area: sidebar; width: 100% !important;',
})}
{@render main?.({
@@ -29,8 +29,8 @@
class={[
pageHeader &&
`w-[calc(100%+1.5rem)] sm:w-[calc(100%+3rem)]
bg-slate-100 dark:bg-zinc-950 -mx-3 sm:-mx-6 sm:px-6 sm:pb-6 px-4 pb-4 -mt-24 pt-24
border-b border-slate-200/50 dark:border-zinc-900 margin z-20`,
bg-slate-100 dark:bg-zinc-950 -mx-3 sm:-mx-6 sm:px-6 sm:pb-6 px-4 pb-4 -mt-64 pt-64
border-b border-slate-200 dark:border-zinc-900 margin z-0`,
]}
{style}
>
@@ -27,7 +27,7 @@
</script>
<nav
class="flex flex-row items-center gap-x-8 gap-y-4 p-1 justify-center sm:justify-start my-2 sm:mt-0 flex-wrap"
class="flex flex-row items-center gap-x-8 gap-y-4 p-1 justify-center sm:justify-start my-2 sm:mt-0 flex-wrap z-20"
>
{#each routes as route (route.href)}
{@const selected = isSelected(
+183 -175
View File
@@ -1,25 +1,35 @@
<script lang="ts">
import { goto } from '$app/navigation'
import { page } from '$app/state'
import { notifications, profile } from '$lib/auth.svelte.js'
import ItemList from '$lib/components/lemmy/generic/ItemList.svelte'
import Expandable from '$lib/components/ui/Expandable.svelte'
import ProfileButton from '$lib/components/ui/sidebar/ProfileButton.svelte'
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
import { t } from '$lib/i18n/translations'
import { communityLink } from '$lib/lemmy/generic'
import { settings } from '$lib/settings.svelte.js'
import { Badge } from 'mono-svelte'
import { Badge, Button, Menu, MenuButton, Option, Select } from 'mono-svelte'
import {
ArrowLeftOnRectangle,
Bookmark,
CheckCircle,
ChevronUpDown,
Cog6Tooth,
ComputerDesktop,
Icon,
Identification,
Inbox,
Moon,
QuestionMarkCircle,
Sun,
Swatch,
UserCircle,
UserGroup,
} from 'svelte-hero-icons'
import type { ClassValue } from 'svelte/elements'
import Avatar from '../Avatar.svelte'
import EndPlaceholder from '../EndPlaceholder.svelte'
import CommonList from '../layout/CommonList.svelte'
import { theme } from '$lib/ui/colors.svelte'
interface Props {
style?: string
@@ -30,201 +40,199 @@
</script>
<nav class={['flex flex-col overflow-auto gap-1', clazz]} {style}>
<Menu placement="bottom">
{#snippet target()}
<Button
color="tertiary"
alignment="left"
size="md"
class="flex flex-row gap-2 items-center"
>
{#snippet prefix()}
<Avatar
url={profile.current.avatar}
alt={profile.current.username}
width={24}
/>
{/snippet}
<div class="flex-1">
<div class="font-medium">{profile.current.username}</div>
<div class="text-xs text-slate-500 dark:text-zinc-500">
{profile.current.instance}
</div>
</div>
{#snippet suffix()}
<Icon
src={ChevronUpDown}
size="16"
micro
class="block justify-self-end"
/>
{/snippet}
</Button>
{/snippet}
{#each profile.meta.profiles as p}
<MenuButton
onclick={() => {
profile.meta.profile = p.id
goto(page.url, {
invalidateAll: true,
})
}}
>
{#snippet prefix()}
<Avatar url={p.avatar} alt={p.username} width={24} />
{/snippet}
<div>
<div class="font-medium text-sm">{p.username}</div>
<div class="text-xs text-slate-500 dark:text-zinc-500">
{p.instance}
</div>
</div>
{#if profile.meta.profile == p.id}
<Icon
src={CheckCircle}
class="text-primary-900 dark:text-primary-100 ml-auto"
size="16"
micro
/>
{/if}
{#if !p.jwt}
<Badge color="gray-subtle" class="ml-auto p-1!">
<Icon src={QuestionMarkCircle} size="16" micro />
</Badge>
{/if}
</MenuButton>
{/each}
<MenuButton href="/accounts">
{#snippet prefix()}
<Icon src={UserGroup} size="16" micro />
{/snippet}
{$t('account.accounts')}
</MenuButton>
</Menu>
<EndPlaceholder size="xs">{$t('profile.profile')}</EndPlaceholder>
{#if profile.current?.jwt}
<SidebarButton icon={UserCircle} href="/profile">
{#snippet label()}
<span>
{$t('profile.profile')}
</span>
{/snippet}
</SidebarButton>
<SidebarButton icon={Inbox} href="/inbox">
{#snippet label()}
<span class="flex items-center gap-2">
{$t('profile.inbox')}
{#if $notifications.inbox}
<Badge
class="min-w-5 h-5 p-0! px-0.5 grid place-items-center ml-auto"
color="red-subtle"
>
{$notifications.inbox > 99 ? '∞' : $notifications.inbox}
</Badge>
{/if}
</span>
{/snippet}
</SidebarButton>
<SidebarButton icon={Bookmark} href="/saved">
{#snippet label()}
<span>{$t('profile.saved')}</span>
{/snippet}
<SidebarButton
icon={UserCircle}
href="/profile"
label={$t('profile.profile')}
/>
<SidebarButton icon={Inbox} href="/inbox" label={$t('profile.inbox')}>
{#if $notifications.inbox}
<Badge
class="min-w-5 h-5 p-0! px-0.5 grid place-items-center ml-auto"
color="red-subtle"
>
{$notifications.inbox > 99 ? '∞' : $notifications.inbox}
</Badge>
{/if}
</SidebarButton>
<SidebarButton icon={Bookmark} href="/saved" label={$t('profile.saved')} />
{:else}
<SidebarButton
href="/login"
title={$t('account.login')}
label={$t('account.login')}
icon={ArrowLeftOnRectangle}
>
{#snippet label()}
<span>{$t('account.login')}</span>
{/snippet}
</SidebarButton>
/>
<SidebarButton
href="/signup"
title={$t('account.signup')}
label={$t('account.signup')}
icon={Identification}
>
{#snippet label()}
<span>{$t('account.signup')}</span>
{/snippet}
</SidebarButton>
/>
<SidebarButton
href="/settings"
title={$t('nav.menu.settings')}
icon={Cog6Tooth}
>
{#snippet label()}
<span>{$t('nav.menu.settings')}</span>
{/snippet}
</SidebarButton>
href="/accounts"
title={$t('accounts.accounts')}
icon={UserGroup}
/>
{/if}
{#if profile.meta.profiles.length >= 1}
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
<Expandable
class="max-w-full min-w-0 w-full"
bind:open={settings.expand.accounts}
>
{#snippet title()}
<span class="px-2 py-1 w-full">
<EndPlaceholder border={false}>
{$t('account.accounts')}
{#snippet action()}
<span class="dark:text-white text-black">
{profile.meta.profiles.length}
</span>
{/snippet}
</EndPlaceholder>
</span>
{/snippet}
<CommonList
size="xs"
animate={false}
items={profile.meta.profiles}
class="px-1 py-0.5"
selected={prof => prof.id == profile.meta.profile}
<EndPlaceholder size="xs">{$t('nav.menu.app')}</EndPlaceholder>
<SidebarButton
href="/settings"
label={$t('nav.menu.settings')}
icon={Cog6Tooth}
/>
<Select bind:value={theme.colorScheme} size="sm">
{#snippet target()}
<SidebarButton
label={$t('nav.menu.colorscheme.label')}
icon={theme.colorScheme == 'system'
? ComputerDesktop
: theme.colorScheme == 'light'
? Sun
: Moon}
class=" w-full"
>
{#snippet item(prof, index)}
<ProfileButton {index} {prof} />
{/snippet}
<li class="xs px-1 py-0.5">
<SidebarButton href="/accounts" icon={UserGroup}>
{$t('account.accounts')}
</SidebarButton>
</li>
</CommonList>
</Expandable>
{/if}
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
<Option value="system" class="hidden" icon={ComputerDesktop}>
{$t('nav.menu.colorscheme.system')}
</Option>
<Option value="light" class="hidden" icon={Sun}>
{$t('nav.menu.colorscheme.light')}
</Option>
<Option value="dark" class="hidden" icon={Moon}>
{$t('nav.menu.colorscheme.dark')}
</Option>
</SidebarButton>
{/snippet}
</Select>
<SidebarButton href="/theme" label={$t('nav.menu.theme')} icon={Swatch} />
{#if profile.current?.user}
{#if profile.current?.user.moderates.length > 0}
<Expandable
class="max-w-full min-w-0 w-full"
bind:open={settings.expand.moderates}
>
<EndPlaceholder size="xs">{$t('content.communities')}</EndPlaceholder>
<div class="space-y-3">
{#if profile.current?.user.moderates.length > 0}
<Expandable class="px-1.5" bind:open={settings.expand.moderates}>
{#snippet title()}
<span class="px-2 py-1 w-full">
<EndPlaceholder border={false}>
{$t('routes.profile.moderates')}
{#snippet action()}
<span class="dark:text-white text-black">
{profile.current.user?.moderates.length}
</span>
{/snippet}
</EndPlaceholder>
</span>
{/snippet}
<ItemList
items={profile.current.user.moderates.map(i => ({
id: i.community.id,
name: i.community.title,
url: communityLink(i.community),
avatar: i.community.icon,
instance: new URL(i.community.actor_id).hostname,
}))}
/>
</Expandable>
{/if}
<Expandable class="px-1.5" bind:open={settings.expand.communities}>
{#snippet title()}
<span class="px-2 py-1 w-full">
<EndPlaceholder border={false}>
{$t('routes.profile.moderates')}
{$t('profile.subscribed')}
{#snippet action()}
<span class="dark:text-white text-black">
{profile.current.user?.moderates.length}
{profile.current.user?.follows.length}
</span>
{/snippet}
</EndPlaceholder>
</span>
{/snippet}
<CommonList
animate={false}
size="xs"
items={profile.current.user.moderates}
class="px-1 py-0.5"
>
{#snippet item(moderate)}
<SidebarButton
class="font-normal w-full h-max"
color="none"
alignment="left"
href={communityLink(moderate.community)}
>
{#snippet customIcon()}
<Avatar
url={moderate.community.icon}
alt={moderate.community.name}
title={moderate.community.title}
width={28}
/>{/snippet}
{#snippet label()}
<div class="flex flex-col max-w-full break-words">
<span>{moderate.community.title}</span>
<span class="text-xs text-slate-600 dark:text-zinc-400">
{new URL(moderate.community.actor_id).hostname}
</span>
</div>
{/snippet}
</SidebarButton>
{/snippet}
</CommonList>
</Expandable>
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
{/if}
<Expandable
class="max-w-full min-w-0 w-full"
bind:open={settings.expand.communities}
>
{#snippet title()}
<span class="px-2 py-1 w-full">
<EndPlaceholder border={false}>
{$t('profile.subscribed')}
{#snippet action()}
<span class="dark:text-white text-black">
{profile.current.user?.follows.length}
</span>
{/snippet}
</EndPlaceholder>
</span>
{/snippet}
<CommonList
animate={false}
size="xs"
items={profile.current.user.follows}
class="px-1 py-0.5"
>
{#snippet item(follow)}
<SidebarButton
class="font-normal w-full h-max"
color="none"
alignment="left"
href={communityLink(follow.community)}
>
{#snippet customIcon()}
<Avatar
url={follow.community.icon}
alt={follow.community.name}
title={follow.community.title}
width={28}
/>{/snippet}
{#snippet label()}
<div class="flex flex-col max-w-full break-words">
<span>{follow.community.title}</span>
<span class="text-xs text-slate-600 dark:text-zinc-400">
{new URL(follow.community.actor_id).hostname}
</span>
</div>
{/snippet}
</SidebarButton>
{/snippet}
</CommonList>
</Expandable>
<ItemList
items={profile.current.user.follows.map(i => ({
id: i.community.id,
name: i.community.title,
url: communityLink(i.community),
avatar: i.community.icon,
instance: new URL(i.community.actor_id).hostname,
}))}
/>
</Expandable>
</div>
{/if}
<div class="flex-1 h-full mt-auto"></div>
</nav>
@@ -8,9 +8,9 @@
href?: string | undefined
icon?: IconSource | undefined
class?: string
label?: string
customIcon?: import('svelte').Snippet<[{ selected: boolean }]>
children?: import('svelte').Snippet
label?: import('svelte').Snippet
}
let {
@@ -27,9 +27,9 @@
</script>
<Button
color="none"
color="tertiary"
alignment="left"
rounding="pill"
rounding="xl"
{...rest}
{href}
class={[
@@ -49,8 +49,6 @@
<Icon src={icon} solid size="20" />
{/if}
{/snippet}
{label}
{@render children?.()}
<div class="contents">
{@render label?.()}
</div>
</Button>