design: improve tabnav
This commit is contained in:
8 files changed
+139
-131
No files matched your search
@@ -10,7 +10,8 @@
|
|||||||
import Link from '../input/Link.svelte'
|
import Link from '../input/Link.svelte'
|
||||||
import Expandable from '../ui/Expandable.svelte'
|
import Expandable from '../ui/Expandable.svelte'
|
||||||
import LabelStat from '../ui/LabelStat.svelte'
|
import LabelStat from '../ui/LabelStat.svelte'
|
||||||
import ItemList from './generic/ItemList.svelte'
|
import CommonList from '../ui/layout/CommonList.svelte'
|
||||||
|
import SidebarButton from '../ui/sidebar/SidebarButton.svelte'
|
||||||
import { optimizeImageURL } from './post/helpers'
|
import { optimizeImageURL } from './post/helpers'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -114,15 +115,36 @@
|
|||||||
{$t('cards.site.admins')}
|
{$t('cards.site.admins')}
|
||||||
</span>
|
</span>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<ItemList
|
<CommonList
|
||||||
items={admins.map(a => ({
|
animate={false}
|
||||||
id: a.person.id,
|
size="xs"
|
||||||
name: a.person.name,
|
items={admins}
|
||||||
url: userLink(a.person),
|
class="px-1 py-0.5"
|
||||||
avatar: a.person.avatar,
|
>
|
||||||
instance: new URL(a.person.actor_id).hostname,
|
{#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>
|
||||||
</Expandable>
|
</Expandable>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
|
|
||||||
<nav
|
<nav
|
||||||
aria-label={$t('aria.pagination.nav')}
|
aria-label={$t('aria.pagination.nav')}
|
||||||
class="flex flex-row w-full gap-4 items-center justify-center"
|
class="flex flex-row w-full gap-4 items-center justify-center backdrop-blur-xl border border-slate-200 dark:border-zinc-800 rounded-full overflow-hidden"
|
||||||
>
|
>
|
||||||
{#if children}
|
{#if children}
|
||||||
<span class="text-sm text-slate-600 dark:text-zinc-400 font-medium">
|
<span class="text-sm text-slate-600 dark:text-zinc-400 font-medium">
|
||||||
@@ -58,9 +58,9 @@
|
|||||||
color="ghost"
|
color="ghost"
|
||||||
onclick={() => invalidate(pageData.url)}
|
onclick={() => invalidate(pageData.url)}
|
||||||
title={$t('common.back')}
|
title={$t('common.back')}
|
||||||
size="square-md"
|
rounding="none"
|
||||||
rounding="pill"
|
size="custom"
|
||||||
class="text-inherit dark:text-inherit disabled:opacity-20! disabled:bg-transparent!"
|
class="text-inherit dark:text-inherit border-0 border-r p-2"
|
||||||
disabled={(cursor?.back == undefined && cursor?.next != undefined) ||
|
disabled={(cursor?.back == undefined && cursor?.next != undefined) ||
|
||||||
page <= 1}
|
page <= 1}
|
||||||
data-sveltekit-preload-data="off"
|
data-sveltekit-preload-data="off"
|
||||||
@@ -77,7 +77,7 @@
|
|||||||
<div
|
<div
|
||||||
in:fly={{ y: 8, easing: backOut, duration: 400, delay: 100 }}
|
in:fly={{ y: 8, easing: backOut, duration: 400, delay: 100 }}
|
||||||
out:fly={{ y: 8, easing: backOut, duration: 400 }}
|
out:fly={{ y: 8, easing: backOut, duration: 400 }}
|
||||||
class="text-md font-medium"
|
class="text-lg font-medium"
|
||||||
style="grid-column: 1; grid-row: 1;"
|
style="grid-column: 1; grid-row: 1;"
|
||||||
>
|
>
|
||||||
{page}
|
{page}
|
||||||
@@ -91,9 +91,9 @@
|
|||||||
color="ghost"
|
color="ghost"
|
||||||
onclick={() => invalidate(pageData.url)}
|
onclick={() => invalidate(pageData.url)}
|
||||||
title={$t('common.next')}
|
title={$t('common.next')}
|
||||||
size="square-md"
|
size="custom"
|
||||||
rounding="pill"
|
rounding="none"
|
||||||
class="text-inherit dark:text-inherit"
|
class="text-inherit dark:text-inherit border-0 border-l p-2"
|
||||||
disabled={!hasMore}
|
disabled={!hasMore}
|
||||||
data-sveltekit-preload-data="off"
|
data-sveltekit-preload-data="off"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { invalidateAll } from '$app/navigation'
|
import { invalidateAll } from '$app/navigation'
|
||||||
import { page } from '$app/state'
|
import { page } from '$app/state'
|
||||||
|
import { SvelteURL } from 'svelte/reactivity'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
routes: {
|
routes: {
|
||||||
href: string
|
href: string
|
||||||
name: string
|
name: string
|
||||||
}[]
|
}[]
|
||||||
currentRoute?: string | undefined
|
currentRoute?: SvelteURL | undefined
|
||||||
buildUrl?: (currentRoute: string | undefined, href: string) => string
|
buildUrl?: (currentRoute: SvelteURL | undefined, href: string) => string
|
||||||
defaultRoute?: string | undefined
|
|
||||||
class?: string
|
class?: string
|
||||||
children?: import('svelte').Snippet
|
children?: import('svelte').Snippet
|
||||||
}
|
}
|
||||||
@@ -18,27 +18,13 @@
|
|||||||
routes,
|
routes,
|
||||||
currentRoute = undefined,
|
currentRoute = undefined,
|
||||||
buildUrl = (_, href) => href,
|
buildUrl = (_, href) => href,
|
||||||
defaultRoute = undefined,
|
|
||||||
class: clazz = '',
|
class: clazz = '',
|
||||||
children,
|
children,
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
|
|
||||||
function isSelected(
|
function isSelected(url: URL, href?: SvelteURL) {
|
||||||
url: URL,
|
if (href?.search != '') return href?.search == url.search
|
||||||
currentRoute: string | undefined,
|
else if (url.search == '') return href?.pathname == url.pathname
|
||||||
route: string,
|
|
||||||
defaultRoute?: string,
|
|
||||||
) {
|
|
||||||
if (route.startsWith('?')) {
|
|
||||||
const param = route.slice(1)
|
|
||||||
const key = param.split(/(?<=[=])/g)[0]
|
|
||||||
if (currentRoute?.includes(param)) {
|
|
||||||
return true
|
|
||||||
} else if (route == defaultRoute && !currentRoute?.includes(key)) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (currentRoute ?? url.pathname) == route
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -56,7 +42,7 @@
|
|||||||
transition-colors duration-100 relative z-0 shrink-0"
|
transition-colors duration-100 relative z-0 shrink-0"
|
||||||
>
|
>
|
||||||
{route.name}
|
{route.name}
|
||||||
{#if isSelected(page.url, currentRoute, route.href, defaultRoute)}
|
{#if isSelected(page.url, new SvelteURL(`${page.url.origin}${route.href}`))}
|
||||||
<div
|
<div
|
||||||
class="rounded-full bg-slate-200/60 dark:bg-zinc-700/60
|
class="rounded-full bg-slate-200/60 dark:bg-zinc-700/60
|
||||||
absolute inset-0 w-full h-full -z-10"
|
absolute inset-0 w-full h-full -z-10"
|
||||||
|
|||||||
@@ -189,11 +189,9 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{#if data.communities.value.length > 0}
|
{#if data.communities.value.length > 0}
|
||||||
<div class="sticky z-30 mx-auto max-w-full bottom-22 lg:bottom-6">
|
<div class="sticky z-30 mx-auto max-w-full bottom-22 lg:bottom-6">
|
||||||
<Tabs routes={[]} class="mx-auto">
|
<Pageination
|
||||||
<Pageination
|
page={Number(page.url.searchParams.get('page')) || 1}
|
||||||
page={Number(page.url.searchParams.get('page')) || 1}
|
href={c => `?page=${c}`}
|
||||||
href={c => `?page=${c}`}
|
/>
|
||||||
/>
|
|
||||||
</Tabs>
|
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { page } from '$app/state'
|
||||||
|
import Tabs from '$lib/components/ui/layout/pages/Tabs.svelte'
|
||||||
|
import { t } from '$lib/i18n/translations'
|
||||||
|
import { SvelteURLSearchParams } from 'svelte/reactivity'
|
||||||
|
|
||||||
|
let { children } = $props()
|
||||||
|
|
||||||
|
function addSearchParam(
|
||||||
|
currentSearchParams: URLSearchParams,
|
||||||
|
newParamString: string,
|
||||||
|
) {
|
||||||
|
const updatedParams = new SvelteURLSearchParams(currentSearchParams)
|
||||||
|
const newParam = new SvelteURLSearchParams(newParamString)
|
||||||
|
const [key, value]: [string, string] = newParam.entries().next().value!
|
||||||
|
updatedParams.set(key, value)
|
||||||
|
return updatedParams
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="mt-4 mb-2 z-30 mx-auto max-w-full flex gap-2 md:flex-row flex-col
|
||||||
|
items-center px-2 w-max top-6 lg:top-22"
|
||||||
|
>
|
||||||
|
<Tabs
|
||||||
|
routes={[
|
||||||
|
{
|
||||||
|
href: '/inbox',
|
||||||
|
name: $t('filter.location.all'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: '/inbox?type=replies',
|
||||||
|
name: $t('filter.inbox.replies'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: '/inbox?type=mentions',
|
||||||
|
name: $t('filter.inbox.mentions'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
href: '/inbox/messages',
|
||||||
|
name: $t('filter.inbox.messages'),
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
class="overflow-auto"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{@render children?.()}
|
||||||
@@ -9,10 +9,10 @@
|
|||||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import { getClient } from '$lib/lemmy.svelte.js'
|
import { getClient } from '$lib/lemmy.svelte.js'
|
||||||
import { Button } from 'mono-svelte'
|
import { Button, Option, Select } from 'mono-svelte'
|
||||||
import { ArrowPath, Check, Icon, Inbox } from 'svelte-hero-icons'
|
import { ArrowPath, Check, Funnel, Icon, Inbox } from 'svelte-hero-icons'
|
||||||
import InboxItem from './InboxItem.svelte'
|
import InboxItem from './InboxItem.svelte'
|
||||||
import { SvelteURLSearchParams } from 'svelte/reactivity'
|
import { searchParam } from '$lib/util.svelte'
|
||||||
|
|
||||||
let { data } = $props()
|
let { data } = $props()
|
||||||
|
|
||||||
@@ -38,80 +38,12 @@
|
|||||||
|
|
||||||
return response.replies
|
return response.replies
|
||||||
}
|
}
|
||||||
|
|
||||||
function addSearchParam(
|
|
||||||
currentSearchParams: URLSearchParams,
|
|
||||||
newParamString: string,
|
|
||||||
) {
|
|
||||||
// Create a new URLSearchParams object from the current search params
|
|
||||||
const updatedParams = new SvelteURLSearchParams(currentSearchParams)
|
|
||||||
|
|
||||||
// Parse the new parameter string
|
|
||||||
const newParam = new SvelteURLSearchParams(newParamString)
|
|
||||||
|
|
||||||
// Get the key and value of the new parameter
|
|
||||||
const [key, value]: [string, string] = newParam.entries().next().value!
|
|
||||||
|
|
||||||
// Add the new parameter to the updated params
|
|
||||||
updatedParams.set(key, value)
|
|
||||||
|
|
||||||
return updatedParams
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<title>{$t('routes.inbox.title')}</title>
|
<title>{$t('routes.inbox.title')}</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<div
|
|
||||||
class="mt-4 mb-2 z-30 mx-auto max-w-full flex gap-2 md:flex-row flex-col
|
|
||||||
items-center px-2 w-max top-6 lg:top-22"
|
|
||||||
>
|
|
||||||
<Tabs
|
|
||||||
routes={[
|
|
||||||
{
|
|
||||||
href: '?type=all',
|
|
||||||
name: $t('filter.location.all'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
href: '?type=replies',
|
|
||||||
name: $t('filter.inbox.replies'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
href: '?type=mentions',
|
|
||||||
name: $t('filter.inbox.mentions'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
href: '/inbox/messages',
|
|
||||||
name: $t('filter.inbox.messages'),
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
currentRoute={page.url.search}
|
|
||||||
buildUrl={(route, href) =>
|
|
||||||
href.includes('?')
|
|
||||||
? '?' + addSearchParam(page.url.searchParams, href).toString()
|
|
||||||
: `${href}${page.url.search}`}
|
|
||||||
defaultRoute="?type=all"
|
|
||||||
class="overflow-auto"
|
|
||||||
/>
|
|
||||||
<Tabs
|
|
||||||
routes={[
|
|
||||||
{
|
|
||||||
href: '?unreadOnly=false',
|
|
||||||
name: $t('filter.location.all'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
href: '?unreadOnly=true',
|
|
||||||
name: $t('filter.unread'),
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
currentRoute={page.url.search}
|
|
||||||
buildUrl={(route, href) =>
|
|
||||||
'?' + addSearchParam(page.url.searchParams, href).toString()}
|
|
||||||
defaultRoute="?unreadOnly=true"
|
|
||||||
class="overflow-auto"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<Header pageHeader class="lg:flex-row justify-between flex-col">
|
<Header pageHeader class="lg:flex-row justify-between flex-col">
|
||||||
{$t('routes.inbox.title')}
|
{$t('routes.inbox.title')}
|
||||||
|
|
||||||
@@ -144,6 +76,32 @@ items-center px-2 w-max top-6 lg:top-22"
|
|||||||
|
|
||||||
<div class="h-3 sm:h-6"></div>
|
<div class="h-3 sm:h-6"></div>
|
||||||
|
|
||||||
|
<div class="mb-3 sm:mb-6">
|
||||||
|
<Select
|
||||||
|
class=" w-max items-center"
|
||||||
|
bind:value={
|
||||||
|
() => data.unreadOnly.value.toString(),
|
||||||
|
v => (data.unreadOnly.value = v == 'true')
|
||||||
|
}
|
||||||
|
onchange={() =>
|
||||||
|
searchParam(
|
||||||
|
page.url,
|
||||||
|
'unreadOnly',
|
||||||
|
data.unreadOnly.value ? 'true' : 'false',
|
||||||
|
'page',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{#snippet customLabel()}
|
||||||
|
<span class="flex items-center gap-1">
|
||||||
|
<Icon src={Funnel} size="15" mini />
|
||||||
|
{$t('filter.filter')}
|
||||||
|
</span>
|
||||||
|
{/snippet}
|
||||||
|
<Option value="false">{$t('filter.location.all')}</Option>
|
||||||
|
<Option value="true">{$t('filter.unread')}</Option>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
|
||||||
{#if !data.inbox?.value || (data.inbox.value?.length ?? 0) == 0}
|
{#if !data.inbox?.value || (data.inbox.value?.length ?? 0) == 0}
|
||||||
<Placeholder
|
<Placeholder
|
||||||
icon={Inbox}
|
icon={Inbox}
|
||||||
@@ -162,14 +120,12 @@ items-center px-2 w-max top-6 lg:top-22"
|
|||||||
<div
|
<div
|
||||||
class="sticky z-30 mx-auto max-w-full self-end mt-auto bottom-22 lg:bottom-6"
|
class="sticky z-30 mx-auto max-w-full self-end mt-auto bottom-22 lg:bottom-6"
|
||||||
>
|
>
|
||||||
<Tabs routes={[]} class="mx-auto">
|
<Pageination
|
||||||
<Pageination
|
hasMore={!(
|
||||||
hasMore={!(
|
!data.inbox || (data.inbox.value?.length ?? 0) < (data?.limit ?? 0)
|
||||||
!data.inbox || (data.inbox.value?.length ?? 0) < (data?.limit ?? 0)
|
)}
|
||||||
)}
|
page={data.page}
|
||||||
page={data.page}
|
href={page => `?page=${page}`}
|
||||||
href={page => `?page=${page}`}
|
/>
|
||||||
/>
|
|
||||||
</Tabs>
|
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -18,12 +18,13 @@ export async function load({ url, fetch }) {
|
|||||||
(url.searchParams.get('type') as InboxFeedType) || 'all'
|
(url.searchParams.get('type') as InboxFeedType) || 'all'
|
||||||
const client = getClient(undefined, fetch)
|
const client = getClient(undefined, fetch)
|
||||||
const page = Number(url.searchParams.get('page')) || 1
|
const page = Number(url.searchParams.get('page')) || 1
|
||||||
const unreadOnly: string = url.searchParams.get('unreadOnly') || 'true'
|
const unreadOnly: boolean =
|
||||||
|
(url.searchParams.get('unreadOnly') || 'true') == 'true'
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
limit: 20,
|
limit: 20,
|
||||||
page: page,
|
page: page,
|
||||||
unread_only: unreadOnly == 'true',
|
unread_only: unreadOnly,
|
||||||
}
|
}
|
||||||
|
|
||||||
const [replies, mentions, privateMessages] = await Promise.all([
|
const [replies, mentions, privateMessages] = await Promise.all([
|
||||||
@@ -70,7 +71,7 @@ export async function load({ url, fetch }) {
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
return {
|
return {
|
||||||
unreadOnly: unreadOnly,
|
unreadOnly: new ReactiveState(unreadOnly),
|
||||||
type: type,
|
type: type,
|
||||||
page: page,
|
page: page,
|
||||||
inbox: new ReactiveState(data),
|
inbox: new ReactiveState(data),
|
||||||
|
|||||||
@@ -82,7 +82,5 @@
|
|||||||
</CommonList>
|
</CommonList>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="sticky z-30 mx-auto max-w-full bottom-22 lg:bottom-6">
|
<div class="sticky z-30 mx-auto max-w-full bottom-22 lg:bottom-6">
|
||||||
<Tabs routes={[]} class="mx-auto">
|
<Pageination href={page => `?page=${page}`} page={data.page} />
|
||||||
<Pageination href={page => `?page=${page}`} page={data.page} />
|
|
||||||
</Tabs>
|
|
||||||
</div>
|
</div>
|
||||||
Reference in new issue
Block a user