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
+1
-1
@@ -44,7 +44,7 @@
|
|||||||
"@dicebear/core": "^6.0.4",
|
"@dicebear/core": "^6.0.4",
|
||||||
"@dicebear/initials": "^6.0.4",
|
"@dicebear/initials": "^6.0.4",
|
||||||
"markdown-it": "^13.0.1",
|
"markdown-it": "^13.0.1",
|
||||||
"mono-svelte": "^1.4.2"
|
"mono-svelte": "^1.4.4"
|
||||||
},
|
},
|
||||||
"type": "module"
|
"type": "module"
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
export let open: boolean
|
export let open: boolean
|
||||||
export let image: FileList | null = null
|
export let image: FileList | null = null
|
||||||
|
export let output: string | undefined = undefined
|
||||||
let loading = false
|
let loading = false
|
||||||
|
|
||||||
const dispatcher = createEventDispatcher<{ upload: string }>()
|
const dispatcher = createEventDispatcher<{ upload: string }>()
|
||||||
@@ -26,6 +27,7 @@
|
|||||||
if (!uploaded) throw new Error('Image upload returned undefined')
|
if (!uploaded) throw new Error('Image upload returned undefined')
|
||||||
|
|
||||||
dispatcher('upload', uploaded)
|
dispatcher('upload', uploaded)
|
||||||
|
output = uploaded
|
||||||
loading = false
|
loading = false
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toast({
|
toast({
|
||||||
@@ -38,7 +40,7 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Modal bind:open>
|
<Modal bind:open bind:output>
|
||||||
<span slot="title">Upload image</span>
|
<span slot="title">Upload image</span>
|
||||||
<form class="flex flex-col gap-4" on:submit|preventDefault={upload}>
|
<form class="flex flex-col gap-4" on:submit|preventDefault={upload}>
|
||||||
<ImageInput accept="image/jpeg,image/png,image/webp" bind:files={image} />
|
<ImageInput accept="image/jpeg,image/png,image/webp" bind:files={image} />
|
||||||
|
|||||||
@@ -124,7 +124,7 @@
|
|||||||
</Label>
|
</Label>
|
||||||
{/if}
|
{/if}
|
||||||
<div
|
<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"
|
overflow-hidden focus-within:border-black focus-within:dark:border-white transition-colors"
|
||||||
class:mt-1={label}
|
class:mt-1={label}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { profile } from '$lib/auth.js'
|
import { profile } from '$lib/auth.js'
|
||||||
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
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 { getClient } from '$lib/lemmy.js'
|
||||||
import type { EditSite } from 'lemmy-js-client'
|
import type { EditSite } from 'lemmy-js-client'
|
||||||
import type { PageData } from './$types.js'
|
import type { PageData } from './$types.js'
|
||||||
import { Button, Checkbox, Select, TextInput } from 'mono-svelte'
|
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
|
export let data: PageData
|
||||||
|
|
||||||
@@ -41,6 +43,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
let saving = false
|
let saving = false
|
||||||
|
|
||||||
|
let uploading = {
|
||||||
|
icon: false,
|
||||||
|
banner: false
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
@@ -62,6 +69,40 @@
|
|||||||
bind:value={formData.legal_information}
|
bind:value={formData.legal_information}
|
||||||
label="Legal"
|
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}>
|
<Checkbox bind:checked={formData.enable_downvotes} defaultValue={true}>
|
||||||
Enable downvotes
|
Enable downvotes
|
||||||
</Checkbox>
|
</Checkbox>
|
||||||
@@ -133,9 +174,6 @@
|
|||||||
<Checkbox bind:checked={formData.captcha_enabled} defaultValue={false}>
|
<Checkbox bind:checked={formData.captcha_enabled} defaultValue={false}>
|
||||||
Captcha enabled
|
Captcha enabled
|
||||||
</Checkbox>
|
</Checkbox>
|
||||||
{#if formData.captcha_enabled}
|
|
||||||
<Select bind:value={formData.captcha_difficulty} />
|
|
||||||
{/if}
|
|
||||||
{/if}
|
{/if}
|
||||||
<Button color="primary" size="lg" loading={saving} disabled={saving} submit>
|
<Button color="primary" size="lg" loading={saving} disabled={saving} submit>
|
||||||
Save
|
Save
|
||||||
|
|||||||
@@ -3054,10 +3054,10 @@ mlly@^1.2.0, mlly@^1.4.0:
|
|||||||
pkg-types "^1.0.3"
|
pkg-types "^1.0.3"
|
||||||
ufo "^1.1.2"
|
ufo "^1.1.2"
|
||||||
|
|
||||||
mono-svelte@^1.4.2:
|
mono-svelte@^1.4.4:
|
||||||
version "1.4.2"
|
version "1.4.4"
|
||||||
resolved "https://registry.yarnpkg.com/mono-svelte/-/mono-svelte-1.4.2.tgz#c66520ac9f56e964656228fad34149d5e85d3813"
|
resolved "https://registry.yarnpkg.com/mono-svelte/-/mono-svelte-1.4.4.tgz#6c7d406f82f97bec17b48a95c3b034e00b5ad62c"
|
||||||
integrity sha512-iAqtHfJBAoBNiE/WSRPEyU/MWTMgLLTbNYhVKq+U2+ktJ9/wC9rhTgbq7CuCzfWBWKFJgtqsZNS/w0TBtIhgXA==
|
integrity sha512-lGemcq9N5tjvRM+s1rFzmLeOnFj4swyd5uw1FcQlPUMfcXTNyOSTwq+/gvfuGjNnJnKQOFkjAltZDQwYlHNTPw==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@floating-ui/core" "^1.5.0"
|
"@floating-ui/core" "^1.5.0"
|
||||||
svelte-floating-ui "^1.5.3"
|
svelte-floating-ui "^1.5.3"
|
||||||
|
|||||||
Reference in new issue
Block a user