feat: change navbar to dock

This commit is contained in:
Xylight committed 2024-04-13 12:46:17 -07:00
1 parent 4dab003ae2
commit e51c4530f0
7 files changed
+99 -83

No files matched your search

+2 -1
View File
@@ -16,6 +16,7 @@ import { get, writable } from 'svelte/store'
import { MINIMUM_VERSION, versionIsSupported } from '$lib/version.js'
import { browser } from '$app/environment'
import { env } from '$env/dynamic/public'
import type { ResumableCommunity } from './lemmy/item'
const getDefaultProfile = (): Profile => ({
id: -1,
@@ -42,7 +43,7 @@ export interface Profile {
user?: PersonData
username?: string
avatar?: string
favorites?: number[]
favorites?: ResumableCommunity[]
color?: string
}
+16 -11
View File
@@ -10,13 +10,6 @@
<div class="shell {$$props.class}" style={colorsToVars($colors)}>
<slot />
<slot
name="navbar"
class="sticky top-0 border-b border-slate-200 dark:border-zinc-900
bg-slate-50 dark:bg-zinc-950 transition-colors duration-500"
style="grid-area: navbar"
{title}
/>
<div
class="content md:divide-x divide-slate-200 dark:divide-zinc-900 {$userSettings.newWidth
? 'limit-width'
@@ -24,7 +17,7 @@
>
<slot
name="sidebar"
class="hidden md:flex sticky top-16 left-0 w-full max-w-full bg-slate-50 dark:bg-zinc-950"
class="hidden md:flex sticky top-0 left-0 w-full max-w-full bg-slate-50 dark:bg-zinc-950"
style="grid-area: sidebar; width: 100% !important;"
/>
<slot
@@ -34,10 +27,22 @@
/>
<slot
name="suffix"
class="max-xl:hidden w-full sticky top-16 left-0 h-full max-h-[calc(100svh-4rem)] bg-slate-50 dark:bg-zinc-950"
class="max-xl:hidden w-full sticky top-0 left-0 h-max bg-slate-50 dark:bg-zinc-950"
style="grid-area: suffix;"
/>
</div>
<div
class="p-4 w-full sticky bottom-0 z-50 max-w-3xl mx-auto"
style="grid-area: navbar;"
>
<slot
name="navbar"
class="border rounded-full border-slate-200 dark:border-zinc-800 shadow-2xl
bg-white dark:bg-zinc-950 transition-colors duration-500"
style="grid-area: navbar"
{title}
/>
</div>
</div>
<style>
@@ -46,8 +51,8 @@
grid-template-columns: 1fr;
grid-template-rows: auto 1fr;
grid-template-areas:
'navbar'
'content';
'content'
'navbar';
}
.content {
+13 -5
View File
@@ -1,23 +1,31 @@
<script lang="ts">
import { page } from '$app/stores'
import { Button } from 'mono-svelte'
import { Icon, type IconSource } from 'svelte-hero-icons'
export let label: string
export let icon: IconSource | undefined = undefined
export let href: string | undefined = undefined
$: isSelected = href != undefined && $page.url.pathname == href
</script>
<Button
color="tertiary"
{...$$restProps}
class="px-3 py-1.5 max-md:py-0 max-md:px-0 max-md:h-8 max-md:w-8 {$$props.class ??
''}"
class="rounded-full w-9 h-9 {isSelected
? 'bg-slate-200 dark:bg-zinc-900'
: ''} {$$props.class ?? ''}"
size="custom"
{href}
rounding="pill"
title={label}
>
{#if icon}
<Icon src={icon} mini size="16" />
<Icon src={icon} mini={isSelected} size="18" />
{:else}
<slot name="icon" />
<slot {isSelected} name="icon" />
{/if}
<span class="max-md:hidden">{label}</span>
<!-- <span class="max-md:hidden">{label}</span> -->
<slot />
</Button>
+43 -65
View File
@@ -13,6 +13,7 @@
import { Menu, MenuButton, MenuDivider, Spinner } from 'mono-svelte'
import {
GlobeAlt,
Home,
Icon,
MagnifyingGlass,
Newspaper,
@@ -23,62 +24,55 @@
import { fly } from 'svelte/transition'
import Profile from './Profile.svelte'
import NavButton from './NavButton.svelte'
export let title: string | undefined = ''
</script>
<nav
class="flex flex-row gap-2 items-center
backdrop-blur-lg w-full mx-auto px-4 py-2 z-50 box-border h-16
class="flex flex-row gap-2 items-center w-full mx-auto p-1 z-50 box-border h-16
{$$props.class}
"
style={$$props.style}
>
<div class="flex flex-row gap-2 items-center mr-auto">
<a
href="/"
class="flex flex-row items-center gap-2 logo group"
title="Home"
>
{#if LINKED_INSTANCE_URL}
{#if $site}
<Avatar
url={$site.site_view.site.icon}
alt={$site.site_view.site.name}
width={32}
res={64}
circle={false}
class="rounded-md"
<div class="flex flex-row gap-2 py-2 px-2 items-center w-full">
<Profile
placement="top"
itemsClass="h-8 md:h-8 z-10"
targetClass="z-10 h-8"
containerClass="!max-h-[28rem] z-10"
buttonClass=""
/>
{#if $profile}
<div
class="px-2 border-r border-l border-slate-200 dark:border-zinc-900
flex flex-row items-center gap-2 flex-shrink overflow-hidden max-[500px]:hidden"
>
{#each $profile.favorites ?? [] as favorite}
<NavButton href={favorite.url.toString()} label="Community">
<Avatar
alt={favorite.name}
url={favorite.avatar}
res={64}
width={28}
/>
</NavButton>
{/each}
</div>
{/if}
<div class="ml-auto" />
{#if amModOfAny($profile?.user)}
<NavButton href="/moderation" label="Moderation" class="relative">
{#if ($profile?.user?.notifications.reports ?? 0) > 0}
<div
class="rounded-full w-2 h-2 bg-red-500 absolute -top-1 -left-1"
/>
<div class="flex flex-row items-center gap-2 max-[500px]:hidden">
<span class="opacity-30 text-xl">/</span>
{$site.site_view.site.name}
</div>
{:else}
<Spinner width={32} />
{/if}
{:else}
<Logo width={40} />
<div class="flex flex-row items-center gap-2 max-[1000px]:hidden">
<span class="opacity-30 text-xl">/</span>
<span class="text-sm font-bold grid place-items-start">
{#key title || $instance}
<span
in:fly={{ y: -12 }}
out:fly={{ y: 12 }}
style="grid-row: 1; grid-column: 1; max-width: 24ch;"
class="overflow-hidden break-words overflow-ellipsis whitespace-nowrap"
>
{title || $instance}
</span>
{/key}
</span>
</div>
{/if}
</a>
</div>
<div class="flex flex-row gap-2 py-2 px-2 items-center">
{#if $profile?.user && isAdmin($profile.user)}
<ShieldIcon let:isSelected slot="icon" filled={isSelected} width={18} />
</NavButton>
{/if}
<NavButton
href="/communities"
label="Explore"
icon={GlobeAlt}
/>{#if $profile?.user && isAdmin($profile.user)}
<NavButton
href="/admin"
label="Admin"
@@ -92,19 +86,9 @@
{/if}
</NavButton>
{/if}
{#if amModOfAny($profile?.user)}
<NavButton href="/moderation" label="Moderation" class="relative">
{#if ($profile?.user?.notifications.reports ?? 0) > 0}
<div
class="rounded-full w-2 h-2 bg-red-500 absolute -top-1 -left-1"
/>
{/if}
<ShieldIcon slot="icon" filled width={15} />
</NavButton>
{/if}
<NavButton href="/search" label="Search" icon={MagnifyingGlass} />
<NavButton href="/communities" label="Explore" icon={GlobeAlt} />
<Menu placement="bottom-end" targetClass="h-8">
<NavButton href="/" label="Home" icon={Home} />
<Menu placement="top" targetClass="h-8">
<NavButton
class="relative"
color="primary"
@@ -138,11 +122,5 @@
</span>
{/if}
</Menu>
<Profile
placement="bottom-end"
itemsClass="h-8 md:h-8 z-10"
targetClass="z-10 h-8"
containerClass="!max-h-[28rem] z-10"
/>
</div>
</nav>
+1 -1
View File
@@ -36,7 +36,7 @@
<button
class="w-8 h-8 rounded-full ring-1 ring-slate-200 dark:ring-zinc-700
transition-all bg-slate-50 dark:bg-zinc-900 relative
hover:dark:brightness-125 hover:brightness-95"
hover:dark:brightness-125 hover:brightness {$$props.buttonClass}"
aria-label="Profile"
slot="target"
>
+7
View File
@@ -66,3 +66,10 @@ export const isCommentReport = (item: Result): item is CommentReportView =>
export const isPrivateMessageReport = (
item: Result
): item is PrivateMessageReportView => 'private_message_report' in item
export interface ResumableCommunity {
url: URL
id: number
name: string
avatar?: string
}