diff --git a/.prettierignore b/.prettierignore index 94a2dd14..91a7c084 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1 +1,2 @@ -*.json \ No newline at end of file +*.json +app.html diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..f2b25e04 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "i18n-ally.localesPaths": [ + "src/lib/i18n", + "src/routes/inbox/messages" + ] +} \ No newline at end of file diff --git a/eslint.config.js b/eslint.config.js index 5fb6b567..4fd4d3a8 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -28,6 +28,7 @@ export default ts.config( 'svelte/require-each-key': 'off', 'svelte/prefer-writable-derived': 'off', 'no-console': 'off', + '@typescript-eslint/no-explicit-any': 'off', }, }, { diff --git a/package.json b/package.json index 5a9e6288..6d915318 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "photon-lemmy", - "version": "2.0.1", + "version": "2.0.2", "license": "AGPL-3.0-only", "devDependencies": { "@dicebear/core": "^8.0.1", diff --git a/src/app.html b/src/app.html index e9997cdc..36bc42fc 100644 --- a/src/app.html +++ b/src/app.html @@ -5,40 +5,15 @@ - %sveltekit.head%
- - - +
-
+
%sveltekit.body%
diff --git a/src/lib/auth.svelte.ts b/src/lib/auth.svelte.ts index 54b2e84e..466aae74 100644 --- a/src/lib/auth.svelte.ts +++ b/src/lib/auth.svelte.ts @@ -237,7 +237,7 @@ class Profile { const id = Math.max(...this.meta.profiles.map(p => p.id)) + 1 this.meta.profile = id - this.meta.profiles.push({ + this.meta.profiles.unshift({ id: id, instance: instance, jwt: jwt, diff --git a/src/lib/components/lemmy/modal/ImageUploadModal.svelte b/src/lib/components/form/ImageAttachForm.svelte similarity index 55% rename from src/lib/components/lemmy/modal/ImageUploadModal.svelte rename to src/lib/components/form/ImageAttachForm.svelte index acf2c09c..7547917b 100644 --- a/src/lib/components/lemmy/modal/ImageUploadModal.svelte +++ b/src/lib/components/form/ImageAttachForm.svelte @@ -1,17 +1,15 @@ - - {#snippet customTitle()} -
Upload image
- {/snippet} - {#if progress != 1} -
- -
- {/if} -
{ - e.preventDefault() - upload() - }} - > -
+{/if} + { + e.preventDefault() + upload() + }} +> + - - - + > + + {$t('form.post.selectFile')} + + {/if} + + + + diff --git a/src/lib/components/form/ImageInputModal.svelte b/src/lib/components/form/ImageInputModal.svelte new file mode 100644 index 00000000..d93b1456 --- /dev/null +++ b/src/lib/components/form/ImageInputModal.svelte @@ -0,0 +1,69 @@ + + + +
+ + + +
+ + {#if customUrl} +
{ + e.preventDefault() + if (!imageUrl) throw new Error('missing imageurl') + + if (URL.canParse != undefined) { + if (!URL.canParse(imageUrl)) throw new Error('invalid URL') + } + + passedImageUrl = imageUrl + open = false + }} + class="contents" + > + + + + {:else} + { + open = false + passedImageUrl = uploaded[0] + }} + /> + {/if} +
diff --git a/src/lib/components/form/ImageInputUpload.svelte b/src/lib/components/form/ImageInputUpload.svelte index cf4d1b1e..1218d718 100644 --- a/src/lib/components/form/ImageInputUpload.svelte +++ b/src/lib/components/form/ImageInputUpload.svelte @@ -1,11 +1,18 @@ @@ -43,15 +50,6 @@ {$t('common.attach')}

{/if} - {#if open} - { - open = false - imageUrl = uploaded[0] - }} - /> - {/if} + diff --git a/src/lib/components/input/FreeTextInput.svelte b/src/lib/components/input/FreeTextInput.svelte index abc23eeb..ae2c0ecb 100644 --- a/src/lib/components/input/FreeTextInput.svelte +++ b/src/lib/components/input/FreeTextInput.svelte @@ -1,6 +1,6 @@ + + + {@render children?.()} + diff --git a/src/lib/components/lemmy/SiteCard.svelte b/src/lib/components/lemmy/SiteCard.svelte index 78169ca7..a09c141d 100644 --- a/src/lib/components/lemmy/SiteCard.svelte +++ b/src/lib/components/lemmy/SiteCard.svelte @@ -10,16 +10,16 @@ import Link from '../input/Link.svelte' import Expandable from '../ui/Expandable.svelte' import LabelStat from '../ui/LabelStat.svelte' - import CommonList from '../ui/layout/CommonList.svelte' - import SidebarButton from '../ui/sidebar/SidebarButton.svelte' + import ItemList from './generic/ItemList.svelte' import { optimizeImageURL } from './post/helpers' + import type { ClassValue, HTMLAttributes } from 'svelte/elements' - interface Props { + interface Props extends HTMLAttributes { site: SiteView taglines?: Tagline[] | undefined admins?: PersonView[] | undefined version?: string | undefined - class?: string + class?: ClassValue } let { @@ -31,7 +31,7 @@ }: Props = $props() -
{/snippet} - - {#snippet item(admin)} - - {#snippet customIcon()} - {/snippet} - {#snippet label()} -
- {admin.person.display_name ?? admin.person.name} - - {new URL(admin.person.actor_id).hostname} - -
- {/snippet} -
- {/snippet} -
+ ({ + id: i.person.id, + name: i.person.display_name || i.person.name, + url: userLink(i.person), + avatar: i.person.avatar, + instance: new URL(i.person.actor_id).hostname, + }))} + /> {/if} @@ -162,4 +141,4 @@
- + diff --git a/src/lib/components/lemmy/comment/Comment.svelte b/src/lib/components/lemmy/comment/Comment.svelte index ed6e200e..d17372d6 100644 --- a/src/lib/components/lemmy/comment/Comment.svelte +++ b/src/lib/components/lemmy/comment/Comment.svelte @@ -1,4 +1,5 @@ {#await community_view} -
+
{:then community_view} -
{/snippet} - - {#snippet item(moderator)} - - {#snippet customIcon()} - - {/snippet} - {#snippet label()} -
- - {moderator.moderator.display_name ?? - moderator.moderator.name} - - - {new URL(moderator.moderator.actor_id).hostname} - -
- {/snippet} -
- {/snippet} -
+ ({ + id: i.moderator.id, + name: i.moderator.display_name || i.moderator.name, + url: userLink(i.moderator), + avatar: i.moderator.avatar, + instance: new URL(i.moderator.actor_id).hostname, + }))} + /> {/if}
@@ -363,5 +341,5 @@ {/if}
- + {/await} diff --git a/src/lib/components/lemmy/generic/ItemList.svelte b/src/lib/components/lemmy/generic/ItemList.svelte index cfd00b45..b29a5fe6 100644 --- a/src/lib/components/lemmy/generic/ItemList.svelte +++ b/src/lib/components/lemmy/generic/ItemList.svelte @@ -1,8 +1,7 @@ -{#each items.sort((a, b) => a.name.localeCompare(b.name)) as item (item.id)} -
+ + {#snippet item(item)}
- -{/each} + {/snippet} + diff --git a/src/lib/components/lemmy/post/Post.svelte b/src/lib/components/lemmy/post/Post.svelte index 5ccf209d..d3cdbd6e 100644 --- a/src/lib/components/lemmy/post/Post.svelte +++ b/src/lib/components/lemmy/post/Post.svelte @@ -1,10 +1,9 @@ {#if uploadingImage} - {#await import('$lib/components/lemmy/modal/ImageUploadModal.svelte') then { default: UploadModal }} + {#await import('$lib/components/form/ImageInputModal.svelte') then { default: UploadModal }} { - if (e) data.url = e[0] - uploadingImage = false - }} + bind:imageUrl={() => '', v => (data.url = v)} /> {/await} {/if} @@ -341,7 +337,6 @@ {/if} {/if} {#if embed_title && view == 'cozy'} - - - {#if thumbnail_url} - + {#if thumbnail_url} + + /> + {/if} +
+ {#if richURL} +
+ {richURL.hostname} +
{/if} -
- {#if richURL} -
- {richURL.hostname} -
- {/if} -

{embed_title}

-
- {#if thumbnail_url} - - {#each ['webp'] as format} - - {/each} - {embed_title}

+
+ {#if thumbnail_url} + + {#each ['webp'] as format} + - - {/if} -
-
+ {/each} + + + {/if} + {:else} {#if uploadingImage && images} - { - e.forEach(i => { - wrapSelection(`![](${i})\n\n`, '') - }) - }} - /> + + { + e.forEach(i => { + wrapSelection(`![](${i})\n\n`, '') + }) + }} + /> + {/if}
diff --git a/src/lib/components/markdown/renderers/MdLink.svelte b/src/lib/components/markdown/renderers/MdLink.svelte index 8864450c..a8fb0eff 100644 --- a/src/lib/components/markdown/renderers/MdLink.svelte +++ b/src/lib/components/markdown/renderers/MdLink.svelte @@ -23,7 +23,7 @@ {@render children?.()} diff --git a/src/lib/components/markdown/renderers/MdParagraph.svelte b/src/lib/components/markdown/renderers/MdParagraph.svelte index 6644c603..fb102bc6 100644 --- a/src/lib/components/markdown/renderers/MdParagraph.svelte +++ b/src/lib/components/markdown/renderers/MdParagraph.svelte @@ -9,12 +9,12 @@ let { children } = $props() -

+

{@render children?.()}

diff --git a/src/lib/components/ui/EndPlaceholder.svelte b/src/lib/components/ui/EndPlaceholder.svelte index 070a7771..0b1019b5 100644 --- a/src/lib/components/ui/EndPlaceholder.svelte +++ b/src/lib/components/ui/EndPlaceholder.svelte @@ -2,11 +2,19 @@ import type { ClassValue } from 'svelte/elements' const sizes = { + xs: 'text-xs', sm: 'text-sm', md: 'text-base', lg: 'text-lg', } + const margins = { + none: '', + sm: 'mt-3 mb-1 px-3', + md: 'mt-4 mb-2', + lg: 'mt-6 mb-2', + } + const colors = { subtle: 'text-slate-600 dark:text-zinc-400', none: '', @@ -16,6 +24,7 @@ class?: ClassValue size?: keyof typeof sizes color?: keyof typeof colors + margin?: keyof typeof margins border?: boolean children?: import('svelte').Snippet action?: import('svelte').Snippet @@ -28,6 +37,7 @@ border = true, size = 'sm', color = 'subtle', + margin = 'none', }: Props = $props() @@ -36,17 +46,18 @@ 'flex flex-row items-center gap-2 flex-wrap', sizes[size], colors[color], + margins[margin], clazz, ]} > - +

{@render children?.()} - -
+
+ >
{@render action?.()}

diff --git a/src/lib/components/ui/EntityHeader.svelte b/src/lib/components/ui/EntityHeader.svelte index 8eff4167..e43f17d7 100644 --- a/src/lib/components/ui/EntityHeader.svelte +++ b/src/lib/components/ui/EntityHeader.svelte @@ -40,90 +40,66 @@ }: Props = $props() -
- {#if banner} +
+
User banner - {/if} -
-
- -
- - {name} - - - {@render nameDetail?.()} - - - {#if actions} -
- {@render actions?.()} -
- {/if} -
-
- {#if bio} -
- - {#snippet title(open)} - {#if bio.split('\n')?.[0]?.startsWith('#') || open} - {$t('nav.menu.about')} - {:else} -
- {bio.split('\n')?.[0].slice(0, 75)} -
- {/if} -
-
- {$t('form.post.readMore')} -
- {/snippet} - -
-
- {/if}
-
- {#if stats.length > 0} -
+ User banner +
+ {/if} + + +
+
+ + {name} + + + {@render nameDetail?.()} + + + {#if actions} +
+ {@render actions?.()} +
+ {/if} +
+ {#if stats.length > 0} +
{#each stats as stat}
-
+
{stat.name}
-
+
{#if stat.format ?? true} {/if} +
+ {#if bio} +
+ {#if bio.length > 300} + + {#snippet title()} + {$t('cards.site.about')} + {/snippet} + + + {:else} + + {/if} +
+ {/if} +
{@render children?.()}
diff --git a/src/lib/components/ui/Logo.svelte b/src/lib/components/ui/Logo.svelte index 6ffa51c5..fe0761f8 100644 --- a/src/lib/components/ui/Logo.svelte +++ b/src/lib/components/ui/Logo.svelte @@ -10,13 +10,12 @@ {width} height={width} viewBox="0 0 100 100" - fill="none" + fill="currentColor" xmlns="http://www.w3.org/2000/svg" - class="inline fill-black dark:fill-white hover:fill-slate-700 dark:hover:fill-zinc-300 transition-colors" + class="inline hover:fill-slate-700 dark:hover:fill-zinc-300 transition-colors" > diff --git a/src/lib/components/ui/Pageination.svelte b/src/lib/components/ui/Pageination.svelte index e0fc99f5..9428114f 100644 --- a/src/lib/components/ui/Pageination.svelte +++ b/src/lib/components/ui/Pageination.svelte @@ -44,7 +44,7 @@