format: whole project

This commit is contained in:
James Xylight committed 2025-02-04 16:23:31 -08:00
1 parent b883b5f6e0
commit 80269cf275
79 files changed
+590 -612

No files matched your search

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