feat: change navbar to dock
This commit is contained in:
1 parent
4dab003ae2
commit
e51c4530f0
7 files changed
+97
-81
No files matched your search
+2
-1
@@ -16,6 +16,7 @@ import { get, writable } from 'svelte/store'
|
|||||||
import { MINIMUM_VERSION, versionIsSupported } from '$lib/version.js'
|
import { MINIMUM_VERSION, versionIsSupported } from '$lib/version.js'
|
||||||
import { browser } from '$app/environment'
|
import { browser } from '$app/environment'
|
||||||
import { env } from '$env/dynamic/public'
|
import { env } from '$env/dynamic/public'
|
||||||
|
import type { ResumableCommunity } from './lemmy/item'
|
||||||
|
|
||||||
const getDefaultProfile = (): Profile => ({
|
const getDefaultProfile = (): Profile => ({
|
||||||
id: -1,
|
id: -1,
|
||||||
@@ -42,7 +43,7 @@ export interface Profile {
|
|||||||
user?: PersonData
|
user?: PersonData
|
||||||
username?: string
|
username?: string
|
||||||
avatar?: string
|
avatar?: string
|
||||||
favorites?: number[]
|
favorites?: ResumableCommunity[]
|
||||||
color?: string
|
color?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,13 +10,6 @@
|
|||||||
|
|
||||||
<div class="shell {$$props.class}" style={colorsToVars($colors)}>
|
<div class="shell {$$props.class}" style={colorsToVars($colors)}>
|
||||||
<slot />
|
<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
|
<div
|
||||||
class="content md:divide-x divide-slate-200 dark:divide-zinc-900 {$userSettings.newWidth
|
class="content md:divide-x divide-slate-200 dark:divide-zinc-900 {$userSettings.newWidth
|
||||||
? 'limit-width'
|
? 'limit-width'
|
||||||
@@ -24,7 +17,7 @@
|
|||||||
>
|
>
|
||||||
<slot
|
<slot
|
||||||
name="sidebar"
|
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;"
|
style="grid-area: sidebar; width: 100% !important;"
|
||||||
/>
|
/>
|
||||||
<slot
|
<slot
|
||||||
@@ -34,10 +27,22 @@
|
|||||||
/>
|
/>
|
||||||
<slot
|
<slot
|
||||||
name="suffix"
|
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;"
|
style="grid-area: suffix;"
|
||||||
/>
|
/>
|
||||||
</div>
|
</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>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@@ -46,8 +51,8 @@
|
|||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
grid-template-rows: auto 1fr;
|
grid-template-rows: auto 1fr;
|
||||||
grid-template-areas:
|
grid-template-areas:
|
||||||
'navbar'
|
'content'
|
||||||
'content';
|
'navbar';
|
||||||
}
|
}
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
|
|||||||
@@ -1,23 +1,31 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { page } from '$app/stores'
|
||||||
import { Button } from 'mono-svelte'
|
import { Button } from 'mono-svelte'
|
||||||
import { Icon, type IconSource } from 'svelte-hero-icons'
|
import { Icon, type IconSource } from 'svelte-hero-icons'
|
||||||
|
|
||||||
export let label: string
|
export let label: string
|
||||||
export let icon: IconSource | undefined = undefined
|
export let icon: IconSource | undefined = undefined
|
||||||
|
export let href: string | undefined = undefined
|
||||||
|
|
||||||
|
$: isSelected = href != undefined && $page.url.pathname == href
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
color="tertiary"
|
||||||
{...$$restProps}
|
{...$$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"
|
size="custom"
|
||||||
|
{href}
|
||||||
|
rounding="pill"
|
||||||
title={label}
|
title={label}
|
||||||
>
|
>
|
||||||
{#if icon}
|
{#if icon}
|
||||||
<Icon src={icon} mini size="16" />
|
<Icon src={icon} mini={isSelected} size="18" />
|
||||||
{:else}
|
{:else}
|
||||||
<slot name="icon" />
|
<slot {isSelected} name="icon" />
|
||||||
{/if}
|
{/if}
|
||||||
<span class="max-md:hidden">{label}</span>
|
<!-- <span class="max-md:hidden">{label}</span> -->
|
||||||
<slot />
|
<slot />
|
||||||
</Button>
|
</Button>
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
import { Menu, MenuButton, MenuDivider, Spinner } from 'mono-svelte'
|
import { Menu, MenuButton, MenuDivider, Spinner } from 'mono-svelte'
|
||||||
import {
|
import {
|
||||||
GlobeAlt,
|
GlobeAlt,
|
||||||
|
Home,
|
||||||
Icon,
|
Icon,
|
||||||
MagnifyingGlass,
|
MagnifyingGlass,
|
||||||
Newspaper,
|
Newspaper,
|
||||||
@@ -23,62 +24,55 @@
|
|||||||
import { fly } from 'svelte/transition'
|
import { fly } from 'svelte/transition'
|
||||||
import Profile from './Profile.svelte'
|
import Profile from './Profile.svelte'
|
||||||
import NavButton from './NavButton.svelte'
|
import NavButton from './NavButton.svelte'
|
||||||
|
|
||||||
export let title: string | undefined = ''
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<nav
|
<nav
|
||||||
class="flex flex-row gap-2 items-center
|
class="flex flex-row gap-2 items-center w-full mx-auto p-1 z-50 box-border h-16
|
||||||
backdrop-blur-lg w-full mx-auto px-4 py-2 z-50 box-border h-16
|
|
||||||
{$$props.class}
|
{$$props.class}
|
||||||
"
|
"
|
||||||
style={$$props.style}
|
style={$$props.style}
|
||||||
>
|
>
|
||||||
<div class="flex flex-row gap-2 items-center mr-auto">
|
<div class="flex flex-row gap-2 py-2 px-2 items-center w-full">
|
||||||
<a
|
<Profile
|
||||||
href="/"
|
placement="top"
|
||||||
class="flex flex-row items-center gap-2 logo group"
|
itemsClass="h-8 md:h-8 z-10"
|
||||||
title="Home"
|
targetClass="z-10 h-8"
|
||||||
>
|
containerClass="!max-h-[28rem] z-10"
|
||||||
{#if LINKED_INSTANCE_URL}
|
buttonClass=""
|
||||||
{#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 items-center gap-2 max-[500px]:hidden">
|
{#if $profile}
|
||||||
<span class="opacity-30 text-xl">/</span>
|
<div
|
||||||
{$site.site_view.site.name}
|
class="px-2 border-r border-l border-slate-200 dark:border-zinc-900
|
||||||
</div>
|
flex flex-row items-center gap-2 flex-shrink overflow-hidden max-[500px]:hidden"
|
||||||
{: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}
|
{#each $profile.favorites ?? [] as favorite}
|
||||||
</span>
|
<NavButton href={favorite.url.toString()} label="Community">
|
||||||
{/key}
|
<Avatar
|
||||||
</span>
|
alt={favorite.name}
|
||||||
|
url={favorite.avatar}
|
||||||
|
res={64}
|
||||||
|
width={28}
|
||||||
|
/>
|
||||||
|
</NavButton>
|
||||||
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</a>
|
<div class="ml-auto" />
|
||||||
</div>
|
{#if amModOfAny($profile?.user)}
|
||||||
<div class="flex flex-row gap-2 py-2 px-2 items-center">
|
<NavButton href="/moderation" label="Moderation" class="relative">
|
||||||
{#if $profile?.user && isAdmin($profile.user)}
|
{#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 let:isSelected slot="icon" filled={isSelected} width={18} />
|
||||||
|
</NavButton>
|
||||||
|
{/if}
|
||||||
|
<NavButton
|
||||||
|
href="/communities"
|
||||||
|
label="Explore"
|
||||||
|
icon={GlobeAlt}
|
||||||
|
/>{#if $profile?.user && isAdmin($profile.user)}
|
||||||
<NavButton
|
<NavButton
|
||||||
href="/admin"
|
href="/admin"
|
||||||
label="Admin"
|
label="Admin"
|
||||||
@@ -92,19 +86,9 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</NavButton>
|
</NavButton>
|
||||||
{/if}
|
{/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="/search" label="Search" icon={MagnifyingGlass} />
|
||||||
<NavButton href="/communities" label="Explore" icon={GlobeAlt} />
|
<NavButton href="/" label="Home" icon={Home} />
|
||||||
<Menu placement="bottom-end" targetClass="h-8">
|
<Menu placement="top" targetClass="h-8">
|
||||||
<NavButton
|
<NavButton
|
||||||
class="relative"
|
class="relative"
|
||||||
color="primary"
|
color="primary"
|
||||||
@@ -138,11 +122,5 @@
|
|||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
</Menu>
|
</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>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
<button
|
<button
|
||||||
class="w-8 h-8 rounded-full ring-1 ring-slate-200 dark:ring-zinc-700
|
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
|
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"
|
aria-label="Profile"
|
||||||
slot="target"
|
slot="target"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -66,3 +66,10 @@ export const isCommentReport = (item: Result): item is CommentReportView =>
|
|||||||
export const isPrivateMessageReport = (
|
export const isPrivateMessageReport = (
|
||||||
item: Result
|
item: Result
|
||||||
): item is PrivateMessageReportView => 'private_message_report' in item
|
): item is PrivateMessageReportView => 'private_message_report' in item
|
||||||
|
|
||||||
|
export interface ResumableCommunity {
|
||||||
|
url: URL
|
||||||
|
id: number
|
||||||
|
name: string
|
||||||
|
avatar?: string
|
||||||
|
}
|
||||||
@@ -34,6 +34,23 @@
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
afterNavigate(() => {
|
||||||
|
if ($profile) {
|
||||||
|
let favs = $profile?.favorites ?? []
|
||||||
|
if (favs.map((fav) => fav.url.toString()).includes($page.url.toString()))
|
||||||
|
return
|
||||||
|
|
||||||
|
if (favs.length >= 3) favs.pop()
|
||||||
|
favs.push({
|
||||||
|
avatar: data.community.community_view.community.icon,
|
||||||
|
id: data.community.community_view.community.id,
|
||||||
|
url: $page.url,
|
||||||
|
name: data.community.community_view.community.title,
|
||||||
|
})
|
||||||
|
$profile.favorites = favs
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
onDestroy(() => {
|
onDestroy(() => {
|
||||||
if (browser) {
|
if (browser) {
|
||||||
if ($navigating?.to?.route?.id == '/create/post') return
|
if ($navigating?.to?.route?.id == '/create/post') return
|
||||||
|
|||||||
Reference in new issue
Block a user