cleanup: use native html forms for earch and communities
This commit is contained in:
1 parent
e46422c27b
commit
73a4c16322
37 files changed
+254
-246
No files matched your search
@@ -25,7 +25,7 @@
|
||||
import { Button, Modal } from 'mono-svelte'
|
||||
import { publishedToDate } from '$lib/components/util/date.js'
|
||||
import ShieldIcon from '../moderation/ShieldIcon.svelte'
|
||||
import { page } from '$app/stores'
|
||||
import { page } from '$app/state'
|
||||
import { onMount } from 'svelte'
|
||||
import { t } from '$lib/translations'
|
||||
import { fly, slide } from 'svelte/transition'
|
||||
@@ -90,7 +90,7 @@
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
if ('#' + node.comment_view.comment.id.toString() == $page.url.hash) {
|
||||
if ('#' + node.comment_view.comment.id.toString() == page.url.hash) {
|
||||
highlight = 'text-primary-900 dark:text-primary-100 font-medium'
|
||||
|
||||
setTimeout(() => (highlight = 'duration-[3s] transition-all'), 500)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import Comments from './Comments.svelte'
|
||||
import Comment from './Comment.svelte'
|
||||
import { buildCommentsTree, type CommentNodeI } from './comments.svelte'
|
||||
import { page } from '$app/stores'
|
||||
import { page } from '$app/state'
|
||||
import { onMount, setContext } from 'svelte'
|
||||
import { Icon, ArrowDownCircle } from 'svelte-hero-icons'
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
@@ -28,8 +28,8 @@
|
||||
|
||||
onMount(() => {
|
||||
hydrated = true
|
||||
if (isParent && $page.url.hash && browser) {
|
||||
document.getElementById($page.url.hash)?.scrollIntoView({
|
||||
if (isParent && page.url.hash && browser) {
|
||||
document.getElementById(page.url.hash)?.scrollIntoView({
|
||||
behavior: 'smooth',
|
||||
block: 'center',
|
||||
})
|
||||
@@ -51,7 +51,7 @@
|
||||
try {
|
||||
parent.loading = true
|
||||
|
||||
const newComments = await getClient($page.params.instance).getComments({
|
||||
const newComments = await getClient(page.params.instance).getComments({
|
||||
max_depth: 5,
|
||||
parent_id: parent.comment_view.comment.id,
|
||||
type_: 'All',
|
||||
@@ -128,7 +128,7 @@
|
||||
<svelte:element
|
||||
this={hydrated ? 'div' : 'a'}
|
||||
class="w-full my-2 h-8"
|
||||
href="/comment/{$page.params.instance}/{node.comment_view.comment.id}"
|
||||
href="/comment/{page.params.instance}/{node.comment_view.comment.id}"
|
||||
>
|
||||
<Button
|
||||
loading={node.loading}
|
||||
@@ -140,7 +140,7 @@
|
||||
onclick={() => {
|
||||
if (node.depth > 4) {
|
||||
goto(
|
||||
`/comment/${$page.params.instance}/${node.comment_view.comment.id}#comments`,
|
||||
`/comment/${page.params.instance}/${node.comment_view.comment.id}#comments`,
|
||||
)
|
||||
} else {
|
||||
node.loading = true
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores'
|
||||
import { page } from '$app/state'
|
||||
import { profile } from '$lib/auth.svelte'
|
||||
import { searchParam } from '$lib/util.svelte'
|
||||
import { Select } from 'mono-svelte'
|
||||
@@ -35,7 +35,7 @@
|
||||
{...rest}
|
||||
bind:value={selected}
|
||||
onchange={() => {
|
||||
if (navigate) searchParam($page.url, 'type', selected, 'page', 'cursor')
|
||||
if (navigate) searchParam(page.url, 'type', selected, 'page', 'cursor')
|
||||
}}
|
||||
>
|
||||
{#snippet customLabel()}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores'
|
||||
import { page } from '$app/state'
|
||||
import { t } from '$lib/translations'
|
||||
import { searchParam } from '$lib/util.svelte.js'
|
||||
import { Select } from 'mono-svelte'
|
||||
@@ -51,7 +51,7 @@
|
||||
bind:value={sort}
|
||||
onchange={() => {
|
||||
setSelected()
|
||||
if (navigate) searchParam($page.url, 'sort', selected, 'page', 'cursor')
|
||||
if (navigate) searchParam(page.url, 'sort', selected, 'page', 'cursor')
|
||||
}}
|
||||
>
|
||||
{#snippet customLabel()}
|
||||
@@ -96,7 +96,7 @@
|
||||
onchange={() => {
|
||||
sort = 'TopAll'
|
||||
if (navigate)
|
||||
searchParam($page.url, 'sort', selected, 'page', 'cursor')
|
||||
searchParam(page.url, 'sort', selected, 'page', 'cursor')
|
||||
}}
|
||||
>
|
||||
{#snippet customLabel()}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores'
|
||||
import { page } from '$app/state'
|
||||
import { Button, Material, toast } from 'mono-svelte'
|
||||
import {
|
||||
ArrowDownTray,
|
||||
@@ -50,7 +50,7 @@
|
||||
let { alt = '', class: clazz = '', children }: Props = $props()
|
||||
</script>
|
||||
|
||||
{#if $page.state.openImage || '' != ''}
|
||||
{#if page.state.openImage || '' != ''}
|
||||
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
||||
@@ -68,7 +68,7 @@
|
||||
<img
|
||||
width={400}
|
||||
height={400}
|
||||
src={$page.state.openImage}
|
||||
src={page.state.openImage}
|
||||
class="{zoomed
|
||||
? 'object-cover'
|
||||
: 'object-contain'} max-w-max mx-auto my-auto overscroll-contain bg-white dark:bg-zinc-900"
|
||||
@@ -93,7 +93,7 @@
|
||||
>
|
||||
<Button
|
||||
download
|
||||
href={$page.state.openImage}
|
||||
href={page.state.openImage}
|
||||
color="tertiary"
|
||||
size="square-lg"
|
||||
rounding="pill"
|
||||
@@ -104,13 +104,13 @@
|
||||
<Button
|
||||
onclick={async () => {
|
||||
if (navigator.share) {
|
||||
const file = await downloadImage($page.state.openImage)
|
||||
const file = await downloadImage(page.state.openImage)
|
||||
|
||||
navigator?.share?.({
|
||||
files: [file],
|
||||
})
|
||||
} else {
|
||||
navigator.clipboard.writeText($page.state.openImage)
|
||||
navigator.clipboard.writeText(page.state.openImage)
|
||||
toast({ content: $t('toast.copied') })
|
||||
}
|
||||
}}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { invalidate } from '$app/navigation'
|
||||
import { page } from '$app/stores'
|
||||
import { page } from '$app/state'
|
||||
import { fly } from 'svelte/transition'
|
||||
|
||||
interface Props {
|
||||
@@ -47,7 +47,7 @@
|
||||
transition-colors duration-100 relative z-0 flex-shrink-0"
|
||||
>
|
||||
{route.name}
|
||||
{#if isSelected($page.url, currentRoute, route.href, defaultRoute)}
|
||||
{#if isSelected(page.url, currentRoute, route.href, defaultRoute)}
|
||||
<div
|
||||
class="rounded-full bg-slate-100/60 dark:bg-zinc-700/60
|
||||
absolute inset-0 w-full h-full -z-10"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores'
|
||||
import { page } from '$app/state'
|
||||
import { Button } from 'mono-svelte'
|
||||
import { Icon, type IconSource } from 'svelte-hero-icons'
|
||||
import { dockProps } from '../layout/Shell.svelte'
|
||||
@@ -28,7 +28,7 @@
|
||||
...rest
|
||||
}: Props = $props()
|
||||
|
||||
let isSelected = $derived(isSelectedFilter($page.url.pathname))
|
||||
let isSelected = $derived(isSelectedFilter(page.url.pathname))
|
||||
let isPanel = $derived(adaptive ? $dockProps.noGap : false)
|
||||
</script>
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
import { profile, profileData } from '$lib/auth.svelte'
|
||||
import { getGroups, type Action, type Group } from './actions.svelte'
|
||||
import { themeData } from '$lib/ui/colors'
|
||||
import { page } from '$app/stores'
|
||||
import { page } from '$app/state'
|
||||
|
||||
interface Props {
|
||||
open?: boolean
|
||||
@@ -235,7 +235,7 @@
|
||||
$profile,
|
||||
$profileData.profiles,
|
||||
$themeData,
|
||||
$page.data.contextual?.actions,
|
||||
page.data.contextual?.actions,
|
||||
)
|
||||
})
|
||||
let flattenedActions = $derived(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { goto } from '$app/navigation'
|
||||
import { page } from '$app/stores'
|
||||
import { page } from '$app/state'
|
||||
import { setUserID, type Profile } from '$lib/auth.svelte'
|
||||
import {
|
||||
amModOfAny,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation'
|
||||
import { page } from '$app/stores'
|
||||
import { page } from '$app/state'
|
||||
import { profile, setUserID, type Profile } from '$lib/auth.svelte.js'
|
||||
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
|
||||
import { LINKED_INSTANCE_URL } from '$lib/instance'
|
||||
@@ -31,7 +31,7 @@
|
||||
await setUserID(prof.id)
|
||||
}
|
||||
|
||||
await goto($page.url, {
|
||||
await goto(page.url, {
|
||||
invalidateAll: true,
|
||||
})
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { run } from 'svelte/legacy'
|
||||
|
||||
import { page } from '$app/stores'
|
||||
import { page } from '$app/state'
|
||||
import { settings } from '$lib/settings.svelte.js'
|
||||
import { Button } from 'mono-svelte'
|
||||
import { Icon, type IconSource } from 'svelte-hero-icons'
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
run(() => {
|
||||
if (href != undefined) {
|
||||
selected = $page.url.pathname == href
|
||||
selected = page.url.pathname == href
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
import Menu from '../../popover/Menu.svelte'
|
||||
import MenuButton from '../../popover/MenuButton.svelte'
|
||||
import Popover from '../../popover/Popover.svelte'
|
||||
import { createEventDispatcher, onMount, setContext } from 'svelte'
|
||||
import { createEventDispatcher, onMount, setContext, tick } from 'svelte'
|
||||
import {
|
||||
CheckCircle,
|
||||
ChevronDown,
|
||||
@@ -51,8 +51,8 @@
|
||||
customLabel?: import('svelte').Snippet
|
||||
children?: import('svelte').Snippet
|
||||
customOption?: import('svelte').Snippet<[any]>
|
||||
oncontextmenu?: () => void
|
||||
onchange?: () => void
|
||||
oncontextmenu?: HTMLSelectAttributes['oncontextmenu']
|
||||
onchange?: HTMLSelectAttributes['onchange']
|
||||
}
|
||||
|
||||
let {
|
||||
@@ -99,8 +99,8 @@
|
||||
e.preventDefault()
|
||||
open = !open
|
||||
}}
|
||||
onchange={bubble('change')}
|
||||
oncontextmenu={bubble('contextmenu')}
|
||||
{onchange}
|
||||
{oncontextmenu}
|
||||
{placeholder}
|
||||
>
|
||||
{#if placeholder}
|
||||
@@ -116,10 +116,10 @@
|
||||
selected: option.value == value,
|
||||
})}{:else}
|
||||
<MenuButton
|
||||
on:contextmenu={() => oncontextmenu?.()}
|
||||
onclick={() => {
|
||||
onclick={async () => {
|
||||
value = option.value
|
||||
onchange?.()
|
||||
await tick()
|
||||
element?.dispatchEvent(new Event('change', { bubbles: true }))
|
||||
}}
|
||||
size="custom"
|
||||
disabled={option.disabled}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { toast } from 'mono-svelte'
|
||||
import { settings } from '$lib/settings.svelte'
|
||||
import { get } from 'svelte/store'
|
||||
import type { SubscribedType } from 'lemmy-js-client'
|
||||
import { page } from '$app/stores'
|
||||
import { page } from '$app/state'
|
||||
import { feature } from '$lib/version.js'
|
||||
import { client } from '$lib/lemmy.js'
|
||||
import { site } from './lemmy'
|
||||
|
||||
Reference in new issue
Block a user