Merge pull request #641 from Xyphyn/aria-impr
a11y: improve accessibility for screen readers and generally
This commit is contained in:
46 files changed
+373
-248
No files matched your search
Vendored
+2
-1
@@ -2,5 +2,6 @@
|
|||||||
"i18n-ally.localesPaths": [
|
"i18n-ally.localesPaths": [
|
||||||
"src/lib/i18n",
|
"src/lib/i18n",
|
||||||
"src/routes/inbox/messages"
|
"src/routes/inbox/messages"
|
||||||
]
|
],
|
||||||
|
"i18n-ally.keystyle": "nested"
|
||||||
}
|
}
|
||||||
@@ -66,8 +66,9 @@
|
|||||||
<CommentModerationMenu bind:item={comment} />
|
<CommentModerationMenu bind:item={comment} />
|
||||||
{/if}
|
{/if}
|
||||||
<Menu placement="bottom">
|
<Menu placement="bottom">
|
||||||
{#snippet target()}
|
{#snippet target(attachment)}
|
||||||
<Button
|
<Button
|
||||||
|
{@attach attachment}
|
||||||
title={$t('comment.actions.label')}
|
title={$t('comment.actions.label')}
|
||||||
color="tertiary"
|
color="tertiary"
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
|
|||||||
@@ -270,8 +270,8 @@
|
|||||||
</Button>
|
</Button>
|
||||||
{/if}
|
{/if}
|
||||||
<Menu placement="top-end">
|
<Menu placement="top-end">
|
||||||
{#snippet target()}
|
{#snippet target(attachment)}
|
||||||
<Button size="square-md" rounding="pill">
|
<Button {@attach attachment} size="square-md" rounding="pill">
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
<Icon src={EllipsisHorizontal} size="16" mini />
|
<Icon src={EllipsisHorizontal} size="16" mini />
|
||||||
{/snippet}
|
{/snippet}
|
||||||
|
|||||||
@@ -193,8 +193,8 @@
|
|||||||
{#if site.data}
|
{#if site.data}
|
||||||
<div class="flex gap-2 flex-wrap flex-row">
|
<div class="flex gap-2 flex-wrap flex-row">
|
||||||
<Menu class="gap-px">
|
<Menu class="gap-px">
|
||||||
{#snippet target()}
|
{#snippet target(attachment)}
|
||||||
<button type="button">
|
<button {@attach attachment} type="button">
|
||||||
<Badge color="blue-subtle">
|
<Badge color="blue-subtle">
|
||||||
<Icon src={Plus} micro size="14" />
|
<Icon src={Plus} micro size="14" />
|
||||||
{$t('common.add')}
|
{$t('common.add')}
|
||||||
|
|||||||
@@ -170,8 +170,8 @@
|
|||||||
</Button>
|
</Button>
|
||||||
{/if}
|
{/if}
|
||||||
<Menu placement="top-end">
|
<Menu placement="top-end">
|
||||||
{#snippet target()}
|
{#snippet target(attachment)}
|
||||||
<Button size="custom" rounding="pill" class="h-8.5 aspect-square">
|
<Button {@attach attachment} size="custom" rounding="pill" class="h-8.5 aspect-square">
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
<Icon src={EllipsisHorizontal} size="16" mini />
|
<Icon src={EllipsisHorizontal} size="16" mini />
|
||||||
{/snippet}
|
{/snippet}
|
||||||
|
|||||||
@@ -5,10 +5,13 @@
|
|||||||
import LabelStat from '$lib/components/ui/LabelStat.svelte'
|
import LabelStat from '$lib/components/ui/LabelStat.svelte'
|
||||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
|
import { client } from '$lib/lemmy.svelte'
|
||||||
import { addSubscription } from '$lib/lemmy/user.js'
|
import { addSubscription } from '$lib/lemmy/user.js'
|
||||||
|
import { settings } from '$lib/settings.svelte'
|
||||||
import { fullCommunityName, isSubscribed } from '$lib/util.svelte.js'
|
import { fullCommunityName, isSubscribed } from '$lib/util.svelte.js'
|
||||||
import type { CommunityView } from 'lemmy-js-client'
|
import type { CommunityView } from 'lemmy-js-client'
|
||||||
import { Button, Modal } from 'mono-svelte'
|
import { Button, modal } from 'mono-svelte'
|
||||||
|
import type { Snippet } from 'svelte'
|
||||||
import {
|
import {
|
||||||
Check,
|
Check,
|
||||||
ExclamationTriangle,
|
ExclamationTriangle,
|
||||||
@@ -20,11 +23,7 @@
|
|||||||
Trash,
|
Trash,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import Subscribe from '../../../../routes/communities/Subscribe.svelte'
|
import Subscribe from '../../../../routes/communities/Subscribe.svelte'
|
||||||
import { settings } from '$lib/settings.svelte'
|
|
||||||
import type { Snippet } from 'svelte'
|
|
||||||
import { client } from '$lib/lemmy.svelte'
|
|
||||||
|
|
||||||
let showInfo = $state(false)
|
|
||||||
interface Props {
|
interface Props {
|
||||||
community: CommunityView
|
community: CommunityView
|
||||||
view?: 'cozy' | 'compact'
|
view?: 'cozy' | 'compact'
|
||||||
@@ -46,11 +45,9 @@
|
|||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if showInfo}
|
{#snippet communityInfo()}
|
||||||
<Modal title={$t('form.post.community')} bind:open={showInfo}>
|
|
||||||
<CommunityCard community_view={community} />
|
<CommunityCard community_view={community} />
|
||||||
</Modal>
|
{/snippet}
|
||||||
{/if}
|
|
||||||
|
|
||||||
<div class={clazz}>
|
<div class={clazz}>
|
||||||
<div
|
<div
|
||||||
@@ -154,7 +151,8 @@
|
|||||||
size="square-md"
|
size="square-md"
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
color="ghost"
|
color="ghost"
|
||||||
onclick={() => (showInfo = !showInfo)}
|
onclick={() =>
|
||||||
|
modal({ title: $t('form.post.community'), snippet: communityInfo })}
|
||||||
>
|
>
|
||||||
<Icon src={InformationCircle} size="16" mini />
|
<Icon src={InformationCircle} size="16" mini />
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -88,14 +88,12 @@
|
|||||||
</Option>
|
</Option>
|
||||||
</Select>
|
</Select>
|
||||||
{#if selected?.startsWith('Top')}
|
{#if selected?.startsWith('Top')}
|
||||||
<div transition:fly={{ easing: backOut, x: 2 }}>
|
|
||||||
<Select
|
<Select
|
||||||
class="border-l-0 rounded-l-none"
|
class="border-l-0 rounded-l-none"
|
||||||
bind:value={selected}
|
bind:value={selected}
|
||||||
onchange={() => {
|
onchange={() => {
|
||||||
sort = 'TopAll'
|
sort = 'TopAll'
|
||||||
if (navigate)
|
if (navigate) searchParam(page.url, 'sort', selected, 'page', 'cursor')
|
||||||
searchParam(page.url, 'sort', selected, 'page', 'cursor')
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{#snippet customLabel()}
|
{#snippet customLabel()}
|
||||||
@@ -135,6 +133,5 @@
|
|||||||
{$t('filter.sort.top.time.hour')}
|
{$t('filter.sort.top.time.hour')}
|
||||||
</Option>
|
</Option>
|
||||||
</Select>
|
</Select>
|
||||||
</div>
|
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
@@ -3,9 +3,10 @@
|
|||||||
import { settings } from '$lib/settings.svelte.js'
|
import { settings } from '$lib/settings.svelte.js'
|
||||||
import { Select } from 'mono-svelte'
|
import { Select } from 'mono-svelte'
|
||||||
import Option from 'mono-svelte/forms/select/Option.svelte'
|
import Option from 'mono-svelte/forms/select/Option.svelte'
|
||||||
|
import type { SelectProps } from 'mono-svelte/forms/select/Select.svelte'
|
||||||
import { Bars3, Icon, RectangleGroup, ViewColumns } from 'svelte-hero-icons'
|
import { Bars3, Icon, RectangleGroup, ViewColumns } from 'svelte-hero-icons'
|
||||||
|
|
||||||
interface Props {
|
interface Props extends SelectProps<string> {
|
||||||
showLabel?: boolean
|
showLabel?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,8 +24,9 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Menu placement="bottom" class="top-0 h-[26px] w-[26px] ">
|
<Menu placement="bottom" class="top-0 h-[26px] w-[26px] ">
|
||||||
{#snippet target()}
|
{#snippet target(attachment)}
|
||||||
<Button
|
<Button
|
||||||
|
{@attach attachment}
|
||||||
class="w-[26px] h-[26px] hover:text-green-500! dark:text-zinc-400 text-slate-600"
|
class="w-[26px] h-[26px] hover:text-green-500! dark:text-zinc-400 text-slate-600"
|
||||||
size="square-md"
|
size="square-md"
|
||||||
color="tertiary"
|
color="tertiary"
|
||||||
|
|||||||
@@ -19,10 +19,11 @@
|
|||||||
Trash,
|
Trash,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import { amMod, ban, isAdmin, remove, viewVotes } from './moderation'
|
import { amMod, ban, isAdmin, remove, viewVotes } from './moderation'
|
||||||
|
import type { Attachment } from 'svelte/attachments'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
item: PostView | CommentView
|
item: PostView | CommentView
|
||||||
target: Snippet<[boolean]>
|
target: Snippet<[Attachment, boolean]>
|
||||||
}
|
}
|
||||||
|
|
||||||
let { item = $bindable(), target: passedTarget }: Props = $props()
|
let { item = $bindable(), target: passedTarget }: Props = $props()
|
||||||
@@ -75,8 +76,8 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Menu placement="bottom-end">
|
<Menu placement="bottom-end">
|
||||||
{#snippet target()}
|
{#snippet target(attachment)}
|
||||||
{@render passedTarget(acting)}
|
{@render passedTarget(attachment, acting)}
|
||||||
{/snippet}
|
{/snippet}
|
||||||
{#if (profile.current?.user && amMod(profile.current.user, item.community)) || (profile.current?.user && isAdmin(profile.current.user))}
|
{#if (profile.current?.user && amMod(profile.current.user, item.community)) || (profile.current?.user && isAdmin(profile.current.user))}
|
||||||
<MenuDivider showLabel>
|
<MenuDivider showLabel>
|
||||||
|
|||||||
@@ -144,8 +144,9 @@
|
|||||||
>
|
>
|
||||||
{#if showCommunity && community}
|
{#if showCommunity && community}
|
||||||
<Popover>
|
<Popover>
|
||||||
{#snippet target()}
|
{#snippet target(attachment)}
|
||||||
<button
|
<button
|
||||||
|
{@attach attachment}
|
||||||
class={[
|
class={[
|
||||||
'row-span-2 shrink-0 mr-2 self-center group/btn',
|
'row-span-2 shrink-0 mr-2 self-center group/btn',
|
||||||
'bg-slate-200 dark:bg-zinc-800 rounded-lg cursor-pointer',
|
'bg-slate-200 dark:bg-zinc-800 rounded-lg cursor-pointer',
|
||||||
@@ -177,6 +178,7 @@
|
|||||||
rounding="2xl"
|
rounding="2xl"
|
||||||
elevation="high"
|
elevation="high"
|
||||||
class="max-w-2xl w-full max-h-128 overflow-auto"
|
class="max-w-2xl w-full max-h-128 overflow-auto"
|
||||||
|
data-autoclose="false"
|
||||||
>
|
>
|
||||||
{#await import('../community/CommunityHeader.svelte') then { default: CommunityHeader }}
|
{#await import('../community/CommunityHeader.svelte') then { default: CommunityHeader }}
|
||||||
<CommunityHeader {community} {subscribed} />
|
<CommunityHeader {community} {subscribed} />
|
||||||
|
|||||||
@@ -134,8 +134,9 @@
|
|||||||
{#if profile.current?.user && (amMod(profile.current.user, post.community) || isAdmin(profile.current.user))}
|
{#if profile.current?.user && (amMod(profile.current.user, post.community) || isAdmin(profile.current.user))}
|
||||||
{#await import('$lib/components/lemmy/moderation/ModerationMenu.svelte') then { default: ModerationMenu }}
|
{#await import('$lib/components/lemmy/moderation/ModerationMenu.svelte') then { default: ModerationMenu }}
|
||||||
<ModerationMenu bind:item={post}>
|
<ModerationMenu bind:item={post}>
|
||||||
{#snippet target(acting)}
|
{#snippet target(attachment, acting)}
|
||||||
<Button
|
<Button
|
||||||
|
{@attach attachment}
|
||||||
size="custom"
|
size="custom"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
@@ -172,8 +173,9 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<Menu placement="bottom-end">
|
<Menu placement="bottom-end">
|
||||||
{#snippet target()}
|
{#snippet target(popover)}
|
||||||
<Button
|
<Button
|
||||||
|
{@attach popover}
|
||||||
title={$t('post.actions.more.label')}
|
title={$t('post.actions.more.label')}
|
||||||
color="secondary"
|
color="secondary"
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
|
|||||||
@@ -82,20 +82,16 @@
|
|||||||
{/snippet}
|
{/snippet}
|
||||||
{$t('post.actions.more.share')}
|
{$t('post.actions.more.share')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
<!--svelte-ignore a11y_no_static_element_interactions -->
|
|
||||||
<!--svelte-ignore a11y_click_events_have_key_events-->
|
|
||||||
{#if !post.post.local}
|
{#if !post.post.local}
|
||||||
<div
|
|
||||||
class="aspect-square w-max m-1 grid place-items-center"
|
|
||||||
onclick={e => e.stopPropagation()}
|
|
||||||
>
|
|
||||||
<Menu>
|
<Menu>
|
||||||
{#snippet target()}
|
{#snippet target(attachment)}
|
||||||
<Button
|
<Button
|
||||||
|
{@attach attachment}
|
||||||
aria-label={$t('post.actions.more.label')}
|
aria-label={$t('post.actions.more.label')}
|
||||||
color="tertiary"
|
color="tertiary"
|
||||||
size="custom"
|
size="custom"
|
||||||
class="w-full h-full"
|
class="w-6 h-6 self-center"
|
||||||
|
data-autoclose="false"
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
<Icon
|
<Icon
|
||||||
@@ -120,7 +116,6 @@
|
|||||||
{$t('filter.location.local')}
|
{$t('filter.location.local')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
</Menu>
|
</Menu>
|
||||||
</div>
|
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{#if profile.current?.jwt}
|
{#if profile.current?.jwt}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
'transition-transform duration-300 ease-out',
|
'transition-transform duration-300 ease-out',
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Icon src={open ? Minus : Plus} size="16" micro class={[]} />
|
<Icon src={open ? Minus : Plus} size="15" micro class={[]} />
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -10,23 +10,21 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { page } from '$app/state'
|
import { page } from '$app/state'
|
||||||
|
import { t } from '$lib/i18n/translations'
|
||||||
import { Button, Material, toast } from 'mono-svelte'
|
import { Button, Material, toast } from 'mono-svelte'
|
||||||
|
import { focusTrap } from 'svelte-focus-trap'
|
||||||
import { Icon, Share, XMark } from 'svelte-hero-icons'
|
import { Icon, Share, XMark } from 'svelte-hero-icons'
|
||||||
import { expoOut } from 'svelte/easing'
|
import { expoOut } from 'svelte/easing'
|
||||||
import { fade, scale } from 'svelte/transition'
|
import { fade, scale } from 'svelte/transition'
|
||||||
import { focusTrap } from 'svelte-focus-trap'
|
|
||||||
import { t } from '$lib/i18n/translations'
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
/**
|
/**
|
||||||
* The full-resolution image URL
|
* The full-resolution image URL
|
||||||
*/
|
*/
|
||||||
alt?: string
|
alt?: string
|
||||||
class?: string
|
|
||||||
children?: import('svelte').Snippet
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let { alt = '', class: clazz = '', children }: Props = $props()
|
let { alt = '' }: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if page.state.openImage || '' != ''}
|
{#if page.state.openImage || '' != ''}
|
||||||
@@ -88,7 +86,3 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<button onclick={() => history.back()} class="contents {clazz}">
|
|
||||||
{@render children?.()}
|
|
||||||
</button>
|
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
pageHeader &&
|
pageHeader &&
|
||||||
`w-[calc(100%+1.5rem)] sm:w-[calc(100%+3rem)]
|
`w-[calc(100%+1.5rem)] sm:w-[calc(100%+3rem)]
|
||||||
bg-slate-100 dark:bg-zinc-950 -mx-3 sm:-mx-6 sm:px-6 sm:pb-6 px-4 pb-4 -mt-64 pt-64
|
bg-slate-100 dark:bg-zinc-950 -mx-3 sm:-mx-6 sm:px-6 sm:pb-6 px-4 pb-4 -mt-64 pt-64
|
||||||
border-b border-slate-200 dark:border-zinc-900 margin z-0`,
|
border-b border-slate-200 dark:border-zinc-900 margin z-0 mb-3 sm:mb-6`,
|
||||||
]}
|
]}
|
||||||
{style}
|
{style}
|
||||||
aria-label={$t('aria.element.pageHeader')}
|
aria-label={$t('aria.element.pageHeader')}
|
||||||
|
|||||||
@@ -23,22 +23,47 @@
|
|||||||
style = 'header',
|
style = 'header',
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
|
|
||||||
function isSelected(url: URL, href?: SvelteURL) {
|
let matchType = $derived<('search' | 'pathname')[]>(
|
||||||
if (href?.search != '') return href?.search == url.search
|
routes.map(i =>
|
||||||
else if (url.search == '') return href?.pathname == url.pathname
|
new URL(`https://example.com${i.href}`)?.search != ''
|
||||||
|
? 'search'
|
||||||
|
: 'pathname',
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
// i am on 2 hours of sleep i apologize
|
||||||
|
function isSelected(url: URL, href: SvelteURL, type: 'search' | 'pathname') {
|
||||||
|
const currentSearch = new Set(url.searchParams.values())
|
||||||
|
const hrefSearch = new Set(href.searchParams.values())
|
||||||
|
// checks if there is any
|
||||||
|
const usePathname = !routes.some(
|
||||||
|
i =>
|
||||||
|
new Set(
|
||||||
|
new URL(`https://example.com${i.href}`).searchParams.values(),
|
||||||
|
).intersection(currentSearch).size > 0,
|
||||||
|
)
|
||||||
|
|
||||||
|
const hasSearchParam = hrefSearch.intersection(currentSearch).size > 0
|
||||||
|
|
||||||
|
if (hasSearchParam && !usePathname) return hasSearchParam
|
||||||
|
else if ((url.search == '' || usePathname) && type == 'pathname')
|
||||||
|
return href.pathname == url.pathname
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<nav
|
<nav
|
||||||
class={[
|
class={[
|
||||||
'flex flex-row items-center justify-center sm:justify-start my-2 sm:mt-0 flex-wrap z-20',
|
'flex flex-row items-center my-2 sm:mt-0 flex-wrap z-20',
|
||||||
style == 'header' ? 'p-1 gap-x-8 gap-y-4' : 'gap-2',
|
style == 'header'
|
||||||
|
? 'p-1 gap-x-8 gap-y-4 justify-center sm:justify-start'
|
||||||
|
: 'gap-2',
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{#each routes as route (route.href)}
|
{#each routes as route, index (route.href)}
|
||||||
{@const selected = isSelected(
|
{@const selected = isSelected(
|
||||||
page.url,
|
page.url,
|
||||||
new SvelteURL(`${page.url.origin}${route.href}`),
|
new SvelteURL(`${page.url.origin}${route.href}`),
|
||||||
|
matchType[index],
|
||||||
)}
|
)}
|
||||||
{#if style == 'header'}
|
{#if style == 'header'}
|
||||||
<a
|
<a
|
||||||
@@ -61,3 +86,7 @@
|
|||||||
{/each}
|
{/each}
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
{#if style == 'subpage'}
|
||||||
|
<div class="h-3"></div>
|
||||||
|
{/if}
|
||||||
@@ -105,8 +105,9 @@
|
|||||||
href="/create"
|
href="/create"
|
||||||
/>
|
/>
|
||||||
<Menu placement="bottom">
|
<Menu placement="bottom">
|
||||||
{#snippet target()}
|
{#snippet target(attachment)}
|
||||||
<button
|
<button
|
||||||
|
{@attach attachment}
|
||||||
class="w-10 h-10 rounded-full border-slate-200 dark:border-zinc-700
|
class="w-10 h-10 rounded-full border-slate-200 dark:border-zinc-700
|
||||||
transition-all bg-slate-50 dark:bg-zinc-900 relative
|
transition-all bg-slate-50 dark:bg-zinc-900 relative
|
||||||
hover:bg-slate-200 dark:hover:bg-zinc-700 group cursor-pointer"
|
hover:bg-slate-200 dark:hover:bg-zinc-700 group cursor-pointer"
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
MenuButton,
|
MenuButton,
|
||||||
MenuDivider,
|
MenuDivider,
|
||||||
modal,
|
modal,
|
||||||
Modal,
|
|
||||||
Option,
|
Option,
|
||||||
Select,
|
Select,
|
||||||
Spinner,
|
Spinner,
|
||||||
@@ -41,8 +40,6 @@
|
|||||||
UserCircle,
|
UserCircle,
|
||||||
UserGroup,
|
UserGroup,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
|
|
||||||
let showInstance = $state(false)
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#snippet siteSnippet()}
|
{#snippet siteSnippet()}
|
||||||
@@ -136,18 +133,17 @@
|
|||||||
{/snippet}
|
{/snippet}
|
||||||
{$t('nav.menu.settings')}
|
{$t('nav.menu.settings')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
<!--svelte-ignore a11y_click_events_have_key_events-->
|
<Select bind:value={theme.colorScheme} size="sm" placement="left">
|
||||||
<!--svelte-ignore a11y_no_static_element_interactions-->
|
{#snippet target(attachment)}
|
||||||
<div onclick={e => e.stopPropagation()}>
|
|
||||||
<Select bind:value={theme.colorScheme} size="sm">
|
|
||||||
{#snippet target()}
|
|
||||||
<MenuButton
|
<MenuButton
|
||||||
|
{@attach attachment}
|
||||||
icon={theme.colorScheme == 'system'
|
icon={theme.colorScheme == 'system'
|
||||||
? ComputerDesktop
|
? ComputerDesktop
|
||||||
: theme.colorScheme == 'light'
|
: theme.colorScheme == 'light'
|
||||||
? Sun
|
? Sun
|
||||||
: Moon}
|
: Moon}
|
||||||
class=" w-full"
|
class=" w-full"
|
||||||
|
nest
|
||||||
>
|
>
|
||||||
{$t('nav.menu.colorscheme.label')}
|
{$t('nav.menu.colorscheme.label')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
@@ -161,8 +157,7 @@
|
|||||||
{$t('nav.menu.colorscheme.dark')}
|
{$t('nav.menu.colorscheme.dark')}
|
||||||
</Option>
|
</Option>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
</Select>
|
</Select>
|
||||||
</div>
|
|
||||||
<MenuButton href="/theme">
|
<MenuButton href="/theme">
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
<Icon src={Swatch} size="16" micro />
|
<Icon src={Swatch} size="16" micro />
|
||||||
|
|||||||
@@ -25,8 +25,9 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Menu placement="bottom">
|
<Menu placement="bottom">
|
||||||
{#snippet target()}
|
{#snippet target(attachment)}
|
||||||
<Button
|
<Button
|
||||||
|
{@attach attachment}
|
||||||
color="tertiary"
|
color="tertiary"
|
||||||
alignment="left"
|
alignment="left"
|
||||||
size="md"
|
size="md"
|
||||||
|
|||||||
@@ -11,8 +11,10 @@
|
|||||||
import {
|
import {
|
||||||
ArrowLeftOnRectangle,
|
ArrowLeftOnRectangle,
|
||||||
Bookmark,
|
Bookmark,
|
||||||
|
ChevronUpDown,
|
||||||
Cog6Tooth,
|
Cog6Tooth,
|
||||||
ComputerDesktop,
|
ComputerDesktop,
|
||||||
|
Icon,
|
||||||
Identification,
|
Identification,
|
||||||
Inbox,
|
Inbox,
|
||||||
Moon,
|
Moon,
|
||||||
@@ -83,15 +85,16 @@
|
|||||||
icon={Cog6Tooth}
|
icon={Cog6Tooth}
|
||||||
/>
|
/>
|
||||||
<Select bind:value={theme.colorScheme} size="sm">
|
<Select bind:value={theme.colorScheme} size="sm">
|
||||||
{#snippet target()}
|
{#snippet target(attachment)}
|
||||||
<SidebarButton
|
<SidebarButton
|
||||||
|
{@attach attachment}
|
||||||
label={$t('nav.menu.colorscheme.label')}
|
label={$t('nav.menu.colorscheme.label')}
|
||||||
icon={theme.colorScheme == 'system'
|
icon={theme.colorScheme == 'system'
|
||||||
? ComputerDesktop
|
? ComputerDesktop
|
||||||
: theme.colorScheme == 'light'
|
: theme.colorScheme == 'light'
|
||||||
? Sun
|
? Sun
|
||||||
: Moon}
|
: Moon}
|
||||||
class=" w-full"
|
class="w-full relative"
|
||||||
>
|
>
|
||||||
<Option value="system" class="hidden" icon={ComputerDesktop}>
|
<Option value="system" class="hidden" icon={ComputerDesktop}>
|
||||||
{$t('nav.menu.colorscheme.system')}
|
{$t('nav.menu.colorscheme.system')}
|
||||||
@@ -102,6 +105,7 @@
|
|||||||
<Option value="dark" class="hidden" icon={Moon}>
|
<Option value="dark" class="hidden" icon={Moon}>
|
||||||
{$t('nav.menu.colorscheme.dark')}
|
{$t('nav.menu.colorscheme.dark')}
|
||||||
</Option>
|
</Option>
|
||||||
|
<Icon micro size="16" src={ChevronUpDown} class="ml-auto" />
|
||||||
</SidebarButton>
|
</SidebarButton>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
</Select>
|
</Select>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { HTMLAttributes } from 'svelte/elements'
|
import type { ClassValue, HTMLAttributes } from 'svelte/elements'
|
||||||
|
|
||||||
interface Props extends HTMLAttributes<HTMLSpanElement> {
|
interface Props extends HTMLAttributes<HTMLSpanElement> {
|
||||||
for?: string | undefined
|
for?: string | undefined
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
* The `text` prop will take precedence over the slot.
|
* The `text` prop will take precedence over the slot.
|
||||||
*/
|
*/
|
||||||
text?: string | undefined
|
text?: string | undefined
|
||||||
class?: string
|
class?: ClassValue
|
||||||
children?: import('svelte').Snippet
|
children?: import('svelte').Snippet
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,16 +20,14 @@
|
|||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:element
|
<label
|
||||||
this={forID ? 'label' : 'span'}
|
|
||||||
{...rest}
|
{...rest}
|
||||||
for={forID}
|
for={forID}
|
||||||
class="text-sm text-slate-800 dark:text-zinc-200 font-medium w-full {clazz ||
|
class={['text-sm text-slate-800 dark:text-zinc-200 font-medium', clazz]}
|
||||||
''}"
|
|
||||||
>
|
>
|
||||||
{#if text}
|
{#if text}
|
||||||
{text}
|
{text}
|
||||||
{:else if children}
|
{:else if children}
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
{/if}
|
{/if}
|
||||||
</svelte:element>
|
</label>
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
>
|
>
|
||||||
target?: Snippet
|
target?: Snippet<[Attachment]>
|
||||||
oncontextmenu?: HTMLSelectAttributes['oncontextmenu']
|
oncontextmenu?: HTMLSelectAttributes['oncontextmenu']
|
||||||
onchange?: HTMLSelectAttributes['onchange']
|
onchange?: HTMLSelectAttributes['onchange']
|
||||||
placement?: Placement
|
placement?: Placement
|
||||||
@@ -35,12 +35,14 @@
|
|||||||
|
|
||||||
<script lang="ts" generics="T">
|
<script lang="ts" generics="T">
|
||||||
import { setContext, tick, type Snippet } from 'svelte'
|
import { setContext, tick, type Snippet } from 'svelte'
|
||||||
|
import type { Placement } from 'svelte-floating-ui/core'
|
||||||
import {
|
import {
|
||||||
CheckCircle,
|
CheckCircle,
|
||||||
ChevronUpDown,
|
ChevronUpDown,
|
||||||
Icon,
|
Icon,
|
||||||
type IconSource,
|
type IconSource,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
|
import type { Attachment } from 'svelte/attachments'
|
||||||
import type { ClassValue, HTMLSelectAttributes } from 'svelte/elements'
|
import type { ClassValue, HTMLSelectAttributes } from 'svelte/elements'
|
||||||
import {
|
import {
|
||||||
buttonColor,
|
buttonColor,
|
||||||
@@ -52,8 +54,6 @@
|
|||||||
import Menu from '../../popover/Menu.svelte'
|
import Menu from '../../popover/Menu.svelte'
|
||||||
import MenuButton from '../../popover/MenuButton.svelte'
|
import MenuButton from '../../popover/MenuButton.svelte'
|
||||||
import Label from '../Label.svelte'
|
import Label from '../Label.svelte'
|
||||||
import { generateID } from '../helper.js'
|
|
||||||
import type { Placement } from 'svelte-floating-ui/core'
|
|
||||||
|
|
||||||
let open = $state(false)
|
let open = $state(false)
|
||||||
let element: HTMLSelectElement | undefined = $state()
|
let element: HTMLSelectElement | undefined = $state()
|
||||||
@@ -78,7 +78,6 @@
|
|||||||
label = undefined,
|
label = undefined,
|
||||||
size = 'md',
|
size = 'md',
|
||||||
shadow = 'none',
|
shadow = 'none',
|
||||||
id = generateID(),
|
|
||||||
class: clazz = '',
|
class: clazz = '',
|
||||||
baseClass = '',
|
baseClass = '',
|
||||||
selectClass = '',
|
selectClass = '',
|
||||||
@@ -88,15 +87,23 @@
|
|||||||
oncontextmenu,
|
oncontextmenu,
|
||||||
onchange,
|
onchange,
|
||||||
placement = 'bottom',
|
placement = 'bottom',
|
||||||
target,
|
target: passedTarget,
|
||||||
...rest
|
...rest
|
||||||
}: Props<T> = $props()
|
}: Props<T> = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#snippet selectTarget()}
|
{#snippet selectTarget(attachment: Attachment)}
|
||||||
|
<Label text={label} class={['space-y-1 relative', clazz, baseClass]}>
|
||||||
|
{@render customLabel?.()}
|
||||||
|
<Icon
|
||||||
|
src={ChevronUpDown}
|
||||||
|
micro
|
||||||
|
size="16"
|
||||||
|
class="absolute right-1.5 bottom-1 box-border pointer-events-none z-10 text-slate-600 dark:text-zinc-400"
|
||||||
|
/>
|
||||||
<select
|
<select
|
||||||
|
{@attach attachment}
|
||||||
{...rest}
|
{...rest}
|
||||||
{id}
|
|
||||||
bind:this={element}
|
bind:this={element}
|
||||||
class={[
|
class={[
|
||||||
buttonSize[size],
|
buttonSize[size],
|
||||||
@@ -123,17 +130,14 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
</select>
|
</select>
|
||||||
|
</Label>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
|
|
||||||
<div class={['flex flex-col gap-1', clazz, baseClass]}>
|
<Menu bind:open {placement}>
|
||||||
{#if customLabel || label}
|
{#snippet target(attachment)}
|
||||||
<Label for={id} text={label}>
|
{@const render = passedTarget ?? selectTarget}
|
||||||
{@render customLabel?.()}
|
{@render render?.(attachment)}
|
||||||
</Label>
|
{/snippet}
|
||||||
{/if}
|
|
||||||
|
|
||||||
<div class="w-full relative">
|
|
||||||
<Menu bind:open {placement} target={target ?? selectTarget}>
|
|
||||||
{#each context.options as option (option)}
|
{#each context.options as option (option)}
|
||||||
{#if customOption}{@render customOption({
|
{#if customOption}{@render customOption({
|
||||||
option,
|
option,
|
||||||
@@ -177,11 +181,3 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
</Menu>
|
</Menu>
|
||||||
<Icon
|
|
||||||
src={ChevronUpDown}
|
|
||||||
micro
|
|
||||||
size="16"
|
|
||||||
class="absolute right-0 top-1/4 mx-1.5 box-border pointer-events-none"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -8,27 +8,26 @@
|
|||||||
type Strategy,
|
type Strategy,
|
||||||
} from '@floating-ui/core'
|
} from '@floating-ui/core'
|
||||||
import Popover from '../popover/Popover.svelte'
|
import Popover from '../popover/Popover.svelte'
|
||||||
|
import type { Snippet } from 'svelte'
|
||||||
|
import type { Attachment } from 'svelte/attachments'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
openOnHover?: boolean
|
openOnHover?: boolean
|
||||||
open?: boolean
|
open?: boolean
|
||||||
manual?: boolean
|
|
||||||
placement?: Placement
|
placement?: Placement
|
||||||
middleware?: Middleware[]
|
middleware?: Middleware[]
|
||||||
strategy?: Strategy
|
strategy?: Strategy
|
||||||
class?: string
|
class?: string
|
||||||
target?: import('svelte').Snippet
|
target?: Snippet<[Attachment]>
|
||||||
children?: import('svelte').Snippet<[boolean]>
|
children?: import('svelte').Snippet<[boolean]>
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
openOnHover = false,
|
openOnHover = false,
|
||||||
open = $bindable(false),
|
open = $bindable(false),
|
||||||
manual = false,
|
|
||||||
placement = 'bottom-start',
|
placement = 'bottom-start',
|
||||||
middleware = [offset(6), shift({ padding: 6 }), flip()],
|
middleware = [offset(6), shift({ padding: 6 }), flip()],
|
||||||
strategy = 'absolute',
|
strategy = 'absolute',
|
||||||
class: clazz = '',
|
|
||||||
target,
|
target,
|
||||||
children,
|
children,
|
||||||
...rest
|
...rest
|
||||||
@@ -40,12 +39,10 @@
|
|||||||
{placement}
|
{placement}
|
||||||
{middleware}
|
{middleware}
|
||||||
{strategy}
|
{strategy}
|
||||||
{manual}
|
{target}
|
||||||
{...rest}
|
{...rest}
|
||||||
bind:open
|
bind:open
|
||||||
popoverClass="rounded-xl w-full backdrop-blur-md max-w-72"
|
popoverClass="rounded-xl w-full backdrop-blur-md max-w-72"
|
||||||
class={clazz}
|
|
||||||
{target}
|
|
||||||
>
|
>
|
||||||
{#snippet popover()}
|
{#snippet popover()}
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
type ButtonColor,
|
type ButtonColor,
|
||||||
type ButtonProps,
|
type ButtonProps,
|
||||||
} from '../button/Button.svelte'
|
} from '../button/Button.svelte'
|
||||||
import { Icon, type IconSource } from 'svelte-hero-icons'
|
import { ChevronRight, Icon, type IconSource } from 'svelte-hero-icons'
|
||||||
import type { ClassValue } from 'svelte/elements'
|
import type { ClassValue } from 'svelte/elements'
|
||||||
|
|
||||||
interface Props extends ButtonProps {
|
interface Props extends ButtonProps {
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
prefix?: Snippet
|
prefix?: Snippet
|
||||||
children?: Snippet
|
children?: Snippet
|
||||||
suffix?: Snippet
|
suffix?: Snippet
|
||||||
|
nest?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
@@ -30,6 +31,7 @@
|
|||||||
prefix: passedPrefix,
|
prefix: passedPrefix,
|
||||||
children,
|
children,
|
||||||
suffix: passedSuffix,
|
suffix: passedSuffix,
|
||||||
|
nest,
|
||||||
...rest
|
...rest
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
@@ -48,6 +50,7 @@
|
|||||||
{alignment}
|
{alignment}
|
||||||
{href}
|
{href}
|
||||||
{disabled}
|
{disabled}
|
||||||
|
data-autoclose={nest ? 'false' : 'true'}
|
||||||
shadow="none"
|
shadow="none"
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
@@ -67,5 +70,8 @@
|
|||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
{#snippet suffix()}
|
{#snippet suffix()}
|
||||||
{@render passedSuffix?.()}
|
{@render passedSuffix?.()}
|
||||||
|
{#if nest}
|
||||||
|
<Icon src={ChevronRight} size="16" micro class="ml-auto" />
|
||||||
|
{/if}
|
||||||
{/snippet}
|
{/snippet}
|
||||||
</Button>
|
</Button>
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
} from '@floating-ui/core'
|
} from '@floating-ui/core'
|
||||||
import { createFloatingActions } from 'svelte-floating-ui'
|
import { createFloatingActions } from 'svelte-floating-ui'
|
||||||
import { focusTrap } from 'svelte-focus-trap'
|
import { focusTrap } from 'svelte-focus-trap'
|
||||||
|
import type { Attachment } from 'svelte/attachments'
|
||||||
import { expoOut } from 'svelte/easing'
|
import { expoOut } from 'svelte/easing'
|
||||||
import { scale } from 'svelte/transition'
|
import { scale } from 'svelte/transition'
|
||||||
import { Material } from '../index'
|
import { Material } from '../index'
|
||||||
@@ -21,10 +22,8 @@
|
|||||||
placement?: Placement
|
placement?: Placement
|
||||||
middleware?: Middleware[]
|
middleware?: Middleware[]
|
||||||
strategy?: Strategy
|
strategy?: Strategy
|
||||||
manual?: boolean
|
|
||||||
popoverClass?: string
|
popoverClass?: string
|
||||||
class?: string
|
target?: import('svelte').Snippet<[Attachment]>
|
||||||
target?: import('svelte').Snippet
|
|
||||||
popover?: import('svelte').Snippet<[boolean]>
|
popover?: import('svelte').Snippet<[boolean]>
|
||||||
children?: import('svelte').Snippet<[boolean]>
|
children?: import('svelte').Snippet<[boolean]>
|
||||||
}
|
}
|
||||||
@@ -36,17 +35,12 @@
|
|||||||
placement = 'bottom-start',
|
placement = 'bottom-start',
|
||||||
middleware = [offset(6), shift(), flip()],
|
middleware = [offset(6), shift(), flip()],
|
||||||
strategy = 'fixed',
|
strategy = 'fixed',
|
||||||
manual = false,
|
|
||||||
popoverClass = '',
|
popoverClass = '',
|
||||||
class: clazz = '',
|
|
||||||
target,
|
target,
|
||||||
popover,
|
popover,
|
||||||
children,
|
children,
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
|
|
||||||
let canUseContents = $state(true)
|
|
||||||
|
|
||||||
let el = $state<HTMLElement>()
|
|
||||||
let popoverEl = $state<HTMLElement>()
|
let popoverEl = $state<HTMLElement>()
|
||||||
|
|
||||||
let origins: Record<Placement, string> = {
|
let origins: Record<Placement, string> = {
|
||||||
@@ -75,66 +69,54 @@
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const customFloatingContent = (node: HTMLDivElement) => {
|
const menuAttach: Attachment = element => {
|
||||||
floatingContent(node)
|
const e = element as HTMLButtonElement
|
||||||
|
|
||||||
|
const mouseLeave = () => (openOnHover ? (open = false) : false)
|
||||||
|
const focus = () => (openOnHover ? (open = true) : false)
|
||||||
|
const focusout = () => (openOnHover ? (open = false) : false)
|
||||||
|
const click = () => {
|
||||||
|
open = !open
|
||||||
|
|
||||||
|
if (autoClose) {
|
||||||
|
const clickHandler = (event: Event) => {
|
||||||
|
if (!e) return
|
||||||
|
|
||||||
|
const target = event.target as Element | null
|
||||||
|
|
||||||
|
if (!e?.contains(event.target as Element | null)) {
|
||||||
|
if (target?.closest("[data-autoclose='false']") == null) {
|
||||||
|
open = false
|
||||||
|
document.removeEventListener('click', clickHandler)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
document.addEventListener('click', clickHandler)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const keydown = (event: KeyboardEvent) => {
|
||||||
|
if (event.key === 'Escape') open = false
|
||||||
}
|
}
|
||||||
|
|
||||||
const customFloatingRef = (node: HTMLDivElement) => {
|
e.addEventListener('mouseleave', mouseLeave)
|
||||||
const n = node.children.item(0)
|
e.addEventListener('focus', focus)
|
||||||
|
e.addEventListener('focusout', focusout)
|
||||||
|
e.addEventListener('click', click)
|
||||||
|
e.addEventListener('keydown', keydown)
|
||||||
|
|
||||||
// @ts-expect-error svelte hell
|
floatingRef(e)
|
||||||
if (n) floatingRef(n)
|
|
||||||
else {
|
return () => {
|
||||||
canUseContents = false
|
e.removeEventListener('mouseleave', mouseLeave)
|
||||||
floatingRef(node)
|
e.removeEventListener('focus', focus)
|
||||||
|
e.removeEventListener('focusout', focusout)
|
||||||
|
e.removeEventListener('click', click)
|
||||||
|
e.removeEventListener('keydown', keydown)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:body
|
{@render target?.(menuAttach)}
|
||||||
onclick={e => {
|
|
||||||
if (openOnHover) return
|
|
||||||
|
|
||||||
// @ts-expect-error svelte hell
|
|
||||||
if (!el?.contains(e.target) && open) {
|
|
||||||
if (!autoClose) {
|
|
||||||
// @ts-expect-error svelte hell
|
|
||||||
if (popoverEl && !popoverEl.contains(e.target)) {
|
|
||||||
open = false
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
open = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
onkeydown={async e => {
|
|
||||||
if (open && e.key == 'Escape') {
|
|
||||||
open = false
|
|
||||||
// @ts-expect-error svelte hell
|
|
||||||
el?.firstChild.focus()
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{#if target}
|
|
||||||
<div
|
|
||||||
onmouseover={() => (openOnHover ? (open = true) : false)}
|
|
||||||
onmouseleave={() => (openOnHover ? (open = false) : false)}
|
|
||||||
onfocus={() => (openOnHover ? (open = true) : false)}
|
|
||||||
onfocusout={() => (openOnHover ? (open = false) : false)}
|
|
||||||
onclick={() => (!openOnHover && !manual ? (open = !open) : false)}
|
|
||||||
onkeydown={e => {
|
|
||||||
if (e.key == 'Escape') open = false
|
|
||||||
}}
|
|
||||||
tabindex="0"
|
|
||||||
role="button"
|
|
||||||
class="{canUseContents ? 'contents text-left' : 'w-max h-max'} {clazz}"
|
|
||||||
bind:this={el}
|
|
||||||
use:customFloatingRef
|
|
||||||
>
|
|
||||||
{@render target?.()}
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
{#if open}
|
{#if open}
|
||||||
<Portal class="z-150">
|
<Portal class="z-150">
|
||||||
@@ -146,7 +128,7 @@
|
|||||||
easing: expoOut,
|
easing: expoOut,
|
||||||
}}
|
}}
|
||||||
class="z-150 {popoverClass}"
|
class="z-150 {popoverClass}"
|
||||||
use:customFloatingContent
|
use:floatingContent
|
||||||
use:focusTrap
|
use:focusTrap
|
||||||
bind:this={popoverEl}
|
bind:this={popoverEl}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -65,9 +65,10 @@
|
|||||||
|
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
<Menu bind:open={openMenu}>
|
<Menu bind:open={openMenu}>
|
||||||
{#snippet target()}
|
{#snippet target(attachment)}
|
||||||
{#if input}{@render input()}{:else}
|
{#if input}{@render input()}{:else}
|
||||||
<TextInput
|
<TextInput
|
||||||
|
{@attach attachment}
|
||||||
bind:value={query}
|
bind:value={query}
|
||||||
oninput={e => {
|
oninput={e => {
|
||||||
searching = true
|
searching = true
|
||||||
|
|||||||
@@ -3,9 +3,6 @@ import { env } from '$env/dynamic/public'
|
|||||||
import { locale } from './i18n/translations'
|
import { locale } from './i18n/translations'
|
||||||
import { browser } from '$app/environment'
|
import { browser } from '$app/environment'
|
||||||
|
|
||||||
console.log('Using the following default settings from the environment:')
|
|
||||||
console.log(env)
|
|
||||||
|
|
||||||
export type View = 'cozy' | 'compact'
|
export type View = 'cozy' | 'compact'
|
||||||
|
|
||||||
export const SSR_ENABLED = env.PUBLIC_SSR_ENABLED?.toLowerCase() == 'true'
|
export const SSR_ENABLED = env.PUBLIC_SSR_ENABLED?.toLowerCase() == 'true'
|
||||||
@@ -230,7 +227,7 @@ function isObject(item: object) {
|
|||||||
* @param target
|
* @param target
|
||||||
* @param ...sources
|
* @param ...sources
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line
|
|
||||||
function mergeDeep(target: any, ...sources: any[]) {
|
function mergeDeep(target: any, ...sources: any[]) {
|
||||||
if (!sources.length) return target
|
if (!sources.length) return target
|
||||||
const source = sources.shift()
|
const source = sources.shift()
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import { browser } from '$app/environment'
|
import { browser } from '$app/environment'
|
||||||
import { env } from '$env/dynamic/public'
|
|
||||||
import { settings } from '$lib/settings.svelte'
|
import { settings } from '$lib/settings.svelte'
|
||||||
import { aliases, loadTranslations } from '$lib/i18n/translations.js'
|
import { aliases, loadTranslations } from '$lib/i18n/translations.js'
|
||||||
|
|
||||||
export const ssr = (env.PUBLIC_SSR_ENABLED?.toLowerCase() ?? 'false') == 'true'
|
export const ssr = false
|
||||||
|
|
||||||
export const load = async () => {
|
export const load = async () => {
|
||||||
if (browser) {
|
if (browser) {
|
||||||
|
|||||||
+45
-11
@@ -6,6 +6,7 @@
|
|||||||
import PostFeed from '$lib/components/lemmy/post/feed/PostFeed.svelte'
|
import PostFeed from '$lib/components/lemmy/post/feed/PostFeed.svelte'
|
||||||
import VirtualFeed from '$lib/components/lemmy/post/feed/VirtualFeed.svelte'
|
import VirtualFeed from '$lib/components/lemmy/post/feed/VirtualFeed.svelte'
|
||||||
import EndPlaceholder from '$lib/components/ui/EndPlaceholder.svelte'
|
import EndPlaceholder from '$lib/components/ui/EndPlaceholder.svelte'
|
||||||
|
import Skeleton from '$lib/components/ui/generic/Skeleton.svelte'
|
||||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||||
import Pageination from '$lib/components/ui/Pageination.svelte'
|
import Pageination from '$lib/components/ui/Pageination.svelte'
|
||||||
import { t } from '$lib/i18n/translations.js'
|
import { t } from '$lib/i18n/translations.js'
|
||||||
@@ -13,16 +14,19 @@
|
|||||||
import { postFeeds } from '$lib/lemmy/postfeed.svelte.js'
|
import { postFeeds } from '$lib/lemmy/postfeed.svelte.js'
|
||||||
import { settings } from '$lib/settings.svelte.js'
|
import { settings } from '$lib/settings.svelte.js'
|
||||||
import Button from 'mono-svelte/button/Button.svelte'
|
import Button from 'mono-svelte/button/Button.svelte'
|
||||||
|
import { onMount } from 'svelte'
|
||||||
import { ArrowRight, ChartBar, Icon } from 'svelte-hero-icons'
|
import { ArrowRight, ChartBar, Icon } from 'svelte-hero-icons'
|
||||||
|
|
||||||
let { data = $bindable() } = $props()
|
let { data = $bindable() } = $props()
|
||||||
|
|
||||||
let type = $state(data.feed.value.type_)
|
onMount(async () => {
|
||||||
let sort = $state(data.feed.value.sort)
|
await data.feed.value
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
if (type) settings.defaultSort.feed = type
|
if (data.filters.value.type_)
|
||||||
if (sort) settings.defaultSort.sort = sort
|
settings.defaultSort.feed = data.filters.value.type_
|
||||||
|
if (data.filters.value.sort)
|
||||||
|
settings.defaultSort.sort = data.filters.value.sort
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
const FeedComponent = $derived(
|
const FeedComponent = $derived(
|
||||||
@@ -42,10 +46,19 @@
|
|||||||
|
|
||||||
{#snippet extended()}
|
{#snippet extended()}
|
||||||
<form class="flex items-center gap-2" method="get" action="/">
|
<form class="flex items-center gap-2" method="get" action="/">
|
||||||
{#if type}
|
{#if data.filters.value.type_}
|
||||||
<Location name="type" navigate bind:selected={type} />
|
<Location
|
||||||
|
name="type"
|
||||||
|
navigate
|
||||||
|
bind:selected={data.filters.value.type_}
|
||||||
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
<Sort placement="bottom" name="sort" navigate bind:selected={sort} />
|
<Sort
|
||||||
|
placement="bottom"
|
||||||
|
name="sort"
|
||||||
|
navigate
|
||||||
|
bind:selected={data.filters.value.sort}
|
||||||
|
/>
|
||||||
<ViewSelect placement="bottom" />
|
<ViewSelect placement="bottom" />
|
||||||
|
|
||||||
<noscript>
|
<noscript>
|
||||||
@@ -57,9 +70,29 @@
|
|||||||
{/snippet}
|
{/snippet}
|
||||||
</Header>
|
</Header>
|
||||||
|
|
||||||
|
<!-- <EndPlaceholder size="md">
|
||||||
|
{$t('cards.community.activeDay')}
|
||||||
|
{#snippet action()}
|
||||||
|
<span class="text-primary-900 dark:text-primary-100">
|
||||||
|
{site.data?.site_view.counts.users_active_day.toString()}
|
||||||
|
</span>
|
||||||
|
{/snippet}
|
||||||
|
</EndPlaceholder> -->
|
||||||
|
|
||||||
|
{#await data.feed.value}
|
||||||
|
{#each new Array(5) as _, index}{_}
|
||||||
|
<div
|
||||||
|
class="animate-pop-in"
|
||||||
|
style="animation-delay: {index * 50}ms; opacity: 0; width: {(1 /
|
||||||
|
((index + 1) % 3)) *
|
||||||
|
100}%"
|
||||||
|
>
|
||||||
|
<Skeleton />
|
||||||
|
</div>{/each}
|
||||||
|
{:then feed}
|
||||||
<FeedComponent
|
<FeedComponent
|
||||||
bind:posts={data.feed.value.posts.posts}
|
bind:posts={feed.posts.posts}
|
||||||
bind:feedData={() => data.feed.value, v => (postFeeds.value.main.data = v)}
|
bind:feedData={() => feed, v => (postFeeds.value.main.data = v)}
|
||||||
feedId="main"
|
feedId="main"
|
||||||
/>
|
/>
|
||||||
<svelte:element
|
<svelte:element
|
||||||
@@ -76,7 +109,7 @@
|
|||||||
})}
|
})}
|
||||||
{#snippet action()}
|
{#snippet action()}
|
||||||
<Pageination
|
<Pageination
|
||||||
cursor={{ next: data.feed.value.cursor.next }}
|
cursor={{ next: feed.cursor.next }}
|
||||||
href={page =>
|
href={page =>
|
||||||
typeof page == 'number' ? `?page=${page}` : `?cursor=${page}`}
|
typeof page == 'number' ? `?page=${page}` : `?cursor=${page}`}
|
||||||
back={false}
|
back={false}
|
||||||
@@ -84,4 +117,5 @@
|
|||||||
{/snippet}
|
{/snippet}
|
||||||
</EndPlaceholder>
|
</EndPlaceholder>
|
||||||
</svelte:element>
|
</svelte:element>
|
||||||
|
{/await}
|
||||||
</div>
|
</div>
|
||||||
+9
-5
@@ -1,6 +1,6 @@
|
|||||||
import { t } from '$lib/i18n/translations.js'
|
import { t } from '$lib/i18n/translations.js'
|
||||||
import { postFeed } from '$lib/lemmy/postfeed.svelte.js'
|
import { postFeed } from '$lib/lemmy/postfeed.svelte.js'
|
||||||
import { ReactiveState } from '$lib/promise.svelte.js'
|
import { ReactiveState, awaitIfServer } from '$lib/promise.svelte.js'
|
||||||
import { settings } from '$lib/settings.svelte'
|
import { settings } from '$lib/settings.svelte'
|
||||||
import type { ListingType, SortType } from 'lemmy-js-client'
|
import type { ListingType, SortType } from 'lemmy-js-client'
|
||||||
import { ChevronDoubleUp } from 'svelte-hero-icons'
|
import { ChevronDoubleUp } from 'svelte-hero-icons'
|
||||||
@@ -13,9 +13,7 @@ export async function load({ url, fetch }) {
|
|||||||
const listingType: ListingType =
|
const listingType: ListingType =
|
||||||
(url.searchParams.get('type') as ListingType) || settings.defaultSort.feed
|
(url.searchParams.get('type') as ListingType) || settings.defaultSort.feed
|
||||||
|
|
||||||
return {
|
const feed = postFeed({
|
||||||
feed: new ReactiveState(
|
|
||||||
await postFeed({
|
|
||||||
id: 'main',
|
id: 'main',
|
||||||
request: {
|
request: {
|
||||||
page_cursor: cursor,
|
page_cursor: cursor,
|
||||||
@@ -26,8 +24,14 @@ export async function load({ url, fetch }) {
|
|||||||
},
|
},
|
||||||
url: url,
|
url: url,
|
||||||
fetch: fetch,
|
fetch: fetch,
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
feed: new ReactiveState((await awaitIfServer(feed)).data),
|
||||||
|
filters: new ReactiveState({
|
||||||
|
sort: sort,
|
||||||
|
type_: listingType,
|
||||||
}),
|
}),
|
||||||
),
|
|
||||||
contextual: {
|
contextual: {
|
||||||
actions: [
|
actions: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -171,8 +171,9 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<Menu placement="bottom-end">
|
<Menu placement="bottom-end">
|
||||||
{#snippet target()}
|
{#snippet target(attachment)}
|
||||||
<Button
|
<Button
|
||||||
|
{@attach attachment}
|
||||||
size="square-md"
|
size="square-md"
|
||||||
color="tertiary"
|
color="tertiary"
|
||||||
class="justify-self-end ml-auto z-50"
|
class="justify-self-end ml-auto z-50"
|
||||||
|
|||||||
@@ -188,8 +188,8 @@
|
|||||||
{#if site.data}
|
{#if site.data}
|
||||||
<div class="flex gap-2 flex-wrap flex-row">
|
<div class="flex gap-2 flex-wrap flex-row">
|
||||||
<Menu class="gap-px">
|
<Menu class="gap-px">
|
||||||
{#snippet target()}
|
{#snippet target(attachment)}
|
||||||
<button type="button">
|
<button {@attach attachment} type="button">
|
||||||
<Badge color="blue-subtle">
|
<Badge color="blue-subtle">
|
||||||
<Icon src={Plus} micro size="14" />
|
<Icon src={Plus} micro size="14" />
|
||||||
{$t('common.add')}
|
{$t('common.add')}
|
||||||
|
|||||||
@@ -4,12 +4,12 @@
|
|||||||
import CommunityItem from '$lib/components/lemmy/community/CommunityItem.svelte'
|
import CommunityItem from '$lib/components/lemmy/community/CommunityItem.svelte'
|
||||||
import Location from '$lib/components/lemmy/dropdowns/Location.svelte'
|
import Location from '$lib/components/lemmy/dropdowns/Location.svelte'
|
||||||
import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte'
|
import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte'
|
||||||
|
import EndPlaceholder from '$lib/components/ui/EndPlaceholder.svelte'
|
||||||
import Skeleton from '$lib/components/ui/generic/Skeleton.svelte'
|
import Skeleton from '$lib/components/ui/generic/Skeleton.svelte'
|
||||||
import CommonList from '$lib/components/ui/layout/CommonList.svelte'
|
import CommonList from '$lib/components/ui/layout/CommonList.svelte'
|
||||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||||
import Pageination from '$lib/components/ui/Pageination.svelte'
|
import Pageination from '$lib/components/ui/Pageination.svelte'
|
||||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||||
import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
|
|
||||||
import { t } from '$lib/i18n/translations.js'
|
import { t } from '$lib/i18n/translations.js'
|
||||||
import { LINKED_INSTANCE_URL } from '$lib/instance.svelte'
|
import { LINKED_INSTANCE_URL } from '$lib/instance.svelte'
|
||||||
import { Material, Option } from 'mono-svelte'
|
import { Material, Option } from 'mono-svelte'
|
||||||
@@ -17,7 +17,6 @@
|
|||||||
import { expoOut } from 'svelte/easing'
|
import { expoOut } from 'svelte/easing'
|
||||||
import { fly } from 'svelte/transition'
|
import { fly } from 'svelte/transition'
|
||||||
import SearchBar from '../search/SearchBar.svelte'
|
import SearchBar from '../search/SearchBar.svelte'
|
||||||
import EndPlaceholder from '$lib/components/ui/EndPlaceholder.svelte'
|
|
||||||
|
|
||||||
let { data } = $props()
|
let { data } = $props()
|
||||||
|
|
||||||
@@ -44,9 +43,9 @@
|
|||||||
|
|
||||||
<Header pageHeader class="justify-between">
|
<Header pageHeader class="justify-between">
|
||||||
<span>{$t('routes.communities.title')}</span>
|
<span>{$t('routes.communities.title')}</span>
|
||||||
</Header>
|
|
||||||
|
|
||||||
<form method="get" action="/communities" class="contents" bind:this={form}>
|
{#snippet extended()}
|
||||||
|
<form method="get" action="/communities" class="contents" bind:this={form}>
|
||||||
<SearchBar bind:query={search} />
|
<SearchBar bind:query={search} />
|
||||||
|
|
||||||
<div class="flex flex-row flex-wrap gap-4 mt-4 items-center">
|
<div class="flex flex-row flex-wrap gap-4 mt-4 items-center">
|
||||||
@@ -78,9 +77,12 @@
|
|||||||
onchange={() => form?.requestSubmit()}
|
onchange={() => form?.requestSubmit()}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
{/snippet}
|
||||||
|
</Header>
|
||||||
|
|
||||||
{#if navigating.to?.route.id == '/communities'}
|
{#if navigating.to?.route.id == '/communities'}
|
||||||
<div class="flex flex-col gap-3 mt-6">
|
<div class="flex flex-col gap-3">
|
||||||
{#each new Array(5) as _, index}
|
{#each new Array(5) as _, index}
|
||||||
{_}
|
{_}
|
||||||
<div
|
<div
|
||||||
@@ -107,7 +109,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if showTop}
|
{#if showTop}
|
||||||
<EndPlaceholder size="lg" margin="lg">
|
<EndPlaceholder size="lg" margin="md">
|
||||||
{$t('routes.search.top')}
|
{$t('routes.search.top')}
|
||||||
</EndPlaceholder>
|
</EndPlaceholder>
|
||||||
<div
|
<div
|
||||||
@@ -137,7 +139,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if data.communities.value.slice(showTop ? 3 : 0).length > 0}
|
{#if data.communities.value.slice(showTop ? 3 : 0).length > 0}
|
||||||
<EndPlaceholder size="lg" margin="lg">
|
<EndPlaceholder size="lg" margin="md">
|
||||||
{$t('routes.search.other')}
|
{$t('routes.search.other')}
|
||||||
</EndPlaceholder>
|
</EndPlaceholder>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
{$t('nav.create.label')}
|
{$t('nav.create.label')}
|
||||||
</Header>
|
</Header>
|
||||||
|
|
||||||
<div class="h-3 sm:h-6"></div>
|
|
||||||
<Tabs
|
<Tabs
|
||||||
style="subpage"
|
style="subpage"
|
||||||
routes={[
|
routes={[
|
||||||
@@ -24,6 +23,5 @@
|
|||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
<div class="h-3 sm:h-6"></div>
|
|
||||||
|
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
@@ -73,11 +73,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</Header>
|
</Header>
|
||||||
|
|
||||||
<div class="h-3 sm:h-6"></div>
|
<Select
|
||||||
|
class="relative w-max"
|
||||||
<div class="mb-3 sm:mb-6">
|
|
||||||
<Select
|
|
||||||
class=" w-max items-center"
|
|
||||||
bind:value={
|
bind:value={
|
||||||
() => data.unreadOnly.value.toString(),
|
() => data.unreadOnly.value.toString(),
|
||||||
v => (data.unreadOnly.value = v == 'true')
|
v => (data.unreadOnly.value = v == 'true')
|
||||||
@@ -89,17 +86,18 @@
|
|||||||
data.unreadOnly.value ? 'true' : 'false',
|
data.unreadOnly.value ? 'true' : 'false',
|
||||||
'page',
|
'page',
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{#snippet customLabel()}
|
{#snippet customLabel()}
|
||||||
<span class="flex items-center gap-1">
|
<div class="flex items-center gap-1">
|
||||||
<Icon src={Funnel} size="15" mini />
|
<Icon src={Funnel} size="15" mini />
|
||||||
{$t('filter.filter')}
|
{$t('filter.filter')}
|
||||||
</span>
|
</div>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<Option value="false">{$t('filter.location.all')}</Option>
|
<Option value="false">{$t('filter.location.all')}</Option>
|
||||||
<Option value="true">{$t('filter.unread')}</Option>
|
<Option value="true">{$t('filter.unread')}</Option>
|
||||||
</Select>
|
</Select>
|
||||||
</div>
|
|
||||||
|
<div class="h-3 sm:h-6"></div>
|
||||||
|
|
||||||
{#if !data.inbox?.value || (data.inbox.value?.length ?? 0) == 0}
|
{#if !data.inbox?.value || (data.inbox.value?.length ?? 0) == 0}
|
||||||
<Placeholder
|
<Placeholder
|
||||||
|
|||||||
@@ -131,7 +131,6 @@
|
|||||||
{@render startChat?.()}
|
{@render startChat?.()}
|
||||||
</Placeholder>
|
</Placeholder>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="h-3 sm:h-6"></div>
|
|
||||||
<CommonList items={previews}>
|
<CommonList items={previews}>
|
||||||
{#snippet item(preview)}
|
{#snippet item(preview)}
|
||||||
<a href="/inbox/messages/{preview.user.id}" class="flex flex-row gap-2">
|
<a href="/inbox/messages/{preview.user.id}" class="flex flex-row gap-2">
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
let { children } = $props()
|
let { children } = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Header pageHeader>Instances</Header>
|
|
||||||
<Tabs
|
<Tabs
|
||||||
routes={[
|
routes={[
|
||||||
{
|
{
|
||||||
@@ -15,5 +14,5 @@
|
|||||||
{ href: '/instances/blocked', name: 'Blocked' },
|
{ href: '/instances/blocked', name: 'Blocked' },
|
||||||
]}
|
]}
|
||||||
></Tabs>
|
></Tabs>
|
||||||
<div class="h-3 sm:h-6"></div>
|
<Header pageHeader>Instances</Header>
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import VirtualList from '$lib/components/render/VirtualList.svelte'
|
||||||
|
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||||
|
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
||||||
|
import { publishedToDate } from '$lib/components/util/date.js'
|
||||||
|
import { t } from '$lib/i18n/translations.js'
|
||||||
|
import { Spinner, TextInput } from 'mono-svelte'
|
||||||
|
import { Check } from 'svelte-hero-icons'
|
||||||
|
|
||||||
|
let { data: passedData } = $props()
|
||||||
|
let data = $state(passedData)
|
||||||
|
|
||||||
|
let filter = $state('')
|
||||||
|
|
||||||
|
let loading = $state(false)
|
||||||
|
|
||||||
|
function triggerFilter(filter: string) {
|
||||||
|
if (!passedData.blocked) return
|
||||||
|
loading = true
|
||||||
|
data.blocked = passedData.blocked.filter(i => i.domain.includes(filter))
|
||||||
|
loading = false
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if data}
|
||||||
|
<div class="flex flex-col gap-4">
|
||||||
|
<form onsubmit={() => triggerFilter(filter)}>
|
||||||
|
<TextInput label={$t('filter.filter')} bind:value={filter}></TextInput>
|
||||||
|
</form>
|
||||||
|
{#if data.blocked && data.blocked.length > 0}
|
||||||
|
{#if loading}
|
||||||
|
<Spinner />
|
||||||
|
{/if}
|
||||||
|
<VirtualList
|
||||||
|
items={data.blocked}
|
||||||
|
useWindow={false}
|
||||||
|
height={600}
|
||||||
|
estimatedHeight={50}
|
||||||
|
class="overflow-auto border rounded-2xl border-slate-200 dark:border-zinc-900 bg-white dark:bg-zinc-950
|
||||||
|
divide-y divide-slate-200 dark:divide-zinc-900 w-full"
|
||||||
|
>
|
||||||
|
{#snippet item(index)}
|
||||||
|
{#if data.blocked[index]}
|
||||||
|
<div
|
||||||
|
class="flex justify-between items-center first:pt-0 last:pb-0 my-3 px-6"
|
||||||
|
>
|
||||||
|
<div class="flex flex-col">
|
||||||
|
<span class="font-medium">{data.blocked[index].domain}</span>
|
||||||
|
<span
|
||||||
|
class="text-xs text-slate-600 dark:text-zinc-400 capitalize"
|
||||||
|
>
|
||||||
|
{data.blocked[index].software ?? 'Unknown'} • <RelativeDate
|
||||||
|
date={publishedToDate(data.blocked[index].published)}
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
{/snippet}
|
||||||
|
</VirtualList>
|
||||||
|
{:else}
|
||||||
|
<Placeholder
|
||||||
|
icon={Check}
|
||||||
|
title="No blocked instances"
|
||||||
|
description="This instance likely has federation disabled."
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
@@ -3,27 +3,46 @@
|
|||||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||||
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
||||||
import { publishedToDate } from '$lib/components/util/date.js'
|
import { publishedToDate } from '$lib/components/util/date.js'
|
||||||
import { Material } from 'mono-svelte'
|
import { t } from '$lib/i18n/translations.js'
|
||||||
|
import { Spinner, TextInput } from 'mono-svelte'
|
||||||
import { Check } from 'svelte-hero-icons'
|
import { Check } from 'svelte-hero-icons'
|
||||||
|
|
||||||
let { data } = $props()
|
let { data: passedData } = $props()
|
||||||
|
let data = $state(passedData)
|
||||||
|
|
||||||
|
let filter = $state('')
|
||||||
|
|
||||||
|
let loading = $state(false)
|
||||||
|
|
||||||
|
function triggerFilter(filter: string) {
|
||||||
|
if (!passedData.linked) return
|
||||||
|
loading = true
|
||||||
|
data.linked = passedData.linked.filter(i => i.domain.includes(filter))
|
||||||
|
loading = false
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if data}
|
{#if data}
|
||||||
<div class="flex flex-col md:flex-row gap-4">
|
<div class="flex flex-col gap-4">
|
||||||
<Material
|
<form onsubmit={() => triggerFilter(filter)}>
|
||||||
class="h-full overflow-auto divide-y *:py-3 divide-slate-200 dark:divide-zinc-800 max-h-[48rem] w-full"
|
<TextInput label={$t('filter.filter')} bind:value={filter}></TextInput>
|
||||||
>
|
</form>
|
||||||
{#if data.linked && data.linked.length > 0}
|
{#if data.linked && data.linked.length > 0}
|
||||||
|
{#if loading}
|
||||||
|
<Spinner />
|
||||||
|
{/if}
|
||||||
<VirtualList
|
<VirtualList
|
||||||
useWindow={false}
|
|
||||||
items={data.linked}
|
items={data.linked}
|
||||||
height={473}
|
useWindow={false}
|
||||||
estimatedHeight={100}
|
height={600}
|
||||||
|
estimatedHeight={50}
|
||||||
|
class="overflow-auto border rounded-2xl border-slate-200 dark:border-zinc-900 bg-white dark:bg-zinc-950
|
||||||
|
divide-y divide-slate-200 dark:divide-zinc-900 w-full"
|
||||||
>
|
>
|
||||||
{#snippet item(index)}
|
{#snippet item(index)}
|
||||||
|
{#if data.linked[index]}
|
||||||
<div
|
<div
|
||||||
class="flex justify-between items-center first:pt-0 last:pb-0 my-3"
|
class="flex justify-between items-center first:pt-0 last:pb-0 my-3 px-6"
|
||||||
>
|
>
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<span class="font-medium">{data.linked[index].domain}</span>
|
<span class="font-medium">{data.linked[index].domain}</span>
|
||||||
@@ -36,15 +55,15 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
{/snippet}
|
{/snippet}
|
||||||
</VirtualList>
|
</VirtualList>
|
||||||
{:else}
|
{:else}
|
||||||
<Placeholder
|
<Placeholder
|
||||||
icon={Check}
|
icon={Check}
|
||||||
title="No linked instances"
|
title="No linked instances"
|
||||||
description="This instance likely has federation disabled."
|
description="This instance doesn't block any others."
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
</Material>
|
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -120,8 +120,8 @@
|
|||||||
{#if site.data && formData.discussion_languages}
|
{#if site.data && formData.discussion_languages}
|
||||||
<div class="flex gap-2 flex-wrap flex-row">
|
<div class="flex gap-2 flex-wrap flex-row">
|
||||||
<Menu class="gap-px">
|
<Menu class="gap-px">
|
||||||
{#snippet target()}
|
{#snippet target(attachment)}
|
||||||
<button type="button">
|
<button {@attach attachment} type="button">
|
||||||
<Badge color="blue-subtle">
|
<Badge color="blue-subtle">
|
||||||
<Icon src={Plus} micro size="14" />
|
<Icon src={Plus} micro size="14" />
|
||||||
{$t('common.add')}
|
{$t('common.add')}
|
||||||
|
|||||||
@@ -48,8 +48,9 @@
|
|||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Menu class="flex-1" placement="bottom-end">
|
<Menu class="flex-1" placement="bottom-end">
|
||||||
{#snippet target()}
|
{#snippet target(attachment)}
|
||||||
<Button
|
<Button
|
||||||
|
{@attach attachment}
|
||||||
aria-label={$t('post.actions.more.label')}
|
aria-label={$t('post.actions.more.label')}
|
||||||
size="square-sm"
|
size="square-sm"
|
||||||
color="none"
|
color="none"
|
||||||
|
|||||||
@@ -61,8 +61,6 @@
|
|||||||
{/snippet}
|
{/snippet}
|
||||||
</Header>
|
</Header>
|
||||||
|
|
||||||
<div class="h-3 sm:h-6"></div>
|
|
||||||
|
|
||||||
{#if !data.data || (data.data?.length ?? 0) == 0}
|
{#if !data.data || (data.data?.length ?? 0) == 0}
|
||||||
<Placeholder
|
<Placeholder
|
||||||
icon={Bookmark}
|
icon={Bookmark}
|
||||||
|
|||||||
@@ -54,10 +54,15 @@
|
|||||||
|
|
||||||
<Header pageHeader>
|
<Header pageHeader>
|
||||||
{$t('routes.search.title')}
|
{$t('routes.search.title')}
|
||||||
</Header>
|
{#snippet extended()}
|
||||||
<form method="get" action="/search" class="contents" bind:this={form}>
|
<form
|
||||||
|
method="get"
|
||||||
|
action="/search"
|
||||||
|
class="flex flex-col gap-4"
|
||||||
|
bind:this={form}
|
||||||
|
>
|
||||||
<SearchBar bind:query={data.filters.value.query} />
|
<SearchBar bind:query={data.filters.value.query} />
|
||||||
<div class="flex flex-row flex-wrap items-center gap-4 my-4 sm:my-6">
|
<div class="flex flex-row flex-wrap items-center gap-4">
|
||||||
<Select
|
<Select
|
||||||
name="type"
|
name="type"
|
||||||
bind:value={data.filters.value.type}
|
bind:value={data.filters.value.type}
|
||||||
@@ -91,7 +96,10 @@
|
|||||||
<Icon src={ChevronDoubleDown} size="20" mini />
|
<Icon src={ChevronDoubleDown} size="20" mini />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
{/snippet}
|
||||||
|
</Header>
|
||||||
|
|
||||||
{#if moreOptions}
|
{#if moreOptions}
|
||||||
<div
|
<div
|
||||||
transition:slide={{ axis: 'y', easing: expoOut, duration: 500 }}
|
transition:slide={{ axis: 'y', easing: expoOut, duration: 500 }}
|
||||||
|
|||||||
@@ -96,8 +96,6 @@
|
|||||||
{/snippet}
|
{/snippet}
|
||||||
</Header>
|
</Header>
|
||||||
|
|
||||||
<div class="h-3 sm:h-6"></div>
|
|
||||||
|
|
||||||
<Tabs
|
<Tabs
|
||||||
routes={[
|
routes={[
|
||||||
{
|
{
|
||||||
@@ -122,8 +120,6 @@
|
|||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
style="subpage"
|
style="subpage"
|
||||||
></Tabs>
|
/>
|
||||||
|
|
||||||
<div class="h-3 sm:h-6"></div>
|
|
||||||
|
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
@@ -240,8 +240,8 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{#if isAdmin(profile.current?.user)}
|
{#if isAdmin(profile.current?.user)}
|
||||||
<Menu class="ml-auto" placement="bottom-end">
|
<Menu class="ml-auto" placement="bottom-end">
|
||||||
{#snippet target()}
|
{#snippet target(attachment)}
|
||||||
<Button size="sm" rounding="pill">
|
<Button {@attach attachment} size="sm" rounding="pill">
|
||||||
<ShieldIcon width={16} filled />
|
<ShieldIcon width={16} filled />
|
||||||
{$t('moderation.label')}
|
{$t('moderation.label')}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
Reference in new issue
Block a user