migrate: switch to callbacks instead of events
This commit is contained in:
1 parent
c7e2963390
commit
b291aeebf8
67 files changed
+332
-357
No files matched your search
@@ -89,7 +89,7 @@
|
||||
rounding="full"
|
||||
padding="none"
|
||||
color="uniform"
|
||||
on:click={(e) => e.stopPropagation()}
|
||||
onclick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<Button
|
||||
download
|
||||
@@ -102,7 +102,7 @@
|
||||
<Icon src={ArrowDownTray} size="20" micro />
|
||||
</Button>
|
||||
<Button
|
||||
on:click={async () => {
|
||||
onclick={async () => {
|
||||
if (navigator.share) {
|
||||
const file = await downloadImage($page.state.openImage)
|
||||
|
||||
@@ -125,7 +125,7 @@
|
||||
{/snippet}
|
||||
</Button>
|
||||
<Button
|
||||
on:click={() => {
|
||||
onclick={() => {
|
||||
zoomed = !zoomed
|
||||
}}
|
||||
color="tertiary"
|
||||
@@ -140,7 +140,7 @@
|
||||
/>
|
||||
</Button>
|
||||
<Button
|
||||
on:click={() => history.back()}
|
||||
onclick={() => history.back()}
|
||||
color="tertiary"
|
||||
size="square-lg"
|
||||
rounding="pill"
|
||||
|
||||
@@ -13,18 +13,18 @@
|
||||
import { fly } from 'svelte/transition'
|
||||
|
||||
interface Props {
|
||||
page?: number;
|
||||
cursor?: { next?: string; back?: string } | undefined;
|
||||
hasMore?: boolean;
|
||||
children?: import('svelte').Snippet;
|
||||
page?: number
|
||||
cursor?: { next?: string; back?: string } | undefined
|
||||
hasMore?: boolean
|
||||
children?: import('svelte').Snippet
|
||||
}
|
||||
|
||||
let {
|
||||
page = $bindable(0),
|
||||
cursor = undefined,
|
||||
hasMore = true,
|
||||
children
|
||||
}: Props = $props();
|
||||
children,
|
||||
}: Props = $props()
|
||||
|
||||
const dispatcher = createEventDispatcher<{ change: number; cursor: string }>()
|
||||
</script>
|
||||
@@ -41,7 +41,7 @@
|
||||
{/if}
|
||||
<Button
|
||||
color="ghost"
|
||||
on:click={() => {
|
||||
onclick={() => {
|
||||
if (cursor?.back) dispatcher('cursor', cursor?.back)
|
||||
else dispatcher('change', --page)
|
||||
}}
|
||||
@@ -52,8 +52,8 @@
|
||||
disabled={(!cursor?.back && cursor?.next) || page <= 1}
|
||||
>
|
||||
{#snippet suffix()}
|
||||
<Icon src={ChevronLeft} size="24" mini />
|
||||
{/snippet}
|
||||
<Icon src={ChevronLeft} size="24" mini />
|
||||
{/snippet}
|
||||
</Button>
|
||||
|
||||
{#if page}
|
||||
@@ -73,7 +73,7 @@
|
||||
|
||||
<Button
|
||||
color="ghost"
|
||||
on:click={() => {
|
||||
onclick={() => {
|
||||
if (cursor?.next) dispatcher('cursor', cursor?.next)
|
||||
else dispatcher('change', ++page)
|
||||
}}
|
||||
@@ -84,7 +84,7 @@
|
||||
disabled={!hasMore}
|
||||
>
|
||||
{#snippet suffix()}
|
||||
<Icon src={ChevronRight} size="24" mini />
|
||||
{/snippet}
|
||||
<Icon src={ChevronRight} size="24" mini />
|
||||
{/snippet}
|
||||
</Button>
|
||||
</nav>
|
||||
@@ -4,18 +4,15 @@
|
||||
import { Icon, type IconSource } from 'svelte-hero-icons'
|
||||
import { dockProps } from '../layout/Shell.svelte'
|
||||
|
||||
|
||||
|
||||
|
||||
interface Props {
|
||||
label: string;
|
||||
icon?: IconSource | undefined;
|
||||
href?: string | undefined;
|
||||
adaptive?: boolean;
|
||||
isSelectedFilter?: (path: string) => boolean;
|
||||
class?: string;
|
||||
customIcon?: import('svelte').Snippet<[any]>;
|
||||
children?: import('svelte').Snippet;
|
||||
label: string
|
||||
icon?: IconSource | undefined
|
||||
href?: string | undefined
|
||||
adaptive?: boolean
|
||||
isSelectedFilter?: (path: string) => boolean
|
||||
class?: string
|
||||
customIcon?: import('svelte').Snippet<[any]>
|
||||
children?: import('svelte').Snippet
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
@@ -24,14 +21,13 @@
|
||||
icon = undefined,
|
||||
href = undefined,
|
||||
adaptive = true,
|
||||
isSelectedFilter = (path) =>
|
||||
href != undefined && path == href,
|
||||
isSelectedFilter = (path) => href != undefined && path == href,
|
||||
class: clazz = '',
|
||||
customIcon,
|
||||
children,
|
||||
...rest
|
||||
}: Props = $props();
|
||||
|
||||
}: Props = $props()
|
||||
|
||||
let isSelected = $derived(isSelectedFilter($page.url.pathname))
|
||||
let isPanel = $derived(adaptive ? $dockProps.noGap : false)
|
||||
</script>
|
||||
@@ -39,7 +35,7 @@
|
||||
<Button
|
||||
color={isPanel ? 'secondary' : 'tertiary'}
|
||||
{...rest}
|
||||
on:click
|
||||
onclick
|
||||
on:contextmenu
|
||||
class="rounded-full w-10 h-10 flex-shrink-0 {adaptive
|
||||
? '@3xl:h-8 @3xl:px-3 @3xl:rounded-[10px] @3xl:w-auto'
|
||||
@@ -60,7 +56,7 @@
|
||||
size={isPanel ? '16' : '18'}
|
||||
/>
|
||||
{:else}
|
||||
{@render customIcon?.({ size: isPanel ? 16 : 18, isSelected, })}
|
||||
{@render customIcon?.({ size: isPanel ? 16 : 18, isSelected })}
|
||||
{/if}
|
||||
<span class="hidden {adaptive ? '@3xl:block' : ''}">{label}</span>
|
||||
{@render children?.()}
|
||||
|
||||
@@ -209,7 +209,7 @@
|
||||
</button>
|
||||
</div>
|
||||
<Button
|
||||
on:click={() => (showInstance = !showInstance)}
|
||||
onclick={() => (showInstance = !showInstance)}
|
||||
color="tertiary"
|
||||
title={$t('nav.menu.instance')}
|
||||
size="square-md"
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
<Button
|
||||
href={action.href}
|
||||
on:click
|
||||
onclick
|
||||
alignment="left"
|
||||
color="tertiary"
|
||||
size="lg"
|
||||
|
||||
@@ -278,7 +278,7 @@
|
||||
<li>
|
||||
<CommandItem
|
||||
{action}
|
||||
on:click={(e) => {
|
||||
onclick={(e) => {
|
||||
if (action.href) {
|
||||
togglePalette()
|
||||
return
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
class="hidden group-hover:inline-flex opacity-0 group-hover:opacity-100 transition-all z-20
|
||||
items-center justify-center box-border w-7 h-7"
|
||||
style="grid-column: 1; grid-row: 1;"
|
||||
on:click={() => addFavorite(follow)}
|
||||
onclick={() => addFavorite(follow)}
|
||||
>
|
||||
<Icon src={Star} size="16" mini />
|
||||
</Button>
|
||||
@@ -43,7 +43,7 @@
|
||||
class="hidden group-hover:inline-flex opacity-0 group-hover:opacity-100 transition-all z-20
|
||||
items-center justify-center box-border w-7 h-7"
|
||||
style="grid-column: 1; grid-row: 1;"
|
||||
on:click={() => addFavorite(follow, false)}
|
||||
onclick={() => addFavorite(follow, false)}
|
||||
>
|
||||
<Icon src={Trash} size="16" mini />
|
||||
</Button>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
loading={switching}
|
||||
loaderWidth={20}
|
||||
selected={$profile?.id == prof.id}
|
||||
on:click={async () => {
|
||||
onclick={async () => {
|
||||
switching = true
|
||||
|
||||
if ($profile?.id != prof.id) {
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
{#each settings.dock.pins as pin}
|
||||
<SidebarButton
|
||||
icon={iconOfLink(pin.url)}
|
||||
on:click={() => goto(pin.url)}
|
||||
onclick={() => goto(pin.url)}
|
||||
alignment="center"
|
||||
selected={`${$page.url.pathname}${$page.url.search}` == pin.url}
|
||||
on:contextmenu={(e) => {
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
alignment="left"
|
||||
{...rest}
|
||||
{href}
|
||||
on:click
|
||||
onclick
|
||||
on:contextmenu
|
||||
class="font-normal block !origin-left border border-transparent {!selected
|
||||
? 'text-slate-600 dark:text-zinc-400'
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
in:fly={{ duration: 300, easing: expoOut, y: 6, delay: 100 }}
|
||||
>
|
||||
<Button
|
||||
on:click={() => {
|
||||
onclick={() => {
|
||||
filters.clear()
|
||||
filters = filters
|
||||
}}
|
||||
@@ -51,7 +51,7 @@
|
||||
{/if}
|
||||
{#each uniqueIds as id}
|
||||
<Button
|
||||
on:click={() => {
|
||||
onclick={() => {
|
||||
if (filters.has(id)) filters.delete(id)
|
||||
else filters.add(id)
|
||||
filters = filters
|
||||
|
||||
Reference in new issue
Block a user