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

+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"
>