format: whole project
This commit is contained in:
1 parent
b883b5f6e0
commit
80269cf275
79 files changed
+583
-605
No files matched your search
@@ -1,22 +1,22 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { preventDefault } from 'svelte/legacy';
|
import { preventDefault } from 'svelte/legacy'
|
||||||
|
|
||||||
import { DocumentPlus, Icon } from 'svelte-hero-icons'
|
import { DocumentPlus, Icon } from 'svelte-hero-icons'
|
||||||
import { Label, TextInput } from 'mono-svelte'
|
import { Label, TextInput } from 'mono-svelte'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
accept?: string;
|
accept?: string
|
||||||
files?: FileList | undefined | null;
|
files?: FileList | undefined | null
|
||||||
label?: string | undefined;
|
label?: string | undefined
|
||||||
url?: string | undefined;
|
url?: string | undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
accept = 'image/*',
|
accept = 'image/*',
|
||||||
files = $bindable(null),
|
files = $bindable(null),
|
||||||
label = undefined,
|
label = undefined,
|
||||||
url = undefined
|
url = undefined,
|
||||||
}: Props = $props();
|
}: Props = $props()
|
||||||
|
|
||||||
let dragover = $state(false)
|
let dragover = $state(false)
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export function buildCommentsTree(
|
|||||||
comment_view,
|
comment_view,
|
||||||
children: [],
|
children: [],
|
||||||
depth: depth,
|
depth: depth,
|
||||||
expanded: true
|
expanded: true,
|
||||||
}
|
}
|
||||||
min_depth = Math.min(min_depth, depth)
|
min_depth = Math.min(min_depth, depth)
|
||||||
if (filter(comment_view)) {
|
if (filter(comment_view)) {
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Icon, type IconSource } from 'svelte-hero-icons'
|
import { Icon, type IconSource } from 'svelte-hero-icons'
|
||||||
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
icon?: IconSource | undefined;
|
icon?: IconSource | undefined
|
||||||
title: string;
|
title: string
|
||||||
description?: string | undefined;
|
description?: string | undefined
|
||||||
center?: boolean;
|
center?: boolean
|
||||||
class?: string;
|
class?: string
|
||||||
children?: import('svelte').Snippet;
|
children?: import('svelte').Snippet
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
@@ -17,9 +16,8 @@
|
|||||||
description = undefined,
|
description = undefined,
|
||||||
center = false,
|
center = false,
|
||||||
class: clazz = '',
|
class: clazz = '',
|
||||||
children
|
children,
|
||||||
}: Props = $props();
|
}: Props = $props()
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { run } from 'svelte/legacy';
|
import { run } from 'svelte/legacy'
|
||||||
|
|
||||||
import { expoOut } from 'svelte/easing'
|
import { expoOut } from 'svelte/easing'
|
||||||
import { tweened } from 'svelte/motion'
|
import { tweened } from 'svelte/motion'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
progress?: number;
|
progress?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
let { progress = 0 }: Props = $props();
|
let { progress = 0 }: Props = $props()
|
||||||
|
|
||||||
let tween = tweened(progress, { easing: expoOut })
|
let tween = tweened(progress, { easing: expoOut })
|
||||||
|
|
||||||
run(() => {
|
run(() => {
|
||||||
tween.set(progress)
|
tween.set(progress)
|
||||||
});
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -1,18 +1,14 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
interface Props {
|
interface Props {
|
||||||
small?: boolean;
|
small?: boolean
|
||||||
class?: string;
|
class?: string
|
||||||
children?: import('svelte').Snippet;
|
children?: import('svelte').Snippet
|
||||||
[key: string]: any
|
[key: string]: any
|
||||||
}
|
}
|
||||||
|
|
||||||
let { small = false, class: clazz = '', children, ...rest }: Props = $props();
|
let { small = false, class: clazz = '', children, ...rest }: Props = $props()
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<span
|
<span {...rest} class="{!small ? 'text-lg' : 'text-xs'} font-semibold {clazz}">
|
||||||
{...rest}
|
|
||||||
class="{!small ? 'text-lg' : 'text-xs'} font-semibold {clazz}"
|
|
||||||
>
|
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
</span>
|
</span>
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
interface Props {
|
interface Props {
|
||||||
class?: string;
|
class?: string
|
||||||
children?: import('svelte').Snippet;
|
children?: import('svelte').Snippet
|
||||||
}
|
}
|
||||||
|
|
||||||
let { class: clazz = '', children }: Props = $props();
|
let { class: clazz = '', children }: Props = $props()
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<aside
|
<aside
|
||||||
|
|||||||
@@ -77,7 +77,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { settings } from '$lib/settings.svelte.js'
|
import { settings } from '$lib/settings.svelte.js'
|
||||||
import { themeVars } from '$lib/ui/colors'
|
import { themeVars } from '$lib/ui/colors'
|
||||||
import { routes } from '$lib/util.svelte.js'
|
|
||||||
import { writable, type Readable, type Writable } from 'svelte/store'
|
import { writable, type Readable, type Writable } from 'svelte/store'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -102,9 +101,6 @@
|
|||||||
...rest
|
...rest
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
|
|
||||||
let title = $derived(
|
|
||||||
route ? routes[(route.id as keyof typeof routes) ?? ''] : '',
|
|
||||||
)
|
|
||||||
let sidePadding = $derived(
|
let sidePadding = $derived(
|
||||||
calculatePadding($dockProps.noGap, $dockProps.top, false),
|
calculatePadding($dockProps.noGap, $dockProps.top, false),
|
||||||
)
|
)
|
||||||
@@ -147,7 +143,6 @@
|
|||||||
: `border-slate-200 dark:border-zinc-800 shadow-2xl
|
: `border-slate-200 dark:border-zinc-800 shadow-2xl
|
||||||
bg-white/50 dark:bg-zinc-950/70`
|
bg-white/50 dark:bg-zinc-950/70`
|
||||||
}`,
|
}`,
|
||||||
title,
|
|
||||||
style: 'transition: border-radius 250ms;',
|
style: 'transition: border-radius 250ms;',
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -338,16 +338,14 @@ export function getGroups(
|
|||||||
default: t.get('filter.view.compact'),
|
default: t.get('filter.view.compact'),
|
||||||
}),
|
}),
|
||||||
icon: ViewColumns,
|
icon: ViewColumns,
|
||||||
handle: () =>
|
handle: () => (settings.view = 'compact'),
|
||||||
settings.view = 'compact'
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: t.get('nav.commands.setViewTo', {
|
name: t.get('nav.commands.setViewTo', {
|
||||||
default: t.get('filter.view.cozy'),
|
default: t.get('filter.view.cozy'),
|
||||||
}),
|
}),
|
||||||
icon: ViewColumns,
|
icon: ViewColumns,
|
||||||
handle: () =>
|
handle: () => (settings.view = 'cozy'),
|
||||||
settings.view = 'cozy'
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -6,14 +6,13 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
wrap?: keyof typeof wrapClass;
|
wrap?: keyof typeof wrapClass
|
||||||
class?: string;
|
class?: string
|
||||||
children?: import('svelte').Snippet;
|
children?: import('svelte').Snippet
|
||||||
}
|
}
|
||||||
|
|
||||||
let { wrap = 'wrap', class: clazz = '', children }: Props = $props();
|
let { wrap = 'wrap', class: clazz = '', children }: Props = $props()
|
||||||
|
|
||||||
let classes = $derived(`${wrapClass[wrap]} ${clazz ?? ''}`)
|
let classes = $derived(`${wrapClass[wrap]} ${clazz ?? ''}`)
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,25 +1,21 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { locale } from '$lib/translations'
|
import { locale } from '$lib/translations'
|
||||||
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
number: number;
|
number: number
|
||||||
locale?: string;
|
locale?: string
|
||||||
options?: Intl.NumberFormatOptions;
|
options?: Intl.NumberFormatOptions
|
||||||
class?: string;
|
class?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
number,
|
number,
|
||||||
locale: localeToUse = $locale,
|
locale: localeToUse = $locale,
|
||||||
options = {
|
options = {
|
||||||
notation: 'compact',
|
notation: 'compact',
|
||||||
},
|
},
|
||||||
class: clazz = ''
|
class: clazz = '',
|
||||||
}: Props = $props();
|
}: Props = $props()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<span class={clazz ?? ''}>
|
<span class={clazz ?? ''}>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
date: Date,
|
date: Date,
|
||||||
options: Intl.RelativeTimeFormatOptions,
|
options: Intl.RelativeTimeFormatOptions,
|
||||||
locale?: string,
|
locale?: string,
|
||||||
relativeTo?: Date
|
relativeTo?: Date,
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
const now = relativeTo?.getTime() ?? Date.now()
|
const now = relativeTo?.getTime() ?? Date.now()
|
||||||
@@ -41,7 +41,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { locale } from '$lib/translations'
|
import { locale } from '$lib/translations'
|
||||||
|
|
||||||
|
|
||||||
const toLocaleDateString = (date: Date): string => {
|
const toLocaleDateString = (date: Date): string => {
|
||||||
try {
|
try {
|
||||||
return date.toLocaleString()
|
return date.toLocaleString()
|
||||||
@@ -51,23 +50,23 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
date: Date;
|
date: Date
|
||||||
relativeTo?: Date | undefined;
|
relativeTo?: Date | undefined
|
||||||
options?: Intl.RelativeTimeFormatOptions;
|
options?: Intl.RelativeTimeFormatOptions
|
||||||
style?: string;
|
style?: string
|
||||||
class?: string;
|
class?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
date,
|
date,
|
||||||
relativeTo = undefined,
|
relativeTo = undefined,
|
||||||
options = {
|
options = {
|
||||||
numeric: 'always',
|
numeric: 'always',
|
||||||
style: 'narrow',
|
style: 'narrow',
|
||||||
},
|
},
|
||||||
style = '',
|
style = '',
|
||||||
class: clazz = ''
|
class: clazz = '',
|
||||||
}: Props = $props();
|
}: Props = $props()
|
||||||
|
|
||||||
let dateTime = $derived(toLocaleDateString(date))
|
let dateTime = $derived(toLocaleDateString(date))
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -3,17 +3,19 @@
|
|||||||
import { Modal } from 'mono-svelte'
|
import { Modal } from 'mono-svelte'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
object: any;
|
object: any
|
||||||
open?: boolean;
|
open?: boolean
|
||||||
title?: import('svelte').Snippet;
|
title?: import('svelte').Snippet
|
||||||
}
|
}
|
||||||
|
|
||||||
let { object, open = $bindable(false), title }: Props = $props();
|
let { object, open = $bindable(false), title }: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Modal bind:open>
|
<Modal bind:open>
|
||||||
{#snippet title()}
|
{#snippet title()}
|
||||||
<span >{#if title}{@render title()}{:else}Debug{/if}</span>
|
<span>
|
||||||
|
{#if title}{@render title()}{:else}Debug{/if}
|
||||||
|
</span>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<DebugTree {object} isParent={true} />
|
<DebugTree {object} isParent={true} />
|
||||||
</Modal>
|
</Modal>
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import DebugTree from './DebugTree.svelte';
|
import DebugTree from './DebugTree.svelte'
|
||||||
interface Props {
|
interface Props {
|
||||||
object: any;
|
object: any
|
||||||
isParent?: boolean;
|
isParent?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
let { object, isParent = false }: Props = $props();
|
let { object, isParent = false }: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ul class:ml-4={!isParent} class="leading-8">
|
<ul class:ml-4={!isParent} class="leading-8">
|
||||||
|
|||||||
@@ -1,95 +1,105 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Badge, Modal } from "mono-svelte"
|
import { Badge, Modal } from 'mono-svelte'
|
||||||
import type { Data } from "./fediseer"
|
import type { Data } from './fediseer'
|
||||||
import SectionTitle from "$lib/components/ui/SectionTitle.svelte"
|
import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
|
||||||
import LabelStat from "$lib/components/ui/LabelStat.svelte"
|
import LabelStat from '$lib/components/ui/LabelStat.svelte'
|
||||||
import Expandable from "$lib/components/ui/Expandable.svelte"
|
import Expandable from '$lib/components/ui/Expandable.svelte'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
open?: boolean;
|
open?: boolean
|
||||||
data: Data;
|
data: Data
|
||||||
}
|
}
|
||||||
|
|
||||||
let { open = $bindable(false), data }: Props = $props();
|
let { open = $bindable(false), data }: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Modal bind:open title="Fediseer">
|
<Modal bind:open title="Fediseer">
|
||||||
<div class="flex flex-col [&>*]:py-2 divide-y divide-slate-300 dark:divide-zinc-800">
|
<div
|
||||||
<Expandable class="flex flex-col gap-4">
|
class="flex flex-col [&>*]:py-2 divide-y divide-slate-300 dark:divide-zinc-800"
|
||||||
{#snippet title()}
|
>
|
||||||
<SectionTitle class="flex gap-2 items-center flex-row" >
|
<Expandable class="flex flex-col gap-4">
|
||||||
Endorsements <Badge class="w-max h-max" color="green-subtle">{data.endorsements.instances.length}</Badge>
|
{#snippet title()}
|
||||||
</SectionTitle>
|
<SectionTitle class="flex gap-2 items-center flex-row">
|
||||||
{/snippet}
|
Endorsements <Badge class="w-max h-max" color="green-subtle">
|
||||||
<div class="flex flex-row gap-6 flex-wrap">
|
{data.endorsements.instances.length}
|
||||||
{#each data.endorsements.instances as instance}
|
</Badge>
|
||||||
<div class="flex flex-col">
|
</SectionTitle>
|
||||||
<LabelStat
|
{/snippet}
|
||||||
labelClass="!text-sm"
|
<div class="flex flex-row gap-6 flex-wrap">
|
||||||
label={instance.domain}
|
{#each data.endorsements.instances as instance}
|
||||||
formatted={false}
|
<div class="flex flex-col">
|
||||||
content={instance.endorsement_reasons?.[0] || '👍'}>
|
<LabelStat
|
||||||
</LabelStat>
|
labelClass="!text-sm"
|
||||||
</div>
|
label={instance.domain}
|
||||||
{/each}
|
formatted={false}
|
||||||
</div>
|
content={instance.endorsement_reasons?.[0] || '👍'}
|
||||||
</Expandable>
|
></LabelStat>
|
||||||
<Expandable class="flex flex-col gap-4">
|
</div>
|
||||||
{#snippet title()}
|
{/each}
|
||||||
<SectionTitle class="flex gap-2 items-center flex-row" >
|
</div>
|
||||||
Guarantees <Badge class="w-max h-max" color="green-subtle">{data.guarantees.instances.length}</Badge>
|
</Expandable>
|
||||||
</SectionTitle>
|
<Expandable class="flex flex-col gap-4">
|
||||||
{/snippet}
|
{#snippet title()}
|
||||||
<div class="flex flex-row gap-6 flex-wrap">
|
<SectionTitle class="flex gap-2 items-center flex-row">
|
||||||
{#each data.guarantees.instances as instance}
|
Guarantees <Badge class="w-max h-max" color="green-subtle">
|
||||||
<div class="flex flex-col">
|
{data.guarantees.instances.length}
|
||||||
<LabelStat
|
</Badge>
|
||||||
labelClass="!text-sm"
|
</SectionTitle>
|
||||||
label={instance.domain}
|
{/snippet}
|
||||||
formatted={false}
|
<div class="flex flex-row gap-6 flex-wrap">
|
||||||
content={instance.guarantee_reasons?.[0] || '👍'}>
|
{#each data.guarantees.instances as instance}
|
||||||
</LabelStat>
|
<div class="flex flex-col">
|
||||||
</div>
|
<LabelStat
|
||||||
{/each}
|
labelClass="!text-sm"
|
||||||
</div>
|
label={instance.domain}
|
||||||
</Expandable>
|
formatted={false}
|
||||||
<Expandable class="flex flex-col gap-4">
|
content={instance.guarantee_reasons?.[0] || '👍'}
|
||||||
{#snippet title()}
|
></LabelStat>
|
||||||
<SectionTitle class="flex gap-2 items-center flex-row" >
|
</div>
|
||||||
Censures <Badge class="w-max h-max" color="red-subtle">{data.censures.instances.length}</Badge>
|
{/each}
|
||||||
</SectionTitle>
|
</div>
|
||||||
{/snippet}
|
</Expandable>
|
||||||
<div class="flex flex-row gap-6 flex-wrap">
|
<Expandable class="flex flex-col gap-4">
|
||||||
{#each data.censures.instances as instance}
|
{#snippet title()}
|
||||||
<div class="flex flex-col">
|
<SectionTitle class="flex gap-2 items-center flex-row">
|
||||||
<LabelStat
|
Censures <Badge class="w-max h-max" color="red-subtle">
|
||||||
labelClass="!text-sm"
|
{data.censures.instances.length}
|
||||||
label={instance.domain}
|
</Badge>
|
||||||
formatted={false}
|
</SectionTitle>
|
||||||
content={instance.censure_reasons?.[0] || '👎'}>
|
{/snippet}
|
||||||
</LabelStat>
|
<div class="flex flex-row gap-6 flex-wrap">
|
||||||
</div>
|
{#each data.censures.instances as instance}
|
||||||
{/each}
|
<div class="flex flex-col">
|
||||||
</div>
|
<LabelStat
|
||||||
</Expandable>
|
labelClass="!text-sm"
|
||||||
<Expandable class="flex flex-col gap-4">
|
label={instance.domain}
|
||||||
{#snippet title()}
|
formatted={false}
|
||||||
<SectionTitle class="flex gap-2 items-center flex-row" >
|
content={instance.censure_reasons?.[0] || '👎'}
|
||||||
Hesitations <Badge class="w-max h-max" color="red-subtle">{data.hesitations.instances.length}</Badge>
|
></LabelStat>
|
||||||
</SectionTitle>
|
</div>
|
||||||
{/snippet}
|
{/each}
|
||||||
<div class="flex flex-row gap-6 flex-wrap">
|
</div>
|
||||||
{#each data.hesitations.instances as instance}
|
</Expandable>
|
||||||
<div class="flex flex-col">
|
<Expandable class="flex flex-col gap-4">
|
||||||
<LabelStat
|
{#snippet title()}
|
||||||
labelClass="!text-sm"
|
<SectionTitle class="flex gap-2 items-center flex-row">
|
||||||
label={instance.domain}
|
Hesitations <Badge class="w-max h-max" color="red-subtle">
|
||||||
formatted={false}
|
{data.hesitations.instances.length}
|
||||||
content={instance.hesitation_reasons?.[0] || '👎'}>
|
</Badge>
|
||||||
</LabelStat>
|
</SectionTitle>
|
||||||
</div>
|
{/snippet}
|
||||||
{/each}
|
<div class="flex flex-row gap-6 flex-wrap">
|
||||||
</div>
|
{#each data.hesitations.instances as instance}
|
||||||
</Expandable>
|
<div class="flex flex-col">
|
||||||
</div>
|
<LabelStat
|
||||||
|
labelClass="!text-sm"
|
||||||
|
label={instance.domain}
|
||||||
|
formatted={false}
|
||||||
|
content={instance.hesitation_reasons?.[0] || '👎'}
|
||||||
|
></LabelStat>
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
</Expandable>
|
||||||
|
</div>
|
||||||
</Modal>
|
</Modal>
|
||||||
@@ -41,12 +41,22 @@ class Fediseer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getInstanceInfo(domain: string): Promise<Data> {
|
async getInstanceInfo(domain: string): Promise<Data> {
|
||||||
const [endorsements, hesitations, guarantees, censures] = await Promise.all([
|
const [endorsements, hesitations, guarantees, censures] = await Promise.all(
|
||||||
fetch(`${this.url}/v1/endorsements/${domain}`).then(r => r.json()) as Promise<Endorsements>,
|
[
|
||||||
fetch(`${this.url}/v1/hesitations/${domain}`).then(r => r.json()) as Promise<Hesitations>,
|
fetch(`${this.url}/v1/endorsements/${domain}`).then((r) =>
|
||||||
fetch(`${this.url}/v1/guarantees/${domain}`).then(r => r.json()) as Promise<Guarantees>,
|
r.json(),
|
||||||
fetch(`${this.url}/v1/censures/${domain}`).then(r => r.json()) as Promise<Censures>
|
) as Promise<Endorsements>,
|
||||||
])
|
fetch(`${this.url}/v1/hesitations/${domain}`).then((r) =>
|
||||||
|
r.json(),
|
||||||
|
) as Promise<Hesitations>,
|
||||||
|
fetch(`${this.url}/v1/guarantees/${domain}`).then((r) =>
|
||||||
|
r.json(),
|
||||||
|
) as Promise<Guarantees>,
|
||||||
|
fetch(`${this.url}/v1/censures/${domain}`).then((r) =>
|
||||||
|
r.json(),
|
||||||
|
) as Promise<Censures>,
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
return { endorsements, hesitations, guarantees, censures }
|
return { endorsements, hesitations, guarantees, censures }
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-13
@@ -3,10 +3,13 @@ enum SwipeDirection {
|
|||||||
Down = 'down',
|
Down = 'down',
|
||||||
Left = 'left',
|
Left = 'left',
|
||||||
Right = 'right',
|
Right = 'right',
|
||||||
None = 'none'
|
None = 'none',
|
||||||
}
|
}
|
||||||
|
|
||||||
export function swipeGesture(node: HTMLElement, swipe: (dir: SwipeDirection) => any) {
|
export function swipeGesture(
|
||||||
|
node: HTMLElement,
|
||||||
|
swipe: (dir: SwipeDirection) => any,
|
||||||
|
) {
|
||||||
let touchstartX = 0
|
let touchstartX = 0
|
||||||
let touchstartY = 0
|
let touchstartY = 0
|
||||||
let touchendX = 0
|
let touchendX = 0
|
||||||
@@ -20,7 +23,7 @@ export function swipeGesture(node: HTMLElement, swipe: (dir: SwipeDirection) =>
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
touchstartY = event?.screenY
|
touchstartY = event?.screenY
|
||||||
},
|
},
|
||||||
false
|
false,
|
||||||
)
|
)
|
||||||
|
|
||||||
node?.addEventListener(
|
node?.addEventListener(
|
||||||
@@ -31,7 +34,7 @@ export function swipeGesture(node: HTMLElement, swipe: (dir: SwipeDirection) =>
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
touchstartY = event?.screenY
|
touchstartY = event?.screenY
|
||||||
},
|
},
|
||||||
false
|
false,
|
||||||
)
|
)
|
||||||
|
|
||||||
node?.addEventListener(
|
node?.addEventListener(
|
||||||
@@ -43,7 +46,7 @@ export function swipeGesture(node: HTMLElement, swipe: (dir: SwipeDirection) =>
|
|||||||
touchendY = event.screenY
|
touchendY = event.screenY
|
||||||
return swipe(swipeDir(touchstartX, touchstartY, touchendX, touchendY))
|
return swipe(swipeDir(touchstartX, touchstartY, touchendX, touchendY))
|
||||||
},
|
},
|
||||||
false
|
false,
|
||||||
)
|
)
|
||||||
|
|
||||||
node?.addEventListener(
|
node?.addEventListener(
|
||||||
@@ -55,7 +58,7 @@ export function swipeGesture(node: HTMLElement, swipe: (dir: SwipeDirection) =>
|
|||||||
touchendY = event.screenY
|
touchendY = event.screenY
|
||||||
return swipe(swipeDir(touchstartX, touchstartY, touchendX, touchendY))
|
return swipe(swipeDir(touchstartX, touchstartY, touchendX, touchendY))
|
||||||
},
|
},
|
||||||
false
|
false,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,26 +66,26 @@ function swipeDir(
|
|||||||
touchStartX: number,
|
touchStartX: number,
|
||||||
touchStartY: number,
|
touchStartY: number,
|
||||||
touchEndX: number,
|
touchEndX: number,
|
||||||
touchEndY: number
|
touchEndY: number,
|
||||||
): SwipeDirection {
|
): SwipeDirection {
|
||||||
const deltaX = touchEndX - touchStartX;
|
const deltaX = touchEndX - touchStartX
|
||||||
const deltaY = touchEndY - touchStartY;
|
const deltaY = touchEndY - touchStartY
|
||||||
|
|
||||||
// Define a threshold for the minimum swipe distance
|
// Define a threshold for the minimum swipe distance
|
||||||
const minSwipeDistance = 10; // Adjust this value as needed
|
const minSwipeDistance = 10 // Adjust this value as needed
|
||||||
|
|
||||||
// Check the absolute difference between deltaX and deltaY
|
// Check the absolute difference between deltaX and deltaY
|
||||||
if (Math.abs(deltaX) >= Math.abs(deltaY)) {
|
if (Math.abs(deltaX) >= Math.abs(deltaY)) {
|
||||||
// Horizontal swipe
|
// Horizontal swipe
|
||||||
if (Math.abs(deltaX) >= minSwipeDistance) {
|
if (Math.abs(deltaX) >= minSwipeDistance) {
|
||||||
return deltaX > 0 ? SwipeDirection.Right : SwipeDirection.Left;
|
return deltaX > 0 ? SwipeDirection.Right : SwipeDirection.Left
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Vertical swipe
|
// Vertical swipe
|
||||||
if (Math.abs(deltaY) >= minSwipeDistance) {
|
if (Math.abs(deltaY) >= minSwipeDistance) {
|
||||||
return deltaY > 0 ? SwipeDirection.Down : SwipeDirection.Up;
|
return deltaY > 0 ? SwipeDirection.Down : SwipeDirection.Up
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return SwipeDirection.None;
|
return SwipeDirection.None
|
||||||
}
|
}
|
||||||
+6
-6
@@ -25,12 +25,12 @@ async function customFetch(
|
|||||||
func:
|
func:
|
||||||
| ((
|
| ((
|
||||||
input: RequestInfo | URL,
|
input: RequestInfo | URL,
|
||||||
init?: RequestInit | undefined
|
init?: RequestInit | undefined,
|
||||||
) => Promise<Response>)
|
) => Promise<Response>)
|
||||||
| undefined,
|
| undefined,
|
||||||
input: RequestInfo | URL,
|
input: RequestInfo | URL,
|
||||||
init?: RequestInit | undefined,
|
init?: RequestInit | undefined,
|
||||||
auth?: string
|
auth?: string,
|
||||||
): Promise<Response> {
|
): Promise<Response> {
|
||||||
const f = func ? func : fetch
|
const f = func ? func : fetch
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ export function client({
|
|||||||
instanceURL?: string
|
instanceURL?: string
|
||||||
func?: (
|
func?: (
|
||||||
input: RequestInfo | URL,
|
input: RequestInfo | URL,
|
||||||
init?: RequestInit | undefined
|
init?: RequestInit | undefined,
|
||||||
) => Promise<Response>
|
) => Promise<Response>
|
||||||
auth?: string
|
auth?: string
|
||||||
} = {}) {
|
} = {}) {
|
||||||
@@ -84,9 +84,9 @@ export function getClient(
|
|||||||
instanceURL?: string,
|
instanceURL?: string,
|
||||||
func?: (
|
func?: (
|
||||||
input: RequestInfo | URL,
|
input: RequestInfo | URL,
|
||||||
init?: RequestInit | undefined
|
init?: RequestInit | undefined,
|
||||||
) => Promise<Response>,
|
) => Promise<Response>,
|
||||||
auth?: string
|
auth?: string,
|
||||||
): LemmyHttp {
|
): LemmyHttp {
|
||||||
return client({ instanceURL, func, auth })
|
return client({ instanceURL, func, auth })
|
||||||
}
|
}
|
||||||
@@ -107,7 +107,7 @@ export async function validateInstance(instance: string): Promise<boolean> {
|
|||||||
|
|
||||||
export function mayBeIncompatible(
|
export function mayBeIncompatible(
|
||||||
minVersion: string,
|
minVersion: string,
|
||||||
availableVersion: string
|
availableVersion: string,
|
||||||
) {
|
) {
|
||||||
if (minVersion.valueOf() === availableVersion.valueOf()) return false
|
if (minVersion.valueOf() === availableVersion.valueOf()) return false
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export interface ContentView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const isSubmissionView = (
|
const isSubmissionView = (
|
||||||
item: SubmissionView | ContentView
|
item: SubmissionView | ContentView,
|
||||||
): item is SubmissionView => !('type' in item)
|
): item is SubmissionView => !('type' in item)
|
||||||
|
|
||||||
const isSubmission = (item: Submission | ContentView): item is Submission =>
|
const isSubmission = (item: Submission | ContentView): item is Submission =>
|
||||||
@@ -63,7 +63,7 @@ export const contentItem = (item: Submission): ContentView => {
|
|||||||
export async function save(
|
export async function save(
|
||||||
item: ContentView | SubmissionView,
|
item: ContentView | SubmissionView,
|
||||||
save: boolean,
|
save: boolean,
|
||||||
jwt: string
|
jwt: string,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
if (isSubmissionView(item)) item = contentView(item)
|
if (isSubmissionView(item)) item = contentView(item)
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ export async function save(
|
|||||||
export async function deleteItem(
|
export async function deleteItem(
|
||||||
item: ContentView | SubmissionView,
|
item: ContentView | SubmissionView,
|
||||||
deleted: boolean,
|
deleted: boolean,
|
||||||
jwt: string
|
jwt: string,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
if (isSubmissionView(item)) item = contentView(item)
|
if (isSubmissionView(item)) item = contentView(item)
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ export async function deleteItem(
|
|||||||
export async function vote(
|
export async function vote(
|
||||||
item: ContentView | Submission,
|
item: ContentView | Submission,
|
||||||
vote: number,
|
vote: number,
|
||||||
jwt: string
|
jwt: string,
|
||||||
): Promise<{ upvotes: number; downvotes: number; score: number }> {
|
): Promise<{ upvotes: number; downvotes: number; score: number }> {
|
||||||
if (isSubmission(item)) item = contentItem(item)
|
if (isSubmission(item)) item = contentItem(item)
|
||||||
|
|
||||||
@@ -138,7 +138,7 @@ export async function vote(
|
|||||||
export async function markAsRead(
|
export async function markAsRead(
|
||||||
item: ContentView | Submission,
|
item: ContentView | Submission,
|
||||||
read: boolean,
|
read: boolean,
|
||||||
jwt: string
|
jwt: string,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
if (isSubmission(item)) item = contentItem(item)
|
if (isSubmission(item)) item = contentItem(item)
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ export const generalizeCommentReply = (item: CommentReplyView): InboxItem => ({
|
|||||||
})
|
})
|
||||||
|
|
||||||
export const generalizePersonMention = (
|
export const generalizePersonMention = (
|
||||||
item: PersonMentionView
|
item: PersonMentionView,
|
||||||
): InboxItem => ({
|
): InboxItem => ({
|
||||||
type: 'person_mention',
|
type: 'person_mention',
|
||||||
id: item.person_mention.id,
|
id: item.person_mention.id,
|
||||||
@@ -38,7 +38,7 @@ export const generalizePersonMention = (
|
|||||||
})
|
})
|
||||||
|
|
||||||
export const generalizePrivateMessage = (
|
export const generalizePrivateMessage = (
|
||||||
item: PrivateMessageView
|
item: PrivateMessageView,
|
||||||
): InboxItem => ({
|
): InboxItem => ({
|
||||||
type: 'private_message',
|
type: 'private_message',
|
||||||
id: item.private_message.id,
|
id: item.private_message.id,
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ export const isCommentReport = (item: Result): item is CommentReportView =>
|
|||||||
'comment_report' in item
|
'comment_report' in item
|
||||||
|
|
||||||
export const isPrivateMessageReport = (
|
export const isPrivateMessageReport = (
|
||||||
item: Result
|
item: Result,
|
||||||
): item is PrivateMessageReportView => 'private_message_report' in item
|
): item is PrivateMessageReportView => 'private_message_report' in item
|
||||||
|
|
||||||
export interface ResumableItem {
|
export interface ResumableItem {
|
||||||
@@ -86,15 +86,18 @@ function resumableStore(limit: number = 10) {
|
|||||||
const { subscribe, set, update } = writable<ResumableItem[]>([])
|
const { subscribe, set, update } = writable<ResumableItem[]>([])
|
||||||
|
|
||||||
return {
|
return {
|
||||||
subscribe, set, update,
|
subscribe,
|
||||||
|
set,
|
||||||
|
update,
|
||||||
add: (item: ResumableItem) => {
|
add: (item: ResumableItem) => {
|
||||||
update(resumables => {
|
update((resumables) => {
|
||||||
if (resumables.find(i => JSON.stringify(i) == JSON.stringify(item))) return resumables
|
if (resumables.find((i) => JSON.stringify(i) == JSON.stringify(item)))
|
||||||
|
return resumables
|
||||||
resumables.unshift(item)
|
resumables.unshift(item)
|
||||||
if (resumables.length > limit) resumables.pop()
|
if (resumables.length > limit) resumables.pop()
|
||||||
return resumables
|
return resumables
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { get, writable } from 'svelte/store'
|
|||||||
export const shouldReload = (
|
export const shouldReload = (
|
||||||
cache: PostFeed | undefined,
|
cache: PostFeed | undefined,
|
||||||
url: URL,
|
url: URL,
|
||||||
instance: string
|
instance: string,
|
||||||
): boolean =>
|
): boolean =>
|
||||||
cache?.instance != instance || cache?.url.toString() != url.toString()
|
cache?.instance != instance || cache?.url.toString() != url.toString()
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ export async function postFeed(args: {
|
|||||||
url: URL
|
url: URL
|
||||||
fetch?: (
|
fetch?: (
|
||||||
input: RequestInfo | URL,
|
input: RequestInfo | URL,
|
||||||
init?: RequestInit | undefined
|
init?: RequestInit | undefined,
|
||||||
) => Promise<Response>
|
) => Promise<Response>
|
||||||
}) {
|
}) {
|
||||||
const feed = get(postFeeds)[args.id]
|
const feed = get(postFeeds)[args.id]
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ interface BaseReport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const generalizeCommentReport = (
|
export const generalizeCommentReport = (
|
||||||
report: CommentReportView
|
report: CommentReportView,
|
||||||
): ReportView => ({
|
): ReportView => ({
|
||||||
creator: report.creator,
|
creator: report.creator,
|
||||||
item: {
|
item: {
|
||||||
@@ -77,7 +77,7 @@ export const generalizePostReport = (report: PostReportView): ReportView => ({
|
|||||||
})
|
})
|
||||||
|
|
||||||
export const generalizePrivateMessageReport = (
|
export const generalizePrivateMessageReport = (
|
||||||
report: PrivateMessageReportView
|
report: PrivateMessageReportView,
|
||||||
): ReportView => ({
|
): ReportView => ({
|
||||||
creator: report.creator,
|
creator: report.creator,
|
||||||
item: report.private_message,
|
item: report.private_message,
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export const isBlocked = (me: MyUserInfo, user: number) =>
|
|||||||
|
|
||||||
export const addSubscription = (
|
export const addSubscription = (
|
||||||
community: Community,
|
community: Community,
|
||||||
subscribe: boolean = true
|
subscribe: boolean = true,
|
||||||
) => {
|
) => {
|
||||||
const p = get(profile)
|
const p = get(profile)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
|
||||||
const badgeColor = {
|
const badgeColor = {
|
||||||
red: 'bg-red-500 text-white ring-transparent',
|
red: 'bg-red-500 text-white ring-transparent',
|
||||||
green: 'bg-green-500 text-white dark:text-black ring-transparent',
|
green: 'bg-green-500 text-white dark:text-black ring-transparent',
|
||||||
@@ -31,15 +30,14 @@
|
|||||||
type BadgeColor = keyof typeof badgeColor
|
type BadgeColor = keyof typeof badgeColor
|
||||||
type BadgeRoundness = keyof typeof badgeRoundness
|
type BadgeRoundness = keyof typeof badgeRoundness
|
||||||
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
label?: string;
|
label?: string
|
||||||
color?: BadgeColor;
|
color?: BadgeColor
|
||||||
rounding?: BadgeRoundness;
|
rounding?: BadgeRoundness
|
||||||
allowIconOnly?: boolean;
|
allowIconOnly?: boolean
|
||||||
class?: string;
|
class?: string
|
||||||
icon?: import('svelte').Snippet;
|
icon?: import('svelte').Snippet
|
||||||
children?: import('svelte').Snippet;
|
children?: import('svelte').Snippet
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
@@ -51,8 +49,7 @@
|
|||||||
icon,
|
icon,
|
||||||
children,
|
children,
|
||||||
...rest
|
...rest
|
||||||
}: Props = $props();
|
}: Props = $props()
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<span
|
<span
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
import { slide } from 'svelte/transition'
|
import { slide } from 'svelte/transition'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
open?: boolean;
|
open?: boolean
|
||||||
class?: string;
|
class?: string
|
||||||
summary?: import('svelte').Snippet<[any]>;
|
summary?: import('svelte').Snippet<[any]>
|
||||||
extended?: import('svelte').Snippet;
|
extended?: import('svelte').Snippet
|
||||||
children?: import('svelte').Snippet<[any]>;
|
children?: import('svelte').Snippet<[any]>
|
||||||
[key: string]: any
|
[key: string]: any
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,18 +18,17 @@
|
|||||||
extended,
|
extended,
|
||||||
children,
|
children,
|
||||||
...rest
|
...rest
|
||||||
}: Props = $props();
|
}: Props = $props()
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div {...rest} class={clazz}>
|
<div {...rest} class={clazz}>
|
||||||
<button onclick={() => (open = !open)} class="w-full">
|
<button onclick={() => (open = !open)} class="w-full">
|
||||||
{@render summary?.({ open, })}
|
{@render summary?.({ open })}
|
||||||
</button>
|
</button>
|
||||||
{@render extended?.()}
|
{@render extended?.()}
|
||||||
{#if open}
|
{#if open}
|
||||||
<div transition:slide={{ axis: 'y', easing: expoOut, duration: 300 }}>
|
<div transition:slide={{ axis: 'y', easing: expoOut, duration: 300 }}>
|
||||||
{@render children?.({ open, })}
|
{@render children?.({ open })}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
@@ -1,27 +1,35 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
interface Props {
|
interface Props {
|
||||||
defaultValue?: boolean;
|
defaultValue?: boolean
|
||||||
checked?: boolean | undefined;
|
checked?: boolean | undefined
|
||||||
inlineDescription?: boolean;
|
inlineDescription?: boolean
|
||||||
children?: import('svelte').Snippet;
|
children?: import('svelte').Snippet
|
||||||
description?: import('svelte').Snippet;
|
description?: import('svelte').Snippet
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
defaultValue = false,
|
defaultValue = false,
|
||||||
checked = $bindable(defaultValue),
|
checked = $bindable(defaultValue),
|
||||||
inlineDescription = false,
|
inlineDescription = false,
|
||||||
children,
|
children,
|
||||||
description
|
description,
|
||||||
}: Props = $props();
|
}: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<label class="font-normal cursor-pointer text-sm flex flex-row items-baseline gap-2">
|
<label
|
||||||
<input type="checkbox" bind:checked class="cursor-pointer" />
|
class="font-normal cursor-pointer text-sm flex flex-row items-baseline gap-2"
|
||||||
<div class="inline-flex {inlineDescription ? 'flex-row' : 'flex-col'} font-medium gap-1">
|
>
|
||||||
{@render children?.()}
|
<input type="checkbox" bind:checked class="cursor-pointer" />
|
||||||
{#if description}
|
<div
|
||||||
<span class="font-normal text-slate-600 dark:text-zinc-400">{@render description?.()}</span>
|
class="inline-flex {inlineDescription
|
||||||
{/if}
|
? 'flex-row'
|
||||||
</div>
|
: 'flex-col'} font-medium gap-1"
|
||||||
|
>
|
||||||
|
{@render children?.()}
|
||||||
|
{#if description}
|
||||||
|
<span class="font-normal text-slate-600 dark:text-zinc-400">
|
||||||
|
{@render description?.()}
|
||||||
|
</span>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
</label>
|
</label>
|
||||||
@@ -1,14 +1,12 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
for?: string | undefined;
|
for?: string | undefined
|
||||||
/**
|
/**
|
||||||
* 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?: string
|
||||||
children?: import('svelte').Snippet;
|
children?: import('svelte').Snippet
|
||||||
[key: string]: any
|
[key: string]: any
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,8 +16,7 @@
|
|||||||
class: clazz = '',
|
class: clazz = '',
|
||||||
children,
|
children,
|
||||||
...rest
|
...rest
|
||||||
}: Props = $props();
|
}: Props = $props()
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:element
|
<svelte:element
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { createBubbler } from 'svelte/legacy';
|
import { createBubbler } from 'svelte/legacy'
|
||||||
|
|
||||||
const bubble = createBubbler();
|
const bubble = createBubbler()
|
||||||
import { generateID } from '../forms/helper.js'
|
import { generateID } from '../forms/helper.js'
|
||||||
|
|
||||||
type T = $$Generic
|
type T = $$Generic
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
value: T;
|
value: T
|
||||||
group: T;
|
group: T
|
||||||
inlineDescription?: boolean;
|
inlineDescription?: boolean
|
||||||
id?: string;
|
id?: string
|
||||||
disabled?: boolean;
|
disabled?: boolean
|
||||||
children?: import('svelte').Snippet;
|
children?: import('svelte').Snippet
|
||||||
description?: import('svelte').Snippet;
|
description?: import('svelte').Snippet
|
||||||
[key: string]: any
|
[key: string]: any
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
children,
|
children,
|
||||||
description,
|
description,
|
||||||
...rest
|
...rest
|
||||||
}: Props = $props();
|
}: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -2,25 +2,24 @@
|
|||||||
import { generateID } from '../forms/helper.js'
|
import { generateID } from '../forms/helper.js'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
group?: string;
|
group?: string
|
||||||
row?: boolean;
|
row?: boolean
|
||||||
class?: string;
|
class?: string
|
||||||
children?: import('svelte').Snippet<[any]>;
|
children?: import('svelte').Snippet<[any]>
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
group = generateID(),
|
group = generateID(),
|
||||||
row = false,
|
row = false,
|
||||||
class: clazz = '',
|
class: clazz = '',
|
||||||
children
|
children,
|
||||||
}: Props = $props();
|
}: Props = $props()
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-col gap-1">
|
<div class="flex flex-col gap-1">
|
||||||
<div
|
<div
|
||||||
class="flex {row ? 'flex-row flex-wrap' : 'flex-col'} gap-4 {clazz || ''}"
|
class="flex {row ? 'flex-row flex-wrap' : 'flex-col'} gap-4 {clazz || ''}"
|
||||||
>
|
>
|
||||||
{@render children?.({ group, })}
|
{@render children?.({ group })}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
defaultValue?: boolean;
|
defaultValue?: boolean
|
||||||
checked?: boolean;
|
checked?: boolean
|
||||||
labelClass?: string;
|
labelClass?: string
|
||||||
class?: string;
|
class?: string
|
||||||
children?: import('svelte').Snippet;
|
children?: import('svelte').Snippet
|
||||||
description?: import('svelte').Snippet;
|
description?: import('svelte').Snippet
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
@@ -15,9 +14,8 @@
|
|||||||
labelClass = '',
|
labelClass = '',
|
||||||
class: clazz = '',
|
class: clazz = '',
|
||||||
children,
|
children,
|
||||||
description
|
description,
|
||||||
}: Props = $props();
|
}: Props = $props()
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<label
|
<label
|
||||||
@@ -39,7 +37,7 @@
|
|||||||
class="box-border w-5 h-full bg-white peer-checked:dark:bg-black rounded-full shadow-sm
|
class="box-border w-5 h-full bg-white peer-checked:dark:bg-black rounded-full shadow-sm
|
||||||
group-active:w-6 transition peer-checked:translate-x-5 group-active:peer-checked:translate-x-4
|
group-active:w-6 transition peer-checked:translate-x-5 group-active:peer-checked:translate-x-4
|
||||||
rtl:peer-checked:-translate-x-5 rtl:group-active:peer-checked:-translate-x-4"
|
rtl:peer-checked:-translate-x-5 rtl:group-active:peer-checked:-translate-x-4"
|
||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col {labelClass}">
|
<div class="flex flex-col {labelClass}">
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
interface Props {
|
interface Props {
|
||||||
width?: number;
|
width?: number
|
||||||
[key: string]: any
|
[key: string]: any
|
||||||
}
|
}
|
||||||
|
|
||||||
let { width = 16, ...rest }: Props = $props();
|
let { width = 16, ...rest }: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svg
|
<svg
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { createBubbler } from 'svelte/legacy';
|
import { createBubbler } from 'svelte/legacy'
|
||||||
|
|
||||||
const bubble = createBubbler();
|
const bubble = createBubbler()
|
||||||
type Elevation = keyof typeof elevationClass
|
type Elevation = keyof typeof elevationClass
|
||||||
type Padding = keyof typeof paddingClass
|
type Padding = keyof typeof paddingClass
|
||||||
type Rounding = keyof typeof roundedClass
|
type Rounding = keyof typeof roundedClass
|
||||||
@@ -46,15 +46,14 @@
|
|||||||
none: '',
|
none: '',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
elevation?: Elevation;
|
elevation?: Elevation
|
||||||
padding?: Padding;
|
padding?: Padding
|
||||||
rounding?: Rounding;
|
rounding?: Rounding
|
||||||
color?: Color;
|
color?: Color
|
||||||
element?: string;
|
element?: string
|
||||||
class?: string;
|
class?: string
|
||||||
children?: import('svelte').Snippet;
|
children?: import('svelte').Snippet
|
||||||
[key: string]: any
|
[key: string]: any
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,8 +66,7 @@
|
|||||||
class: clazz = '',
|
class: clazz = '',
|
||||||
children,
|
children,
|
||||||
...rest
|
...rest
|
||||||
}: Props = $props();
|
}: Props = $props()
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:element
|
<svelte:element
|
||||||
|
|||||||
+46
-46
@@ -4,62 +4,62 @@ import { writable } from 'svelte/store'
|
|||||||
export let shownModal = writable<Modal | undefined>(undefined)
|
export let shownModal = writable<Modal | undefined>(undefined)
|
||||||
|
|
||||||
interface Modal {
|
interface Modal {
|
||||||
actions: Action[]
|
actions: Action[]
|
||||||
title: string
|
title: string
|
||||||
body?: string
|
body?: string
|
||||||
/**
|
/**
|
||||||
* Whether the modal has a close button or not
|
* Whether the modal has a close button or not
|
||||||
*/
|
*/
|
||||||
dismissable: boolean
|
dismissable: boolean
|
||||||
type: 'error' | 'info' | 'success'
|
type: 'error' | 'info' | 'success'
|
||||||
}
|
}
|
||||||
|
|
||||||
type Action = {
|
type Action = {
|
||||||
/**
|
/**
|
||||||
* What function to run when this action is clicked. If undefined, it'll close the window.
|
* What function to run when this action is clicked. If undefined, it'll close the window.
|
||||||
*/
|
*/
|
||||||
action: () => any
|
action: () => any
|
||||||
type: 'danger' | 'secondary' | 'primary'
|
type: 'danger' | 'secondary' | 'primary'
|
||||||
content: string
|
content: string
|
||||||
icon?: IconSource
|
icon?: IconSource
|
||||||
close: boolean
|
close: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export const action = (action?: {
|
export const action = (action?: {
|
||||||
action?: () => any
|
action?: () => any
|
||||||
type?: 'danger' | 'secondary' | 'primary'
|
type?: 'danger' | 'secondary' | 'primary'
|
||||||
content?: string
|
content?: string
|
||||||
icon?: IconSource
|
icon?: IconSource
|
||||||
close?: boolean
|
close?: boolean
|
||||||
}): Action => ({
|
}): Action => ({
|
||||||
action: action?.action
|
action: action?.action
|
||||||
? () => {
|
? () => {
|
||||||
action?.action?.()
|
action?.action?.()
|
||||||
if (action.close) shownModal.set(undefined)
|
if (action.close) shownModal.set(undefined)
|
||||||
}
|
}
|
||||||
: () => shownModal.set(undefined),
|
: () => shownModal.set(undefined),
|
||||||
type: action?.type ?? 'secondary',
|
type: action?.type ?? 'secondary',
|
||||||
content: action?.content || 'OK',
|
content: action?.content || 'OK',
|
||||||
close: action?.close ?? true
|
close: action?.close ?? true,
|
||||||
})
|
})
|
||||||
|
|
||||||
export function modal(inputModal: {
|
export function modal(inputModal: {
|
||||||
actions?: Action[]
|
actions?: Action[]
|
||||||
title: string
|
title: string
|
||||||
body: string
|
body: string
|
||||||
/**
|
/**
|
||||||
* Whether the modal has a close button or not
|
* Whether the modal has a close button or not
|
||||||
*/
|
*/
|
||||||
dismissable?: boolean
|
dismissable?: boolean
|
||||||
type?: 'error' | 'info' | 'success'
|
type?: 'error' | 'info' | 'success'
|
||||||
}) {
|
}) {
|
||||||
const modal: Modal = {
|
const modal: Modal = {
|
||||||
actions: inputModal.actions ?? [action()],
|
actions: inputModal.actions ?? [action()],
|
||||||
dismissable: inputModal.dismissable ?? true,
|
dismissable: inputModal.dismissable ?? true,
|
||||||
title: inputModal.title,
|
title: inputModal.title,
|
||||||
body: inputModal.body,
|
body: inputModal.body,
|
||||||
type: inputModal.type ?? 'info'
|
type: inputModal.type ?? 'info',
|
||||||
}
|
}
|
||||||
|
|
||||||
shownModal.set(modal)
|
shownModal.set(modal)
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Routebar from './Routebar.svelte';
|
import Routebar from './Routebar.svelte'
|
||||||
import Button from '../button/Button.svelte'
|
import Button from '../button/Button.svelte'
|
||||||
|
|
||||||
type Route = string
|
type Route = string
|
||||||
@@ -10,24 +10,22 @@
|
|||||||
name: string
|
name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
/**
|
/**
|
||||||
* The routes for the routebar.
|
* The routes for the routebar.
|
||||||
*/
|
*/
|
||||||
routes: RouteObject[];
|
routes: RouteObject[]
|
||||||
currentRoute?: Route | undefined;
|
currentRoute?: Route | undefined
|
||||||
parentRoute?: Route | undefined;
|
parentRoute?: Route | undefined
|
||||||
depth?: number;
|
depth?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
routes,
|
routes,
|
||||||
currentRoute = undefined,
|
currentRoute = undefined,
|
||||||
parentRoute = undefined,
|
parentRoute = undefined,
|
||||||
depth = 0
|
depth = 0,
|
||||||
}: Props = $props();
|
}: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:element this={depth == 0 ? 'nav' : 'ul'} class="flex flex-col h-full">
|
<svelte:element this={depth == 0 ? 'nav' : 'ul'} class="flex flex-col h-full">
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
import { Icon, InformationCircle } from 'svelte-hero-icons'
|
import { Icon, InformationCircle } from 'svelte-hero-icons'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
content?: string | undefined;
|
content?: string | undefined
|
||||||
children?: import('svelte').Snippet;
|
children?: import('svelte').Snippet
|
||||||
}
|
}
|
||||||
|
|
||||||
let { content = undefined, children }: Props = $props();
|
let { content = undefined, children }: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Material
|
<Material
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
<script>
|
<script>
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} Props
|
* @typedef {Object} Props
|
||||||
* @property {import('svelte').Snippet} [children]
|
* @property {import('svelte').Snippet} [children]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @type {Props} */
|
/** @type {Props} */
|
||||||
let { children } = $props();
|
let { children } = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="text-slate-800 dark:text-zinc-200 text-xs font-medium py-2 px-2 flex items-center gap-1"
|
class="text-slate-800 dark:text-zinc-200 text-xs font-medium py-2 px-2 flex items-center gap-1"
|
||||||
>
|
>
|
||||||
<div>{@render children?.()}</div>
|
<div>{@render children?.()}</div>
|
||||||
<hr class="flex-shrink flex-1 border-slate-200 dark:border-zinc-800 border-opacity-70" />
|
<hr
|
||||||
|
class="flex-shrink flex-1 border-slate-200 dark:border-zinc-800 border-opacity-70"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
// https://github.com/sveltejs/svelte/issues/3088#issuecomment-505785516
|
// https://github.com/sveltejs/svelte/issues/3088#issuecomment-505785516
|
||||||
import { onMount, onDestroy, createEventDispatcher } from 'svelte'
|
import { onMount, onDestroy, createEventDispatcher } from 'svelte'
|
||||||
let slottedElements: HTMLDivElement = $state(), portal: HTMLDivElement
|
let slottedElements: HTMLDivElement = $state(),
|
||||||
|
portal: HTMLDivElement
|
||||||
|
|
||||||
const dispatch = createEventDispatcher<{ mounted: void }>()
|
const dispatch = createEventDispatcher<{ mounted: void }>()
|
||||||
|
|
||||||
@@ -21,12 +22,11 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
class?: string;
|
class?: string
|
||||||
children?: import('svelte').Snippet;
|
children?: import('svelte').Snippet
|
||||||
}
|
}
|
||||||
|
|
||||||
let { class: clazz = '', children }: Props = $props();
|
let { class: clazz = '', children }: Props = $props()
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="portal-initial-mount-point">
|
<div class="portal-initial-mount-point">
|
||||||
|
|||||||
@@ -14,10 +14,10 @@
|
|||||||
import { fly } from 'svelte/transition'
|
import { fly } from 'svelte/transition'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
toast: Toast;
|
toast: Toast
|
||||||
}
|
}
|
||||||
|
|
||||||
let { toast }: Props = $props();
|
let { toast }: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -3,63 +3,65 @@ import { writable } from 'svelte/store'
|
|||||||
type ToastType = keyof typeof toastColors
|
type ToastType = keyof typeof toastColors
|
||||||
|
|
||||||
export const toastColors = {
|
export const toastColors = {
|
||||||
error: 'bg-white dark:bg-zinc-950 text-red-600 dark:text-red-400 border border-red-700',
|
error:
|
||||||
warning:
|
'bg-white dark:bg-zinc-950 text-red-600 dark:text-red-400 border border-red-700',
|
||||||
'bg-white dark:bg-zinc-950 text-yellow-600 dark:text-yellow-400 border border-yellow-600',
|
warning:
|
||||||
success: 'bg-white dark:bg-zinc-950 text-green-700 dark:text-green-400 border border-green-500',
|
'bg-white dark:bg-zinc-950 text-yellow-600 dark:text-yellow-400 border border-yellow-600',
|
||||||
info: 'dark:bg-zinc-950 bg-white border border-slate-200 dark:border-zinc-800 shadow-lg'
|
success:
|
||||||
|
'bg-white dark:bg-zinc-950 text-green-700 dark:text-green-400 border border-green-500',
|
||||||
|
info: 'dark:bg-zinc-950 bg-white border border-slate-200 dark:border-zinc-800 shadow-lg',
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Toast {
|
export interface Toast {
|
||||||
id: number
|
id: number
|
||||||
title?: string
|
title?: string
|
||||||
content: string
|
content: string
|
||||||
type: ToastType
|
type: ToastType
|
||||||
loading?: boolean
|
loading?: boolean
|
||||||
action?: () => any
|
action?: () => any
|
||||||
}
|
}
|
||||||
|
|
||||||
export const toasts = writable<Toast[]>([])
|
export const toasts = writable<Toast[]>([])
|
||||||
|
|
||||||
export function toast({
|
export function toast({
|
||||||
title,
|
title,
|
||||||
content,
|
content,
|
||||||
type = 'info',
|
type = 'info',
|
||||||
duration = 5000,
|
duration = 5000,
|
||||||
loading = false,
|
loading = false,
|
||||||
action
|
action,
|
||||||
}: {
|
}: {
|
||||||
title?: string
|
title?: string
|
||||||
content: string
|
content: string
|
||||||
type?: ToastType
|
type?: ToastType
|
||||||
duration?: number
|
duration?: number
|
||||||
loading?: boolean
|
loading?: boolean
|
||||||
action?: () => any
|
action?: () => any
|
||||||
}) {
|
}) {
|
||||||
let id = 0
|
let id = 0
|
||||||
|
|
||||||
toasts.update((toasts) => {
|
toasts.update((toasts) => {
|
||||||
id = Math.floor(Math.random() * 10000)
|
id = Math.floor(Math.random() * 10000)
|
||||||
|
|
||||||
return [
|
return [
|
||||||
...toasts,
|
...toasts,
|
||||||
{
|
{
|
||||||
id: id,
|
id: id,
|
||||||
content: content,
|
content: content,
|
||||||
title: title,
|
title: title,
|
||||||
type: type,
|
type: type,
|
||||||
loading: loading,
|
loading: loading,
|
||||||
action: action
|
action: action,
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
toasts.update((toasts) => toasts.filter((toast) => toast.id != id))
|
toasts.update((toasts) => toasts.filter((toast) => toast.id != id))
|
||||||
}, duration)
|
}, duration)
|
||||||
|
|
||||||
return id
|
return id
|
||||||
}
|
}
|
||||||
|
|
||||||
export const removeToast = (id: number) =>
|
export const removeToast = (id: number) =>
|
||||||
toasts.update((toasts) => toasts.filter((toast) => toast.id != id))
|
toasts.update((toasts) => toasts.filter((toast) => toast.id != id))
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
export const debounce = (fn: Function, ms = 300) => {
|
export const debounce = (fn: Function, ms = 300) => {
|
||||||
let timeoutId: ReturnType<typeof setTimeout>
|
let timeoutId: ReturnType<typeof setTimeout>
|
||||||
return function (this: any, ...args: any[]) {
|
return function (this: any, ...args: any[]) {
|
||||||
clearTimeout(timeoutId)
|
clearTimeout(timeoutId)
|
||||||
timeoutId = setTimeout(() => fn.apply(this, args), ms)
|
timeoutId = setTimeout(() => fn.apply(this, args), ms)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -19,7 +19,7 @@ interface SessionStorage {
|
|||||||
|
|
||||||
export const setSessionStorage = (
|
export const setSessionStorage = (
|
||||||
key: keyof SessionStorage,
|
key: keyof SessionStorage,
|
||||||
value: SessionStorage[typeof key]
|
value: SessionStorage[typeof key],
|
||||||
) => {
|
) => {
|
||||||
if (!browser) return
|
if (!browser) return
|
||||||
if (value == undefined) {
|
if (value == undefined) {
|
||||||
@@ -30,7 +30,7 @@ export const setSessionStorage = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const getSessionStorage = (
|
export const getSessionStorage = (
|
||||||
key: keyof SessionStorage
|
key: keyof SessionStorage,
|
||||||
): SessionStorage[typeof key] => {
|
): SessionStorage[typeof key] => {
|
||||||
if (!browser) return
|
if (!browser) return
|
||||||
return JSON.parse(sessionStorage.getItem(key)!)
|
return JSON.parse(sessionStorage.getItem(key)!)
|
||||||
|
|||||||
+10
-16
@@ -187,8 +187,6 @@ export const defaultSettings: Settings = {
|
|||||||
logoColorMonth: null,
|
logoColorMonth: null,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function createSettingsState(initial: Settings): Settings {
|
function createSettingsState(initial: Settings): Settings {
|
||||||
let settings = $state(initial)
|
let settings = $state(initial)
|
||||||
if (browser) {
|
if (browser) {
|
||||||
@@ -197,9 +195,7 @@ function createSettingsState(initial: Settings): Settings {
|
|||||||
const merged = mergeDeep(initial, localSettings)
|
const merged = mergeDeep(initial, localSettings)
|
||||||
|
|
||||||
settings = merged
|
settings = merged
|
||||||
} catch (e) {
|
} catch (e) {}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return settings
|
return settings
|
||||||
}
|
}
|
||||||
@@ -208,7 +204,7 @@ export let settings = createSettingsState(defaultSettings)
|
|||||||
|
|
||||||
$effect.root(() => {
|
$effect.root(() => {
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
localStorage.setItem('settings', JSON.stringify(settings))
|
localStorage.setItem('settings', JSON.stringify(settings))
|
||||||
|
|
||||||
if (settings.language) {
|
if (settings.language) {
|
||||||
locale.set(settings.language)
|
locale.set(settings.language)
|
||||||
@@ -217,13 +213,11 @@ $effect.root(() => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return () => {
|
return () => {}
|
||||||
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
function isObject(item: any) {
|
function isObject(item: any) {
|
||||||
return (item && typeof item === 'object' && !Array.isArray(item));
|
return item && typeof item === 'object' && !Array.isArray(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -232,19 +226,19 @@ function isObject(item: any) {
|
|||||||
* @param ...sources
|
* @param ...sources
|
||||||
*/
|
*/
|
||||||
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()
|
||||||
|
|
||||||
if (isObject(target) && isObject(source)) {
|
if (isObject(target) && isObject(source)) {
|
||||||
for (const key in source) {
|
for (const key in source) {
|
||||||
if (isObject(source[key])) {
|
if (isObject(source[key])) {
|
||||||
if (!target[key]) Object.assign(target, { [key]: {} });
|
if (!target[key]) Object.assign(target, { [key]: {} })
|
||||||
mergeDeep(target[key], source[key]);
|
mergeDeep(target[key], source[key])
|
||||||
} else {
|
} else {
|
||||||
Object.assign(target, { [key]: source[key] });
|
Object.assign(target, { [key]: source[key] })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return mergeDeep(target, ...sources);
|
return mergeDeep(target, ...sources)
|
||||||
}
|
}
|
||||||
@@ -88,7 +88,7 @@ const config: Config = {
|
|||||||
loader: async () => (await import('./i18n/zh-Hant.json')).default,
|
loader: async () => (await import('./i18n/zh-Hant.json')).default,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
fallbackLocale: 'en'
|
fallbackLocale: 'en',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const aliases = new Map([
|
export const aliases = new Map([
|
||||||
@@ -111,6 +111,4 @@ export const aliases = new Map([
|
|||||||
['he-IL', 'he'],
|
['he-IL', 'he'],
|
||||||
])
|
])
|
||||||
|
|
||||||
export let { t, locale, locales, loading, loadTranslations } = new i18n(
|
export let { t, locale, locales, loading, loadTranslations } = new i18n(config)
|
||||||
config
|
|
||||||
)
|
|
||||||
@@ -84,8 +84,8 @@ function themeStore(
|
|||||||
fn: (
|
fn: (
|
||||||
values: ThemeData,
|
values: ThemeData,
|
||||||
set: (value: Theme) => void,
|
set: (value: Theme) => void,
|
||||||
update: (fn: Updater<Theme>) => void
|
update: (fn: Updater<Theme>) => void,
|
||||||
) => any
|
) => any,
|
||||||
) {
|
) {
|
||||||
const derive: Readable<Theme> = derived(data, fn)
|
const derive: Readable<Theme> = derived(data, fn)
|
||||||
const { subscribe } = derive
|
const { subscribe } = derive
|
||||||
@@ -107,7 +107,7 @@ export let themeData = writable<ThemeData>(
|
|||||||
scheme: 'system',
|
scheme: 'system',
|
||||||
themes: presets,
|
themes: presets,
|
||||||
currentTheme: 0,
|
currentTheme: 0,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
themeData.subscribe((themeData) => {
|
themeData.subscribe((themeData) => {
|
||||||
@@ -118,7 +118,7 @@ themeData.subscribe((themeData) => {
|
|||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
...themeData,
|
...themeData,
|
||||||
themes: filteredThemes,
|
themes: filteredThemes,
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -126,7 +126,7 @@ themeData.subscribe((themeData) => {
|
|||||||
export let theme = themeStore(
|
export let theme = themeStore(
|
||||||
themeData,
|
themeData,
|
||||||
(data) =>
|
(data) =>
|
||||||
data.themes.find((t) => t.id == data.currentTheme) ?? getDefaultTheme()
|
data.themes.find((t) => t.id == data.currentTheme) ?? getDefaultTheme(),
|
||||||
)
|
)
|
||||||
|
|
||||||
export function calculateVars(theme: Theme) {
|
export function calculateVars(theme: Theme) {
|
||||||
@@ -145,7 +145,7 @@ export const themeVars = derived(theme, (t) => calculateVars(t as Theme))
|
|||||||
|
|
||||||
const configuredColorScheme = env.PUBLIC_COLORSCHEME ?? 'system'
|
const configuredColorScheme = env.PUBLIC_COLORSCHEME ?? 'system'
|
||||||
export const colorScheme = writable<ColorScheme>(
|
export const colorScheme = writable<ColorScheme>(
|
||||||
configuredColorScheme as ColorScheme
|
configuredColorScheme as ColorScheme,
|
||||||
)
|
)
|
||||||
|
|
||||||
export const toggleColorScheme = () => {
|
export const toggleColorScheme = () => {
|
||||||
@@ -175,7 +175,7 @@ function loadColorScheme() {
|
|||||||
colorScheme.subscribe((colorScheme) => {
|
colorScheme.subscribe((colorScheme) => {
|
||||||
if (typeof document != 'undefined') {
|
if (typeof document != 'undefined') {
|
||||||
const prefersDark = window.matchMedia(
|
const prefersDark = window.matchMedia(
|
||||||
'(prefers-color-scheme: dark)'
|
'(prefers-color-scheme: dark)',
|
||||||
).matches
|
).matches
|
||||||
|
|
||||||
const html = document.querySelector('html')
|
const html = document.querySelector('html')
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ export let ssr = (env.PUBLIC_SSR_ENABLED?.toLowerCase() ?? 'false') == 'true'
|
|||||||
|
|
||||||
export const load = async ({}) => {
|
export const load = async ({}) => {
|
||||||
if (browser) {
|
if (browser) {
|
||||||
const initLocale =
|
const initLocale = settings.language ?? navigator?.language ?? 'en'
|
||||||
settings.language ?? navigator?.language ?? 'en'
|
|
||||||
|
|
||||||
console.log(`Loading locale ${aliases.get(initLocale) ?? initLocale}`)
|
console.log(`Loading locale ${aliases.get(initLocale) ?? initLocale}`)
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Badge } from 'mono-svelte'
|
import { Badge } from 'mono-svelte'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
name: string;
|
name: string
|
||||||
description: string;
|
description: string
|
||||||
badge?: string | undefined;
|
badge?: string | undefined
|
||||||
link?: string;
|
link?: string
|
||||||
class?: string;
|
class?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
@@ -16,9 +14,8 @@
|
|||||||
description,
|
description,
|
||||||
badge = undefined,
|
badge = undefined,
|
||||||
link = '#',
|
link = '#',
|
||||||
class: clazz = ''
|
class: clazz = '',
|
||||||
}: Props = $props();
|
}: Props = $props()
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-col w-max {clazz}">
|
<div class="flex flex-col w-max {clazz}">
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { redirect } from '@sveltejs/kit'
|
import { redirect } from '@sveltejs/kit'
|
||||||
|
|
||||||
export const load = () => {
|
export const load = () => {
|
||||||
redirect(302, '/admin/config');
|
redirect(302, '/admin/config')
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
let { data, children } = $props();
|
let { data, children } = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ export async function load({ params, fetch, url }) {
|
|||||||
const page = Number(url.searchParams.get('page')) || undefined
|
const page = Number(url.searchParams.get('page')) || undefined
|
||||||
|
|
||||||
const sort: SortType =
|
const sort: SortType =
|
||||||
(url.searchParams.get('sort') as SortType) ||
|
(url.searchParams.get('sort') as SortType) || settings.defaultSort.sort
|
||||||
settings.defaultSort.sort
|
|
||||||
|
|
||||||
return await postFeed({
|
return await postFeed({
|
||||||
id: 'community',
|
id: 'community',
|
||||||
|
|||||||
@@ -3,18 +3,15 @@
|
|||||||
import CommunityTitle from '$lib/components/lemmy/community/CommunityTitle.svelte'
|
import CommunityTitle from '$lib/components/lemmy/community/CommunityTitle.svelte'
|
||||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||||
|
|
||||||
let { data } = $props();
|
let { data } = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-col gap-4">
|
<div class="flex flex-col gap-4">
|
||||||
<Header pageHeader>
|
<Header pageHeader>
|
||||||
<span>Settings</span>
|
<span>Settings</span>
|
||||||
{#snippet extended()}
|
{#snippet extended()}
|
||||||
<CommunityTitle
|
<CommunityTitle community={data.community.community_view.community} />
|
||||||
|
{/snippet}
|
||||||
community={data.community.community_view.community}
|
|
||||||
/>
|
|
||||||
{/snippet}
|
|
||||||
</Header>
|
</Header>
|
||||||
<CommunityForm
|
<CommunityForm
|
||||||
edit={data.community.community_view.community.id}
|
edit={data.community.community_view.community.id}
|
||||||
@@ -32,7 +29,7 @@
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{#snippet formtitle()}
|
{#snippet formtitle()}
|
||||||
{''}
|
{''}
|
||||||
{/snippet}
|
{/snippet}
|
||||||
</CommunityForm>
|
</CommunityForm>
|
||||||
</div>
|
</div>
|
||||||
@@ -3,5 +3,5 @@ import { redirect } from '@sveltejs/kit'
|
|||||||
|
|
||||||
export function load({ params }) {
|
export function load({ params }) {
|
||||||
// If you somehow got to /comment/instance, it likely means you passed in an ID, not an instance.
|
// If you somehow got to /comment/instance, it likely means you passed in an ID, not an instance.
|
||||||
redirect(302, `/comment/${getInstance()}/${params.instance}`);
|
redirect(302, `/comment/${getInstance()}/${params.instance}`)
|
||||||
}
|
}
|
||||||
@@ -13,6 +13,6 @@ export async function load({ params, fetch }) {
|
|||||||
|
|
||||||
redirect(
|
redirect(
|
||||||
302,
|
302,
|
||||||
`/post/${params.instance}/${comment.comment_view.post.id}?thread=${comment.comment_view.comment.path}#${comment.comment_view.comment.id}`
|
`/post/${params.instance}/${comment.comment_view.post.id}?thread=${comment.comment_view.comment.path}#${comment.comment_view.comment.id}`,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -55,7 +55,7 @@ export async function load({ url, fetch }) {
|
|||||||
].sort(
|
].sort(
|
||||||
(a, b) =>
|
(a, b) =>
|
||||||
publishedToDate(b.published).getTime() -
|
publishedToDate(b.published).getTime() -
|
||||||
publishedToDate(a.published).getTime()
|
publishedToDate(a.published).getTime(),
|
||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { run, preventDefault } from 'svelte/legacy';
|
import { run, preventDefault } from 'svelte/legacy'
|
||||||
|
|
||||||
import { Button, Material, Spinner, TextInput, toast } from 'mono-svelte'
|
import { Button, Material, Spinner, TextInput, toast } from 'mono-svelte'
|
||||||
import Message from './Message.svelte'
|
import Message from './Message.svelte'
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
import { report } from '$lib/components/lemmy/moderation/moderation'
|
import { report } from '$lib/components/lemmy/moderation/moderation'
|
||||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
||||||
|
|
||||||
let { data = $bindable() } = $props();
|
let { data = $bindable() } = $props()
|
||||||
|
|
||||||
let textbox = $state({
|
let textbox = $state({
|
||||||
message: '',
|
message: '',
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
let chatWindow: HTMLDivElement = $state()
|
let chatWindow: HTMLDivElement = $state()
|
||||||
|
|
||||||
async function sendMessage(
|
async function sendMessage(
|
||||||
message: string
|
message: string,
|
||||||
): Promise<PrivateMessageResponse | undefined> {
|
): Promise<PrivateMessageResponse | undefined> {
|
||||||
if (message == '') return
|
if (message == '') return
|
||||||
|
|
||||||
@@ -55,10 +55,13 @@
|
|||||||
run(() => {
|
run(() => {
|
||||||
if (browser && data.message && chatWindow) {
|
if (browser && data.message && chatWindow) {
|
||||||
tick().then(() =>
|
tick().then(() =>
|
||||||
chatWindow.scrollTo({ top: chatWindow.scrollHeight, behavior: 'smooth' })
|
chatWindow.scrollTo({
|
||||||
|
top: chatWindow.scrollHeight,
|
||||||
|
behavior: 'smooth',
|
||||||
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
async function deleteMessage(id: number) {
|
async function deleteMessage(id: number) {
|
||||||
const res = await client().deletePrivateMessage({
|
const res = await client().deletePrivateMessage({
|
||||||
@@ -69,9 +72,9 @@
|
|||||||
data.message = {
|
data.message = {
|
||||||
private_messages: data.message.private_messages.toSpliced(
|
private_messages: data.message.private_messages.toSpliced(
|
||||||
data.message.private_messages.findLastIndex(
|
data.message.private_messages.findLastIndex(
|
||||||
(i) => i.private_message.id == id
|
(i) => i.private_message.id == id,
|
||||||
),
|
),
|
||||||
1
|
1,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,8 +154,8 @@
|
|||||||
disabled={textbox.loading}
|
disabled={textbox.loading}
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
<Icon src={PaperAirplane} size="18" micro />
|
<Icon src={PaperAirplane} size="18" micro />
|
||||||
{/snippet}
|
{/snippet}
|
||||||
</Button>
|
</Button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
import { Material, Popover } from 'mono-svelte'
|
import { Material, Popover } from 'mono-svelte'
|
||||||
import { Check, Icon, InformationCircle } from 'svelte-hero-icons'
|
import { Check, Icon, InformationCircle } from 'svelte-hero-icons'
|
||||||
|
|
||||||
let { data } = $props();
|
let { data } = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Header pageHeader>Linked Instances</Header>
|
<Header pageHeader>Linked Instances</Header>
|
||||||
@@ -18,8 +18,8 @@
|
|||||||
Linked
|
Linked
|
||||||
<Popover openOnHover>
|
<Popover openOnHover>
|
||||||
{#snippet target()}
|
{#snippet target()}
|
||||||
<Icon src={InformationCircle} mini size="20" />
|
<Icon src={InformationCircle} mini size="20" />
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<p class="font-normal">
|
<p class="font-normal">
|
||||||
These are the instances your instance can see and interact with
|
These are the instances your instance can see and interact with
|
||||||
content from.
|
content from.
|
||||||
@@ -60,8 +60,8 @@
|
|||||||
|
|
||||||
<Popover openOnHover placement="bottom">
|
<Popover openOnHover placement="bottom">
|
||||||
{#snippet target()}
|
{#snippet target()}
|
||||||
<Icon src={InformationCircle} mini size="20" />
|
<Icon src={InformationCircle} mini size="20" />
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<p class="font-normal">
|
<p class="font-normal">
|
||||||
These are the instances your instance is explicitly blocking content
|
These are the instances your instance is explicitly blocking content
|
||||||
from.
|
from.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { preventDefault } from 'svelte/legacy';
|
import { preventDefault } from 'svelte/legacy'
|
||||||
|
|
||||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export async function load({ url, fetch }) {
|
|||||||
...posts.post_reports.map(generalizePostReport),
|
...posts.post_reports.map(generalizePostReport),
|
||||||
...comments.comment_reports.map(generalizeCommentReport),
|
...comments.comment_reports.map(generalizeCommentReport),
|
||||||
...(messages?.private_message_reports ?? []).map(
|
...(messages?.private_message_reports ?? []).map(
|
||||||
generalizePrivateMessageReport
|
generalizePrivateMessageReport,
|
||||||
),
|
),
|
||||||
].sort((a, b) => b.timestamp.getTime() - a.timestamp.getTime())
|
].sort((a, b) => b.timestamp.getTime() - a.timestamp.getTime())
|
||||||
|
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ export async function load({ url }) {
|
|||||||
filters: {
|
filters: {
|
||||||
user: user ? moderationActions[0]?.moderatee?.name : undefined,
|
user: user ? moderationActions[0]?.moderatee?.name : undefined,
|
||||||
community: community ? moderationActions[0]?.community?.title : undefined,
|
community: community ? moderationActions[0]?.community?.title : undefined,
|
||||||
moderator: modId ? moderationActions[0]?.moderator?.name : undefined
|
moderator: modId ? moderationActions[0]?.moderator?.name : undefined,
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17,14 +17,13 @@
|
|||||||
import type { ActionName } from './+page.js'
|
import type { ActionName } from './+page.js'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
action: ActionName;
|
action: ActionName
|
||||||
}
|
}
|
||||||
|
|
||||||
let { action }: Props = $props();
|
let { action }: Props = $props()
|
||||||
|
|
||||||
|
|
||||||
const getAction = (
|
const getAction = (
|
||||||
action: ActionName
|
action: ActionName,
|
||||||
): { icon: IconSource; text: string; class: string } => {
|
): { icon: IconSource; text: string; class: string } => {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case 'ban': {
|
case 'ban': {
|
||||||
|
|||||||
@@ -10,10 +10,10 @@
|
|||||||
import ModlogAction from '../ModlogAction.svelte'
|
import ModlogAction from '../ModlogAction.svelte'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
item: ModLog;
|
item: ModLog
|
||||||
}
|
}
|
||||||
|
|
||||||
let { item }: Props = $props();
|
let { item }: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Material padding="lg" class="flex flex-col gap-2">
|
<Material padding="lg" class="flex flex-col gap-2">
|
||||||
|
|||||||
@@ -7,10 +7,10 @@
|
|||||||
import ModlogAction from '../ModlogAction.svelte'
|
import ModlogAction from '../ModlogAction.svelte'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
item: ModLog;
|
item: ModLog
|
||||||
}
|
}
|
||||||
|
|
||||||
let { item }: Props = $props();
|
let { item }: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<tr class="">
|
<tr class="">
|
||||||
@@ -28,7 +28,8 @@
|
|||||||
user={item.moderator}
|
user={item.moderator}
|
||||||
/>
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
<p class="text-slate-500 dark:text-zinc-500">Hidden<p></p>
|
<p class="text-slate-500 dark:text-zinc-500">Hidden</p>
|
||||||
|
<p></p>
|
||||||
{/if}
|
{/if}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { preventDefault } from 'svelte/legacy';
|
import { preventDefault } from 'svelte/legacy'
|
||||||
|
|
||||||
import { goto } from '$app/navigation'
|
import { goto } from '$app/navigation'
|
||||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||||
@@ -14,11 +14,11 @@
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
data: {
|
data: {
|
||||||
token: string
|
token: string
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let { data }: Props = $props();
|
let { data }: Props = $props()
|
||||||
|
|
||||||
let instance = $state(LINKED_INSTANCE_URL || $currentInstance || '')
|
let instance = $state(LINKED_INSTANCE_URL || $currentInstance || '')
|
||||||
let password = $state(''),
|
let password = $state(''),
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ export function load({ params, url }) {
|
|||||||
const newUrl = new URL(url)
|
const newUrl = new URL(url)
|
||||||
newUrl.pathname = split.join('/')
|
newUrl.pathname = split.join('/')
|
||||||
|
|
||||||
redirect(302, newUrl.toString());
|
redirect(302, newUrl.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
error(404, 'Not found');
|
error(404, 'Not found')
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
<script>
|
<script>
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} Props
|
* @typedef {Object} Props
|
||||||
* @property {import('svelte').Snippet} [children]
|
* @property {import('svelte').Snippet} [children]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @type {Props} */
|
/** @type {Props} */
|
||||||
let { children } = $props();
|
let { children } = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/** @type {Props} */
|
/** @type {Props} */
|
||||||
let { children } = $props();
|
let { children } = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
UserGroup,
|
UserGroup,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
|
|
||||||
let { data } = $props();
|
let { data } = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import UserPage from '../../u/[name]/+page.svelte'
|
import UserPage from '../../u/[name]/+page.svelte'
|
||||||
let { data } = $props();
|
let { data } = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if data.user && data.sort && data.type && data.page}
|
{#if data.user && data.sort && data.type && data.page}
|
||||||
|
|||||||
@@ -26,12 +26,12 @@ export async function load({ url, fetch, parent }) {
|
|||||||
(a, b) =>
|
(a, b) =>
|
||||||
b.counts.upvotes -
|
b.counts.upvotes -
|
||||||
b.counts.downvotes -
|
b.counts.downvotes -
|
||||||
(a.counts.upvotes - a.counts.downvotes)
|
(a.counts.upvotes - a.counts.downvotes),
|
||||||
)
|
)
|
||||||
} else if (sort == 'New') {
|
} else if (sort == 'New') {
|
||||||
items.sort(
|
items.sort(
|
||||||
(a, b) =>
|
(a, b) =>
|
||||||
Date.parse(getItemPublished(b)) - Date.parse(getItemPublished(a))
|
Date.parse(getItemPublished(b)) - Date.parse(getItemPublished(a)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
|
|
||||||
let { data = $bindable() } = $props();
|
let { data = $bindable() } = $props()
|
||||||
|
|
||||||
const SvelteComponent = $derived(browser ? VirtualFeed : PostFeed);
|
const SvelteComponent = $derived(browser ? VirtualFeed : PostFeed)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Header>
|
<Header>
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ export async function load({ url, fetch }) {
|
|||||||
const everything = [...posts.posts, ...comments.comments].sort(
|
const everything = [...posts.posts, ...comments.comments].sort(
|
||||||
(a, b) =>
|
(a, b) =>
|
||||||
Date.parse(getSavedItemPublished(b)) -
|
Date.parse(getSavedItemPublished(b)) -
|
||||||
Date.parse(getSavedItemPublished(a))
|
Date.parse(getSavedItemPublished(a)),
|
||||||
)
|
)
|
||||||
|
|
||||||
return { page: page, data: everything, type: type }
|
return { page: page, data: everything, type: type }
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ export async function load({ url, fetch }) {
|
|||||||
everything.sort(
|
everything.sort(
|
||||||
(a, b) =>
|
(a, b) =>
|
||||||
new Date(getItemPublished(b)).getTime() -
|
new Date(getItemPublished(b)).getTime() -
|
||||||
new Date(getItemPublished(a)).getTime()
|
new Date(getItemPublished(a)).getTime(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,20 +4,14 @@
|
|||||||
import { backOut, expoOut } from 'svelte/easing'
|
import { backOut, expoOut } from 'svelte/easing'
|
||||||
import { slide } from 'svelte/transition'
|
import { slide } from 'svelte/transition'
|
||||||
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
title: string;
|
title: string
|
||||||
id: string;
|
id: string
|
||||||
open?: boolean;
|
open?: boolean
|
||||||
children?: import('svelte').Snippet;
|
children?: import('svelte').Snippet
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let { title, id, open = $bindable(true), children }: Props = $props()
|
||||||
title,
|
|
||||||
id,
|
|
||||||
open = $bindable(true),
|
|
||||||
children
|
|
||||||
}: Props = $props();
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-col max-w-full w-full">
|
<div class="flex flex-col max-w-full w-full">
|
||||||
|
|||||||
@@ -8,33 +8,31 @@
|
|||||||
Icon,
|
Icon,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
supportedPlatforms?: any;
|
supportedPlatforms?: any
|
||||||
mainClass?: string;
|
mainClass?: string
|
||||||
itemsClass?: string;
|
itemsClass?: string
|
||||||
optionClass?: string;
|
optionClass?: string
|
||||||
class?: string;
|
class?: string
|
||||||
title?: import('svelte').Snippet;
|
title?: import('svelte').Snippet
|
||||||
description?: import('svelte').Snippet;
|
description?: import('svelte').Snippet
|
||||||
children?: import('svelte').Snippet;
|
children?: import('svelte').Snippet
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
supportedPlatforms = {
|
supportedPlatforms = {
|
||||||
desktop: true,
|
desktop: true,
|
||||||
tablet: true,
|
tablet: true,
|
||||||
mobile: true,
|
mobile: true,
|
||||||
},
|
},
|
||||||
mainClass = '',
|
mainClass = '',
|
||||||
itemsClass = '',
|
itemsClass = '',
|
||||||
optionClass = '',
|
optionClass = '',
|
||||||
class: clazz = '',
|
class: clazz = '',
|
||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
children
|
children,
|
||||||
}: Props = $props();
|
}: Props = $props()
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@@ -45,24 +43,24 @@
|
|||||||
{#if supportedPlatforms.desktop}
|
{#if supportedPlatforms.desktop}
|
||||||
<Badge>
|
<Badge>
|
||||||
{#snippet icon()}
|
{#snippet icon()}
|
||||||
<Icon src={ComputerDesktop} micro size="14" />
|
<Icon src={ComputerDesktop} micro size="14" />
|
||||||
{/snippet}
|
{/snippet}
|
||||||
{$t('settings.desktop')}
|
{$t('settings.desktop')}
|
||||||
</Badge>
|
</Badge>
|
||||||
{/if}
|
{/if}
|
||||||
{#if supportedPlatforms.tablet}
|
{#if supportedPlatforms.tablet}
|
||||||
<Badge>
|
<Badge>
|
||||||
{#snippet icon()}
|
{#snippet icon()}
|
||||||
<Icon src={DeviceTablet} micro size="14" />
|
<Icon src={DeviceTablet} micro size="14" />
|
||||||
{/snippet}
|
{/snippet}
|
||||||
{$t('settings.tablet')}
|
{$t('settings.tablet')}
|
||||||
</Badge>
|
</Badge>
|
||||||
{/if}
|
{/if}
|
||||||
{#if supportedPlatforms.mobile}
|
{#if supportedPlatforms.mobile}
|
||||||
<Badge>
|
<Badge>
|
||||||
{#snippet icon()}
|
{#snippet icon()}
|
||||||
<Icon src={DevicePhoneMobile} micro size="14" />
|
<Icon src={DevicePhoneMobile} micro size="14" />
|
||||||
{/snippet}
|
{/snippet}
|
||||||
{$t('settings.mobile')}
|
{$t('settings.mobile')}
|
||||||
</Badge>
|
</Badge>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -9,13 +9,12 @@
|
|||||||
Icon,
|
Icon,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
title: string;
|
title: string
|
||||||
description?: string | undefined;
|
description?: string | undefined
|
||||||
checked?: boolean;
|
checked?: boolean
|
||||||
beta?: boolean;
|
beta?: boolean
|
||||||
supportedPlatforms?: any;
|
supportedPlatforms?: any
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
@@ -24,11 +23,11 @@
|
|||||||
checked = $bindable(false),
|
checked = $bindable(false),
|
||||||
beta = false,
|
beta = false,
|
||||||
supportedPlatforms = {
|
supportedPlatforms = {
|
||||||
desktop: true,
|
desktop: true,
|
||||||
tablet: true,
|
tablet: true,
|
||||||
mobile: true,
|
mobile: true,
|
||||||
}
|
},
|
||||||
}: Props = $props();
|
}: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-col w-full justify-between gap-2 max-w-full">
|
<div class="flex flex-col w-full justify-between gap-2 max-w-full">
|
||||||
@@ -41,24 +40,24 @@
|
|||||||
{#if supportedPlatforms.desktop}
|
{#if supportedPlatforms.desktop}
|
||||||
<Badge>
|
<Badge>
|
||||||
{#snippet icon()}
|
{#snippet icon()}
|
||||||
<Icon src={ComputerDesktop} micro size="14" />
|
<Icon src={ComputerDesktop} micro size="14" />
|
||||||
{/snippet}
|
{/snippet}
|
||||||
{$t('settings.desktop')}
|
{$t('settings.desktop')}
|
||||||
</Badge>
|
</Badge>
|
||||||
{/if}
|
{/if}
|
||||||
{#if supportedPlatforms.tablet}
|
{#if supportedPlatforms.tablet}
|
||||||
<Badge>
|
<Badge>
|
||||||
{#snippet icon()}
|
{#snippet icon()}
|
||||||
<Icon src={DeviceTablet} micro size="14" />
|
<Icon src={DeviceTablet} micro size="14" />
|
||||||
{/snippet}
|
{/snippet}
|
||||||
{$t('settings.tablet')}
|
{$t('settings.tablet')}
|
||||||
</Badge>
|
</Badge>
|
||||||
{/if}
|
{/if}
|
||||||
{#if supportedPlatforms.mobile}
|
{#if supportedPlatforms.mobile}
|
||||||
<Badge>
|
<Badge>
|
||||||
{#snippet icon()}
|
{#snippet icon()}
|
||||||
<Icon src={DevicePhoneMobile} micro size="14" />
|
<Icon src={DevicePhoneMobile} micro size="14" />
|
||||||
{/snippet}
|
{/snippet}
|
||||||
{$t('settings.mobile')}
|
{$t('settings.mobile')}
|
||||||
</Badge>
|
</Badge>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -2,18 +2,13 @@
|
|||||||
import { Material, Popover } from 'mono-svelte'
|
import { Material, Popover } from 'mono-svelte'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
href: string;
|
href: string
|
||||||
size?: keyof typeof sizes;
|
size?: keyof typeof sizes
|
||||||
title?: string;
|
title?: string
|
||||||
children?: import('svelte').Snippet;
|
children?: import('svelte').Snippet
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let { href, size = 'medium', title = '', children }: Props = $props()
|
||||||
href,
|
|
||||||
size = 'medium',
|
|
||||||
title = '',
|
|
||||||
children
|
|
||||||
}: Props = $props();
|
|
||||||
|
|
||||||
const sizes = {
|
const sizes = {
|
||||||
large: 'h-24',
|
large: 'h-24',
|
||||||
@@ -24,13 +19,12 @@
|
|||||||
|
|
||||||
<Popover openOnHover placement="right">
|
<Popover openOnHover placement="right">
|
||||||
{#snippet target()}
|
{#snippet target()}
|
||||||
<a {href} >
|
<a {href}>
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
</a>
|
</a>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
{#snippet popover()}
|
{#snippet popover()}
|
||||||
<Material
|
<Material
|
||||||
|
|
||||||
padding="none"
|
padding="none"
|
||||||
rounding="xl"
|
rounding="xl"
|
||||||
elevation="medium"
|
elevation="medium"
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { preventDefault } from 'svelte/legacy';
|
import { preventDefault } from 'svelte/legacy'
|
||||||
|
|
||||||
import { goto } from '$app/navigation'
|
import { goto } from '$app/navigation'
|
||||||
import { Badge, Material, Spinner, toast } from 'mono-svelte'
|
import { Badge, Material, Spinner, toast } from 'mono-svelte'
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
try {
|
try {
|
||||||
const res: Instance[] = (
|
const res: Instance[] = (
|
||||||
await fetch(`https://data.lemmyverse.net/data/instance.full.json`).then(
|
await fetch(`https://data.lemmyverse.net/data/instance.full.json`).then(
|
||||||
(r) => r.json()
|
(r) => r.json(),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.filter((i: Instance) => i.fed)
|
.filter((i: Instance) => i.fed)
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { LINKED_INSTANCE_URL } from "$lib/instance.js";
|
import { LINKED_INSTANCE_URL } from '$lib/instance.js'
|
||||||
import { redirect } from "@sveltejs/kit";
|
import { redirect } from '@sveltejs/kit'
|
||||||
|
|
||||||
export const load = () => {
|
export const load = () => {
|
||||||
if (LINKED_INSTANCE_URL) {
|
if (LINKED_INSTANCE_URL) {
|
||||||
redirect(302, `/signup/${LINKED_INSTANCE_URL}`);
|
redirect(302, `/signup/${LINKED_INSTANCE_URL}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,12 +24,12 @@ export async function load({ params, url, fetch }) {
|
|||||||
(a, b) =>
|
(a, b) =>
|
||||||
b.counts.upvotes -
|
b.counts.upvotes -
|
||||||
b.counts.downvotes -
|
b.counts.downvotes -
|
||||||
(a.counts.upvotes - a.counts.downvotes)
|
(a.counts.upvotes - a.counts.downvotes),
|
||||||
)
|
)
|
||||||
} else if (sort == 'New') {
|
} else if (sort == 'New') {
|
||||||
items.sort(
|
items.sort(
|
||||||
(a, b) =>
|
(a, b) =>
|
||||||
Date.parse(getItemPublished(b)) - Date.parse(getItemPublished(a))
|
Date.parse(getItemPublished(b)) - Date.parse(getItemPublished(a)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { run } from 'svelte/legacy';
|
import { run } from 'svelte/legacy'
|
||||||
|
|
||||||
import { photonify } from '$lib/components/markdown/renderers/plugins'
|
import { photonify } from '$lib/components/markdown/renderers/plugins'
|
||||||
import { TextInput } from 'mono-svelte'
|
import { TextInput } from 'mono-svelte'
|
||||||
|
|
||||||
let link = $state('')
|
let link = $state('')
|
||||||
|
|
||||||
let photonified;
|
let photonified
|
||||||
run(() => {
|
run(() => {
|
||||||
photonified = photonify(link)
|
photonified = photonify(link)
|
||||||
});
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<h1 class="font-bold text-2xl">Photonify links</h1>
|
<h1 class="font-bold text-2xl">Photonify links</h1>
|
||||||
|
|||||||
Reference in new issue
Block a user