migrate: change settings from a store to a state
This commit is contained in:
1 parent
ffcd9faa96
commit
d597349887
128 files changed
+1010
-1144
No files matched your search
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { preventDefault } from 'svelte/legacy';
|
||||
import { preventDefault } from 'svelte/legacy'
|
||||
|
||||
import { navigating, page } from '$app/stores'
|
||||
import {
|
||||
@@ -10,7 +10,7 @@
|
||||
QuestionMarkCircle,
|
||||
} from 'svelte-hero-icons'
|
||||
import Pageination from '$lib/components/ui/Pageination.svelte'
|
||||
import { searchParam } from '$lib/util.js'
|
||||
import { searchParam } from '$lib/util.svelte.js'
|
||||
import {
|
||||
Button,
|
||||
Material,
|
||||
@@ -31,21 +31,18 @@
|
||||
import { fly } from 'svelte/transition'
|
||||
import { backOut, expoOut } from 'svelte/easing'
|
||||
|
||||
let { data } = $props();
|
||||
let { data } = $props()
|
||||
|
||||
let search = $state(data.query || '')
|
||||
let searchElement: HTMLInputElement = $state()
|
||||
let searchElement: HTMLInputElement | undefined = $state()
|
||||
let instance = ''
|
||||
|
||||
let virtualList: HTMLDivElement = $state()
|
||||
let offset: number = $state(0)
|
||||
|
||||
let showTop =
|
||||
$derived((data.query ?? '' != '') && data.communities.length > 0 && data.page == 1)
|
||||
let showTop = $derived(
|
||||
(data.query ?? '' != '') && data.communities.length > 0 && data.page == 1,
|
||||
)
|
||||
</script>
|
||||
|
||||
<svelte:window
|
||||
bind:scrollY={offset}
|
||||
onkeydown={(e) => {
|
||||
if (e.target == document.body) searchElement?.focus()
|
||||
}}
|
||||
@@ -65,7 +62,8 @@
|
||||
<Tabs routes={[]} class="p-2 dark:bg-zinc-925/70 shadow-md shadow-black/5">
|
||||
<form
|
||||
onsubmit={preventDefault(() =>
|
||||
searchParam($page.url, 'q', search, 'page'))}
|
||||
searchParam($page.url, 'q', search, 'page'),
|
||||
)}
|
||||
class="flex gap-2 flex-row items-center w-full text-base h-10"
|
||||
>
|
||||
<TextInput
|
||||
@@ -86,8 +84,8 @@
|
||||
loading={$navigating != null}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon src={MagnifyingGlass} size="16" micro />
|
||||
{/snippet}
|
||||
<Icon src={MagnifyingGlass} size="16" micro />
|
||||
{/snippet}
|
||||
</Button>
|
||||
</form>
|
||||
</Tabs>
|
||||
@@ -149,7 +147,7 @@
|
||||
{/if}
|
||||
{#if data.communities}
|
||||
{@const sliced = data.communities.slice(showTop ? 3 : 0)}
|
||||
<div class="-mx-4 sm:-mx-6 h-full" bind:this={virtualList}>
|
||||
<div class="-mx-4 sm:-mx-6 h-full">
|
||||
{#each sliced as community, index (community.community.id)}
|
||||
<div
|
||||
class="px-6 hover:bg-slate-50 hover:dark:bg-zinc-900 transition-colors @container
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { profile } from '$lib/auth.js'
|
||||
import { profile } from '$lib/auth.svelte'
|
||||
import { LINKED_INSTANCE_URL } from '$lib/instance.js'
|
||||
import { client, getClient } from '$lib/lemmy.js'
|
||||
import {
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
<script lang="ts">
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
import type { CommunityView, SubscribedType } from 'lemmy-js-client'
|
||||
import { profile } from '$lib/auth.js'
|
||||
import { profile } from '$lib/auth.svelte.js'
|
||||
import { toast } from 'mono-svelte'
|
||||
|
||||
interface Props {
|
||||
community?: CommunityView | undefined;
|
||||
children?: import('svelte').Snippet<[any]>;
|
||||
community?: CommunityView | undefined
|
||||
children?: import('svelte').Snippet<[any]>
|
||||
}
|
||||
|
||||
let { community = undefined, children }: Props = $props();
|
||||
let { community = undefined, children }: Props = $props()
|
||||
|
||||
let subscribing = $state(false)
|
||||
|
||||
@@ -38,4 +38,4 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
{@render children?.({ subscribe, subscribing, })}
|
||||
{@render children?.({ subscribe, subscribing })}
|
||||
Reference in new issue
Block a user