feat: add admin icon and banners, close #229
This commit is contained in:
1 parent
3f06735fa7
commit
2f9b2be6d0
5 files changed
+51
-11
No files matched your search
@@ -7,6 +7,7 @@
|
||||
|
||||
export let open: boolean
|
||||
export let image: FileList | null = null
|
||||
export let output: string | undefined = undefined
|
||||
let loading = false
|
||||
|
||||
const dispatcher = createEventDispatcher<{ upload: string }>()
|
||||
@@ -26,6 +27,7 @@
|
||||
if (!uploaded) throw new Error('Image upload returned undefined')
|
||||
|
||||
dispatcher('upload', uploaded)
|
||||
output = uploaded
|
||||
loading = false
|
||||
} catch (err) {
|
||||
toast({
|
||||
@@ -38,7 +40,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal bind:open>
|
||||
<Modal bind:open bind:output>
|
||||
<span slot="title">Upload image</span>
|
||||
<form class="flex flex-col gap-4" on:submit|preventDefault={upload}>
|
||||
<ImageInput accept="image/jpeg,image/png,image/webp" bind:files={image} />
|
||||
|
||||
@@ -124,7 +124,7 @@
|
||||
</Label>
|
||||
{/if}
|
||||
<div
|
||||
class="flex flex-col border border-slate-300 dark:border-zinc-800 rounded-md
|
||||
class="flex flex-col border border-slate-300 dark:border-zinc-800 rounded-xl
|
||||
overflow-hidden focus-within:border-black focus-within:dark:border-white transition-colors"
|
||||
class:mt-1={label}
|
||||
>
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
<script lang="ts">
|
||||
import { profile } from '$lib/auth.js'
|
||||
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
||||
import { toast } from 'mono-svelte'
|
||||
import { Label, toast } from 'mono-svelte'
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
import type { EditSite } from 'lemmy-js-client'
|
||||
import type { PageData } from './$types.js'
|
||||
import { Button, Checkbox, Select, TextInput } from 'mono-svelte'
|
||||
import ImageUploadModal from '$lib/components/lemmy/modal/ImageUploadModal.svelte';
|
||||
import { DocumentPlus, Icon } from 'svelte-hero-icons';
|
||||
|
||||
export let data: PageData
|
||||
|
||||
@@ -41,6 +43,11 @@
|
||||
}
|
||||
|
||||
let saving = false
|
||||
|
||||
let uploading = {
|
||||
icon: false,
|
||||
banner: false
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
@@ -62,6 +69,40 @@
|
||||
bind:value={formData.legal_information}
|
||||
label="Legal"
|
||||
/>
|
||||
<div class="flex flex-col gap-1">
|
||||
<Label>Icon</Label>
|
||||
<button type="button" on:click={() => uploading.icon = !uploading.icon} class="flex flex-col gap-4 bg-white dark:bg-black border border-slate-300 dark:border-zinc-800 p-4 w-full h-32 rounded-xl">
|
||||
{#if formData.icon}
|
||||
<img src={formData.icon} class="rounded-md mx-auto h-full" />
|
||||
{:else}
|
||||
<Icon src={DocumentPlus} size="48" class="text-slate-500 dark:text-zinc-500 mx-auto my-auto" />
|
||||
{/if}
|
||||
</button>
|
||||
{#if uploading.icon}
|
||||
<ImageUploadModal
|
||||
bind:open={uploading.icon}
|
||||
bind:output={formData.icon}
|
||||
on:upload={() => uploading.icon = false}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="flex flex-col gap-1">
|
||||
<Label>Banner</Label>
|
||||
<button type="button" on:click={() => uploading.banner = !uploading.banner} class="flex flex-col gap-4 bg-white dark:bg-black border border-slate-300 dark:border-zinc-800 p-4 w-full h-32 rounded-xl">
|
||||
{#if formData.banner}
|
||||
<img src={formData.banner} class="rounded-md mx-auto h-full" />
|
||||
{:else}
|
||||
<Icon src={DocumentPlus} size="48" class="text-slate-500 dark:text-zinc-500 mx-auto my-auto" />
|
||||
{/if}
|
||||
</button>
|
||||
{#if uploading.banner}
|
||||
<ImageUploadModal
|
||||
bind:open={uploading.banner}
|
||||
bind:output={formData.banner}
|
||||
on:upload={() => uploading.banner = false}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
<Checkbox bind:checked={formData.enable_downvotes} defaultValue={true}>
|
||||
Enable downvotes
|
||||
</Checkbox>
|
||||
@@ -133,9 +174,6 @@
|
||||
<Checkbox bind:checked={formData.captcha_enabled} defaultValue={false}>
|
||||
Captcha enabled
|
||||
</Checkbox>
|
||||
{#if formData.captcha_enabled}
|
||||
<Select bind:value={formData.captcha_difficulty} />
|
||||
{/if}
|
||||
{/if}
|
||||
<Button color="primary" size="lg" loading={saving} disabled={saving} submit>
|
||||
Save
|
||||
|
||||
Reference in new issue
Block a user