diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index e7d7e4ac..60004132 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -4,7 +4,6 @@ about: Create a report to help us improve title: '' labels: bug assignees: '' - --- **Describe the bug** @@ -12,6 +11,7 @@ A clear and concise description of what the bug is. **To Reproduce** (if applicable) Steps to reproduce the behavior: + 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' @@ -24,6 +24,7 @@ A clear and concise description of what you expected to happen. If applicable, add screenshots to help explain your problem. **Versions** + - Browser: Firefox - Photon version: 0.5.1 - check in the bottom of the main menu. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index bbcbbe7d..2f28cead 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -4,7 +4,6 @@ about: Suggest an idea for this project title: '' labels: '' assignees: '' - --- **Is your feature request related to a problem? Please describe.** diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..f83848a8 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,10 @@ +{ + "arrowParens": "always", + "tabWidth": 2, + "semi": false, + "singleQuote": true, + "htmlWhitespaceSensitivity": "ignore", + + "plugins": ["prettier-plugin-svelte"], + "overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }] +} diff --git a/.vscode/settings.json b/.vscode/settings.json index cbe8ae72..0645a6c7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,5 @@ { "i18n-ally.localesPaths": ["src/lib/i18n"], - "i18n-ally.keystyle": "nested" + "i18n-ally.keystyle": "nested", + "prettier.prettierPath": "prettier" } diff --git a/package.json b/package.json index e341dccc..a2c502f7 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,8 @@ "@sveltejs/adapter-auto": "^3.2.1", "@sveltejs/adapter-node": "^2.0.0", "@sveltejs/adapter-vercel": "^5.1.0", - "@sveltejs/kit": "^2.5.20", - "@sveltejs/vite-plugin-svelte": "^3.0.0", + "@sveltejs/kit": "^2.5.27", + "@sveltejs/vite-plugin-svelte": "^4.0.0", "@tailwindcss/container-queries": "^0.1.1", "@tanstack/svelte-virtual": "^3.8.1", "@types/nprogress": "^0.2.0", @@ -22,9 +22,11 @@ "marked-linkify-it": "^3.1.10", "nprogress": "^0.2.0", "postcss": "^8.4.30", + "prettier": "^3.3.3", + "prettier-plugin-svelte": "^3.2.7", "rollup-plugin-visualizer": "^5.9.2", - "svelte": "^4.2.18", - "svelte-check": "^3.0.1", + "svelte": "^5.0.0", + "svelte-check": "^4.0.0", "svelte-floating-ui": "^1.5.9", "svelte-focus-trap": "^1.2.0", "svelte-hero-icons": "^5.2.0", @@ -33,9 +35,9 @@ "sveltekit-i18n": "^2.4.2", "tailwindcss": "^3.3.3", "tslib": "^2.4.1", - "typescript": "^5.0.0", + "typescript": "^5.5.0", "ua-parser-js": "^1.0.38", - "vite": "^5.0.0", + "vite": "^5.4.4", "vitest": "^1.0.0" }, "private": true, @@ -47,7 +49,9 @@ "start": "node build/index.js", "bunstart": "bun build/index.js", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", - "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch" + "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", + "format": "prettier --write .", + "format:specific": "prettier --write" }, "type": "module", "dependencies": { diff --git a/src/app.html b/src/app.html index f5ebd676..aa982970 100644 --- a/src/app.html +++ b/src/app.html @@ -1,4 +1,4 @@ - + diff --git a/src/lib/auth.ts b/src/lib/auth.ts index 454e33ec..7f26bf6b 100644 --- a/src/lib/auth.ts +++ b/src/lib/auth.ts @@ -94,7 +94,7 @@ export let profileData = writable( }, ], profile: 1, - } + }, ) let fetchUser = { @@ -107,8 +107,8 @@ function profileStore( fn: ( values: ProfileData, set: (value: Profile) => void, - update: (fn: Updater) => void - ) => any + update: (fn: Updater) => void, + ) => any, ) { const derive: Readable = derived(data, fn) const { subscribe } = derive @@ -226,7 +226,7 @@ if ( const result = await setUser( jwt, env.PUBLIC_INSTANCE_URL ?? '', - user?.user?.local_user_view.person.name + user?.user?.local_user_view.person.name, ) if (result) @@ -283,7 +283,7 @@ export async function setUser(jwt: string, inst: string, username?: string) { async function userFromJwt( jwt: string, - instance: string + instance: string, ): Promise< { user: PersonData | undefined; site: GetSiteResponse } | undefined > { @@ -296,7 +296,7 @@ async function userFromJwt( type: 'warning', loading: true, }), - 5000 + 5000, ) const site = await sitePromise @@ -414,7 +414,7 @@ async function checkInbox() { const notifs = await getNotificationCount( jwt, amModOfAny(user) ?? false, - user ? isAdmin(user) : false + user ? isAdmin(user) : false, ) notifications.set({ diff --git a/src/lib/components/error/ErrorContainer.svelte b/src/lib/components/error/ErrorContainer.svelte index 938b233d..b81e5a9a 100644 --- a/src/lib/components/error/ErrorContainer.svelte +++ b/src/lib/components/error/ErrorContainer.svelte @@ -1,4 +1,4 @@ - {#if scopedErrors.length > 0} diff --git a/src/lib/components/helper/Empty.svelte b/src/lib/components/helper/Empty.svelte index c06d5a9c..2514dc6a 100644 --- a/src/lib/components/helper/Empty.svelte +++ b/src/lib/components/helper/Empty.svelte @@ -1 +1,11 @@ - + + +{@render children?.({ ...rest })} diff --git a/src/lib/components/input/FreeTextInput.svelte b/src/lib/components/input/FreeTextInput.svelte index 6313d6b5..301b26d1 100644 --- a/src/lib/components/input/FreeTextInput.svelte +++ b/src/lib/components/input/FreeTextInput.svelte @@ -1,14 +1,11 @@ diff --git a/src/lib/components/input/ImagePreviewInput.svelte b/src/lib/components/input/ImagePreviewInput.svelte index 8a4b9180..50b982b0 100644 --- a/src/lib/components/input/ImagePreviewInput.svelte +++ b/src/lib/components/input/ImagePreviewInput.svelte @@ -13,9 +13,7 @@
- +
{/if} - + {#snippet customIcon()} + + {/snippet}
{/if} diff --git a/src/lib/components/lemmy/comment/CommentActions.svelte b/src/lib/components/lemmy/comment/CommentActions.svelte index f43d5fb2..4dee6295 100644 --- a/src/lib/components/lemmy/comment/CommentActions.svelte +++ b/src/lib/components/lemmy/comment/CommentActions.svelte @@ -30,14 +30,22 @@ import { text } from '$lib/components/translate/translation' import { userSettings } from '$lib/settings' - export let comment: CommentView - export let replying: boolean = false - export let disabled = false + interface Props { + comment: CommentView + replying?: boolean + disabled?: boolean + } + + let { + comment = $bindable(), + replying = $bindable(false), + disabled = false, + }: Props = $props() const dispatcher = createEventDispatcher<{ edit: CommentView }>() let reply = '' - let translating = false + let translating = $state(false) {#if translating} @@ -69,22 +77,19 @@ {/if} - + {#snippet target()} + + {/snippet} {$t('comment.actions.label')} { @@ -104,7 +109,9 @@ translating = !translating }} > - + {#snippet prefix()} + + {/snippet} {$t('post.actions.more.translate')} {/if} @@ -134,7 +141,7 @@ comment.comment.deleted = await deleteItem( comment, !comment.comment.deleted, - $profile.jwt + $profile.jwt, ) }} > @@ -154,5 +161,5 @@ {/if} {/if} -
+
diff --git a/src/lib/components/lemmy/comment/CommentForm.svelte b/src/lib/components/lemmy/comment/CommentForm.svelte index e0a24160..30b80d47 100644 --- a/src/lib/components/lemmy/comment/CommentForm.svelte +++ b/src/lib/components/lemmy/comment/CommentForm.svelte @@ -12,26 +12,39 @@ import { errorMessage } from '$lib/lemmy/error' import { Icon, XMark } from 'svelte-hero-icons' - export let postId: number - export let parentId: number | undefined = undefined - export let locked: boolean = false - export let banned: boolean = false - export let rows: number = 7 - export let placeholder: string | undefined = undefined - const dispatch = createEventDispatcher<{ comment: CommentResponse confirm: string cancel: boolean }>() - export let value = '' - export let actions = true + interface Props { + postId: number + parentId?: number | undefined + locked?: boolean + banned?: boolean + rows?: number + placeholder?: string | undefined + value?: string + actions?: boolean + preview?: boolean + [key: string]: any + } - let previewAction = true - export { previewAction as preview } + let { + postId, + parentId = undefined, + locked = false, + banned = false, + rows = 7, + placeholder = undefined, + value = $bindable(''), + actions = true, + preview: previewAction = true, + ...rest + }: Props = $props() - let loading = false + let loading = $state(false) let preview = false async function submit() { @@ -70,7 +83,7 @@ {:else} -
+
{#if actions}
diff --git a/src/lib/components/lemmy/comment/CommentListVirtualizer.svelte b/src/lib/components/lemmy/comment/CommentListVirtualizer.svelte index 17ab52ea..53279853 100644 --- a/src/lib/components/lemmy/comment/CommentListVirtualizer.svelte +++ b/src/lib/components/lemmy/comment/CommentListVirtualizer.svelte @@ -1,4 +1,6 @@ @@ -149,34 +155,39 @@ name={community_view.community.title} label="!{fullCommunityName( community_view.community.name, - community_view.community.actor_id + community_view.community.actor_id, )}" > - + {#snippet customIcon()} + + {/snippet}

- - - {$t('cards.site.about')} - + {#snippet title()} + + + {$t('cards.site.about')} + + {/snippet}
- - - {$t('cards.site.stats')} - + {#snippet title()} + + + {$t('cards.site.stats')} + + {/snippet}
0}
- - - {$t('cards.community.moderators')} - + {#snippet title()} + + + {$t('cards.community.moderators')} + + {/snippet} ({ id: m.moderator.id, @@ -224,12 +237,13 @@ on:click={subscribe} class="flex-1 relative z-[inherit]" > - + {#snippet prefix()} + + {/snippet} {community_view.subscribed == 'Subscribed' || community_view.subscribed == 'Pending' ? $t('cards.community.subscribed') @@ -240,17 +254,23 @@ {/if}
- + {#snippet target()} + + {/snippet} {$t('cards.community.modlog')} @@ -262,7 +282,9 @@ on:click={() => block(community_view.community.id, !community_view.blocked)} > - + {#snippet prefix()} + + {/snippet} {community_view.blocked ? $t('cards.community.unblock') : $t('cards.community.block')} @@ -273,7 +295,9 @@ size="lg" on:click={() => blockInstance(community_view.community.instance_id)} > - + {#snippet prefix()} + + {/snippet} {$t('cards.community.blockInstance')} {/if} @@ -301,7 +325,9 @@ type: 'error', })} > - + {#snippet prefix()} + + {/snippet} {$t('admin.purge')} {/if} diff --git a/src/lib/components/lemmy/community/CommunityForm.svelte b/src/lib/components/lemmy/community/CommunityForm.svelte index 8c3ce656..701ba541 100644 --- a/src/lib/components/lemmy/community/CommunityForm.svelte +++ b/src/lib/components/lemmy/community/CommunityForm.svelte @@ -1,4 +1,6 @@ - + {#if formtitle}{@render formtitle()}{:else}
{$t('routes.createCommunity')}
-
+ {/if} {$t('routes.admin.config.icon')} + {#snippet nameDetail()} + + {/snippet} {#if moderators.length > 0} - + {#snippet title()} {$t('cards.community.moderators')} - + {/snippet} ({ id: m.moderator.id, @@ -114,30 +125,32 @@ dark:border-zinc-800 border-slate-300 border-opacity-50 text-slate-700 dark:text counts: counts ?? {}, subscribed: subscribed, }} - let:subscribe - let:subscribing > - + {#snippet children({ subscribe, subscribing })} + + {/snippet} {/if} @@ -150,7 +163,7 @@ dark:border-zinc-800 border-slate-300 border-opacity-50 text-slate-700 dark:text rounding="xl" href="/c/{fullCommunityName( community.name, - community.actor_id + community.actor_id, )}/settings" style="height: 38px; width: 38px;" > @@ -158,14 +171,13 @@ dark:border-zinc-800 border-slate-300 border-opacity-50 text-slate-700 dark:text {/if}
- + {#snippet target()} + + {/snippet} {$t('cards.community.modlog')} @@ -176,7 +188,9 @@ dark:border-zinc-800 border-slate-300 border-opacity-50 text-slate-700 dark:text size="lg" on:click={() => block(community.id, !blocked)} > - + {#snippet prefix()} + + {/snippet} {blocked ? $t('cards.community.unblock') : $t('cards.community.block')} @@ -187,7 +201,9 @@ dark:border-zinc-800 border-slate-300 border-opacity-50 text-slate-700 dark:text size="lg" on:click={() => blockInstance(community.instance_id)} > - + {#snippet prefix()} + + {/snippet} {$t('cards.community.blockInstance')} {/if} @@ -215,7 +231,9 @@ dark:border-zinc-800 border-slate-300 border-opacity-50 text-slate-700 dark:text type: 'error', })} > - + {#snippet prefix()} + + {/snippet} {$t('admin.purge')} {/if} diff --git a/src/lib/components/lemmy/community/CommunityItem.svelte b/src/lib/components/lemmy/community/CommunityItem.svelte index bff71559..2fe66798 100644 --- a/src/lib/components/lemmy/community/CommunityItem.svelte +++ b/src/lib/components/lemmy/community/CommunityItem.svelte @@ -23,13 +23,22 @@ import { t } from '$lib/translations' import Entity from '$lib/components/ui/Entity.svelte' - export let community: CommunityView - export let view: 'cozy' | 'compact' = 'compact' - export let showCounts: boolean = true + let showInfo = $state(false) + interface Props { + community: CommunityView + view?: 'cozy' | 'compact' + showCounts?: boolean + class?: string + icon?: import('svelte').Snippet + } - let showInfo = false - let clazz: string = 'py-4 flex flex-col gap-4 text-sm max-w-full relative' - export { clazz as class } + let { + community = $bindable(), + view = 'compact', + showCounts = true, + class: clazz = 'py-4 flex flex-col gap-4 text-sm max-w-full relative', + icon, + }: Props = $props() {#if showInfo} @@ -48,7 +57,7 @@ - + {#if icon}{@render icon()}{:else} - + {/if}
@@ -92,50 +101,55 @@ - - + community.subscribed = newSubscribed + addSubscription( + community.community, + newSubscribed == 'Subscribed', + ) + } + }} + size="custom" + title={isSubscribed(community.subscribed) + ? $t('cards.community.subscribed') + : $t('cards.community.subscribe')} + color={isSubscribed(community.subscribed) + ? 'elevatedLow' + : 'primary'} + class="{isSubscribed(community.subscribed) + ? 'text-slate-600 dark:text-zinc-400' + : ''} + aspect-square h-8 @md:px-2 @md:min-w-32 @md:aspect-auto" + > + {#snippet prefix()} + + {/snippet} + + + {/snippet}
diff --git a/src/lib/components/lemmy/community/CommunityLink.svelte b/src/lib/components/lemmy/community/CommunityLink.svelte index b94e31b8..64e785bd 100644 --- a/src/lib/components/lemmy/community/CommunityLink.svelte +++ b/src/lib/components/lemmy/community/CommunityLink.svelte @@ -5,25 +5,37 @@ import type { Community } from 'lemmy-js-client' import { ExclamationTriangle, Icon } from 'svelte-hero-icons' - export let community: Community - - export let avatar: boolean = false - export let name: boolean = true - export let avatarSize: number = 24 - export let showInstance: boolean = $userSettings.showInstances.community - export let displayName: boolean = true - - export let badges = { - nsfw: false, + interface Props { + community: Community + avatar?: boolean + name?: boolean + avatarSize?: number + showInstance?: boolean + displayName?: boolean + badges?: any + class?: string + instanceClass?: string + [key: string]: any } - let clazz: string = '' - export let instanceClass: string = '' - export { clazz as class } + let { + community, + avatar = false, + name = true, + avatarSize = 24, + showInstance = $userSettings.showInstances.community, + displayName = true, + badges = { + nsfw: false, + }, + class: clazz = '', + instanceClass = '', + ...rest + }: Props = $props()
diff --git a/src/lib/components/lemmy/dropdowns/Location.svelte b/src/lib/components/lemmy/dropdowns/Location.svelte index dc82a253..95efa1dc 100644 --- a/src/lib/components/lemmy/dropdowns/Location.svelte +++ b/src/lib/components/lemmy/dropdowns/Location.svelte @@ -1,4 +1,6 @@ { @@ -52,10 +68,12 @@ if (navigate) searchParam($page.url, 'sort', selected, 'page', 'cursor') }} > - - - {$t('filter.sort.label')} - + {#snippet label()} + + + {$t('filter.sort.label')} + + {/snippet}