feat: add route indicator
This commit is contained in:
1 parent
8d03d105e2
commit
380fa48ffb
5 files changed
+54
-5
No files matched your search
@@ -40,12 +40,14 @@
|
||||
UserCircle,
|
||||
UserGroup,
|
||||
} from 'svelte-hero-icons'
|
||||
import { fly } from 'svelte/transition'
|
||||
|
||||
export let title: string | undefined = ''
|
||||
</script>
|
||||
|
||||
<nav
|
||||
class="flex flex-row gap-2 items-center sticky top-0 bg-slate-50/80
|
||||
dark:bg-black/80 backdrop-blur-3xl w-full mx-auto px-4 py-2 z-50 box-border h-16
|
||||
|
||||
"
|
||||
>
|
||||
<div class="flex flex-row gap-2 items-center mr-auto">
|
||||
@@ -88,9 +90,19 @@
|
||||
<span
|
||||
class="text-sm font-bold group-hover:bg-gradient-to-r
|
||||
group-hover:text-transparent group-hover:bg-clip-text
|
||||
group-hover:from-violet-500 group-hover:to-pink-600 transition-colors"
|
||||
group-hover:from-violet-500 group-hover:to-pink-600 transition-colors
|
||||
grid place-items-start"
|
||||
>
|
||||
{$instance}
|
||||
{#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}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { writable } from 'svelte/store'
|
||||
|
||||
interface SessionStorage {
|
||||
lastSeenCommunity: // prettier-ignore
|
||||
{
|
||||
@@ -33,3 +35,9 @@ export const getSessionStorage = (
|
||||
): SessionStorage[typeof key] => {
|
||||
return JSON.parse(sessionStorage.getItem(key)!)
|
||||
}
|
||||
|
||||
interface Route {
|
||||
title: string
|
||||
}
|
||||
|
||||
export const route = writable<Route | undefined>(undefined)
|
||||
@@ -3,6 +3,7 @@ import { toast } from 'mono-svelte'
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
import { get } from 'svelte/store'
|
||||
import type { SubscribedType } from 'lemmy-js-client'
|
||||
import { page } from '$app/stores'
|
||||
|
||||
export const findClosestNumber = (numbers: number[], target: number): number =>
|
||||
numbers.reduce((prev, curr) =>
|
||||
@@ -105,3 +106,27 @@ export const DOMAIN_REGEX_FORMS = '^((?!-)[A-Za-z0-9-]{1,63}.)+[A-Za-z]{2,63}'
|
||||
|
||||
export const isSubscribed = (subscribed: SubscribedType) =>
|
||||
subscribed == 'Pending' || subscribed == 'Subscribed'
|
||||
|
||||
export const routes = {
|
||||
'/': 'Frontpage',
|
||||
get '/post/[instance]/[id=integer]'() {
|
||||
return get(page)?.data?.post?.post_view?.post?.name
|
||||
},
|
||||
'/settings': 'Settings',
|
||||
'/communities': 'Communities',
|
||||
'/search': 'Search',
|
||||
'/moderation': 'Moderation',
|
||||
'/create/post': 'Create post',
|
||||
'/create/community': 'Create community',
|
||||
get '/c/[name]'() {
|
||||
return get(page)?.data?.community?.community_view?.community?.title
|
||||
},
|
||||
'/accounts': 'Accounts',
|
||||
'/admin/config': 'Administration',
|
||||
'/inbox': 'Inbox',
|
||||
'/saved': 'Saved',
|
||||
'/about': 'About',
|
||||
'/profile/user': 'Profile',
|
||||
'/profile/settings': 'Profile Settings',
|
||||
'/profile/blocks': 'Blocks',
|
||||
}
|
||||
@@ -14,6 +14,8 @@
|
||||
import { onMount } from 'svelte'
|
||||
import { browser } from '$app/environment'
|
||||
import { Forward, Icon } from 'svelte-hero-icons'
|
||||
import { DEFAULT_INSTANCE_URL, instance } from '$lib/instance.js'
|
||||
import { routes } from '$lib/util.js'
|
||||
|
||||
nProgress.configure({
|
||||
minimum: 0.4,
|
||||
@@ -55,6 +57,8 @@
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
$: title = routes[($page.route.id as keyof typeof routes) ?? '']
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
@@ -80,7 +84,7 @@
|
||||
: 'font-sans'}
|
||||
"
|
||||
>
|
||||
<Navbar />
|
||||
<Navbar {title} />
|
||||
<ToastContainer />
|
||||
<Moderation />
|
||||
<div
|
||||
|
||||
Reference in new issue
Block a user