feat: add custom thumbnails to postform, close #656
This commit is contained in:
4 files changed
+48
-17
No files matched your search
@@ -152,7 +152,8 @@
|
|||||||
"poll": "Poll",
|
"poll": "Poll",
|
||||||
"event": "Event"
|
"event": "Event"
|
||||||
},
|
},
|
||||||
"autosubmit": "Submit automatically"
|
"autosubmit": "Submit automatically",
|
||||||
|
"customThumbnail": "Set thumbnail"
|
||||||
},
|
},
|
||||||
"profile": {
|
"profile": {
|
||||||
"displayName": "Display name",
|
"displayName": "Display name",
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
import { placeholders } from '$lib/app/util.svelte'
|
import { placeholders } from '$lib/app/util.svelte'
|
||||||
import Duration from '$lib/ui/form/Duration.svelte'
|
import Duration from '$lib/ui/form/Duration.svelte'
|
||||||
import FreeTextInput from '$lib/ui/form/FreeTextInput.svelte'
|
import FreeTextInput from '$lib/ui/form/FreeTextInput.svelte'
|
||||||
|
import ImageInputModal from '$lib/ui/form/ImageInputModal.svelte'
|
||||||
import ObjectAutocomplete from '$lib/ui/form/ObjectAutocomplete.svelte'
|
import ObjectAutocomplete from '$lib/ui/form/ObjectAutocomplete.svelte'
|
||||||
import MultiSelect from '$lib/ui/form/Switch.svelte'
|
import MultiSelect from '$lib/ui/form/Switch.svelte'
|
||||||
import Avatar from '$lib/ui/generic/Avatar.svelte'
|
import Avatar from '$lib/ui/generic/Avatar.svelte'
|
||||||
@@ -39,6 +40,7 @@
|
|||||||
Language,
|
Language,
|
||||||
Photo,
|
Photo,
|
||||||
Plus,
|
Plus,
|
||||||
|
QrCode,
|
||||||
Sparkles,
|
Sparkles,
|
||||||
Tag,
|
Tag,
|
||||||
Trash,
|
Trash,
|
||||||
@@ -70,6 +72,7 @@
|
|||||||
|
|
||||||
let loading = $state<boolean>(false)
|
let loading = $state<boolean>(false)
|
||||||
let uploadImage = $state(false)
|
let uploadImage = $state(false)
|
||||||
|
let customThumbnail = $state(false)
|
||||||
|
|
||||||
async function autofill(
|
async function autofill(
|
||||||
data: URL | { title?: string; body?: string },
|
data: URL | { title?: string; body?: string },
|
||||||
@@ -117,12 +120,17 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if uploadImage}
|
{#if uploadImage}
|
||||||
{#await import('$lib/ui/form/ImageInputModal.svelte') then { default: UploadModal }}
|
<ImageInputModal
|
||||||
<UploadModal
|
bind:open={uploadImage}
|
||||||
bind:open={uploadImage}
|
bind:imageUrl={() => '', (v) => (form.url = v)}
|
||||||
bind:imageUrl={() => '', (v) => (form.url = v)}
|
/>
|
||||||
/>
|
{/if}
|
||||||
{/await}
|
|
||||||
|
{#if customThumbnail}
|
||||||
|
<ImageInputModal
|
||||||
|
bind:open={customThumbnail}
|
||||||
|
bind:imageUrl={() => form.thumbnail, (v) => (form.thumbnail = v)}
|
||||||
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#snippet altText()}
|
{#snippet altText()}
|
||||||
@@ -387,10 +395,16 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div class="flex flex-row flex-wrap gap-2">
|
<div class="flex flex-row overflow-auto gap-2 -mx-3 px-3 relative">
|
||||||
|
<div
|
||||||
|
class="bg-gradient-to-r from-slate-25 to-slate-25/0 dark:from-zinc-925 dark:to-zinc-925/0 absolute left-0 w-3 h-full z-10"
|
||||||
|
></div>
|
||||||
|
<div
|
||||||
|
class="bg-gradient-to-l from-slate-25 to-slate-25/0 dark:from-zinc-925 dark:to-zinc-925/0 absolute right-0 w-3 h-full z-10"
|
||||||
|
></div>
|
||||||
<ButtonGroup
|
<ButtonGroup
|
||||||
orientation="horizontal"
|
orientation="horizontal"
|
||||||
class="flex flex-row flex-wrap w-full"
|
class="flex flex-row *:flex-shrink-0 w-full"
|
||||||
>
|
>
|
||||||
{#if form.type == 'normal'}
|
{#if form.type == 'normal'}
|
||||||
<Button
|
<Button
|
||||||
@@ -412,6 +426,18 @@
|
|||||||
{$t('form.post.altText')}
|
{$t('form.post.altText')}
|
||||||
</Button>
|
</Button>
|
||||||
{/if}
|
{/if}
|
||||||
|
{#if form.url}
|
||||||
|
<Button
|
||||||
|
class="animate-pop-in"
|
||||||
|
onclick={() => {
|
||||||
|
customThumbnail = !customThumbnail
|
||||||
|
}}
|
||||||
|
color={form.thumbnail ? 'primary' : 'secondary'}
|
||||||
|
icon={QrCode}
|
||||||
|
>
|
||||||
|
{$t('form.post.customThumbnail')}
|
||||||
|
</Button>
|
||||||
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
{#if form.language === undefined}
|
{#if form.language === undefined}
|
||||||
<Button onclick={() => (form.language = '')} icon={Language}>
|
<Button onclick={() => (form.language = '')} icon={Language}>
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ export class PostFormState {
|
|||||||
this.nsfw = $state(post?.nsfw ?? false)
|
this.nsfw = $state(post?.nsfw ?? false)
|
||||||
this.altText = $state(post?.alt_text)
|
this.altText = $state(post?.alt_text)
|
||||||
this.language = $state(post?.language_id?.toString())
|
this.language = $state(post?.language_id?.toString())
|
||||||
|
this.thumbnail = $state()
|
||||||
this.poll = $state(
|
this.poll = $state(
|
||||||
post?.poll ?? {
|
post?.poll ?? {
|
||||||
mode: 'single',
|
mode: 'single',
|
||||||
|
|||||||
@@ -37,16 +37,19 @@
|
|||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-group.btn-group-horizontal :global(> *) {
|
.btn-group.btn-group-horizontal :global {
|
||||||
position: relative;
|
& > button,
|
||||||
border-radius: 8px !important;
|
& > a {
|
||||||
|
position: relative;
|
||||||
|
border-radius: 8px !important;
|
||||||
|
|
||||||
&:first-child {
|
&:first-child {
|
||||||
border-radius: 24px 12px 12px 24px !important;
|
border-radius: 24px 12px 12px 24px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:last-child {
|
&:last-child {
|
||||||
border-radius: 12px 24px 24px 12px !important;
|
border-radius: 12px 24px 24px 12px !important;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
Reference in new issue
Block a user