feat: use new file input
This commit is contained in:
1 parent
2c7bb403b7
commit
260ee52404
7 files changed
+14
-75
No files matched your search
+1
-1
@@ -42,7 +42,7 @@
|
|||||||
"@dicebear/initials": "^6.0.4",
|
"@dicebear/initials": "^6.0.4",
|
||||||
"lemmy-js-client": "^0.18.0-rc.2",
|
"lemmy-js-client": "^0.18.0-rc.2",
|
||||||
"markdown-it": "^13.0.1",
|
"markdown-it": "^13.0.1",
|
||||||
"mono-svelte": "^0.2.18"
|
"mono-svelte": "^0.2.19"
|
||||||
},
|
},
|
||||||
"type": "module"
|
"type": "module"
|
||||||
}
|
}
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import { DocumentPlus, Icon } from 'svelte-hero-icons'
|
|
||||||
|
|
||||||
export let accept = 'image/*,video/*'
|
|
||||||
export let multiple = false
|
|
||||||
export let files: FileList | null | undefined = null
|
|
||||||
export let image = false
|
|
||||||
export let label: string | undefined = undefined
|
|
||||||
|
|
||||||
let previewURL = ''
|
|
||||||
let dragover = false
|
|
||||||
|
|
||||||
$: if (files) {
|
|
||||||
previewURL = URL.createObjectURL(files[0])
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
{#if label}
|
|
||||||
<span class="block my-1 text-sm font-bold">{label}</span>
|
|
||||||
{/if}
|
|
||||||
<label
|
|
||||||
class="flex flex-col items-center px-8 py-4 mx-auto w-full rounded-lg
|
|
||||||
border border-slate-300 dark:border-zinc-700 bg-white dark:bg-black
|
|
||||||
cursor-pointer min-h-36 transition-colors {dragover
|
|
||||||
? 'border-sky-500 text-sky-500'
|
|
||||||
: ''}
|
|
||||||
"
|
|
||||||
on:drop|preventDefault={(event) => (files = event.dataTransfer?.files)}
|
|
||||||
on:dragover|preventDefault={(event) => {
|
|
||||||
if (event.dataTransfer) {
|
|
||||||
event.dataTransfer.dropEffect = 'copy'
|
|
||||||
dragover = true
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
on:dragleave|preventDefault={() => (dragover = false)}
|
|
||||||
>
|
|
||||||
{#if image && files}
|
|
||||||
<!-- svelte-ignore a11y-missing-attribute -->
|
|
||||||
<img
|
|
||||||
src={previewURL}
|
|
||||||
on:load={() => {
|
|
||||||
if (previewURL) URL.revokeObjectURL(previewURL)
|
|
||||||
}}
|
|
||||||
class="w-full max-w-sm h-full rounded-lg"
|
|
||||||
/>
|
|
||||||
{:else}
|
|
||||||
<Icon src={DocumentPlus} class="opacity-50" size="36" />
|
|
||||||
<p class="text-sm opacity-50">Attach a file</p>
|
|
||||||
{/if}
|
|
||||||
<input type="file" bind:files {accept} class="hidden" {multiple} />
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { goto } from '$app/navigation'
|
import { goto } from '$app/navigation'
|
||||||
import { profile } from '$lib/auth.js'
|
import { profile } from '$lib/auth.js'
|
||||||
import FileInput from '$lib/components/input/FileInput.svelte'
|
|
||||||
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
||||||
import { toast } from 'mono-svelte'
|
import { ImageInput, toast } from 'mono-svelte'
|
||||||
import { getClient, uploadImage } from '$lib/lemmy.js'
|
import { getClient, uploadImage } from '$lib/lemmy.js'
|
||||||
import { addSubscription } from '$lib/lemmy/user.js'
|
import { addSubscription } from '$lib/lemmy/user.js'
|
||||||
import { Button, Checkbox, TextInput } from 'mono-svelte'
|
import { Button, Checkbox, TextInput } from 'mono-svelte'
|
||||||
@@ -118,8 +117,8 @@
|
|||||||
disabled={edit != undefined}
|
disabled={edit != undefined}
|
||||||
/>
|
/>
|
||||||
<TextInput required label="Display name" bind:value={formData.displayName} />
|
<TextInput required label="Display name" bind:value={formData.displayName} />
|
||||||
<FileInput label="Icon" bind:files={formData.icon} image />
|
<ImageInput label="Icon" bind:files={formData.icon} />
|
||||||
<FileInput label="Banner" bind:files={formData.banner} image />
|
<ImageInput label="Banner" bind:files={formData.banner} />
|
||||||
<MarkdownEditor previewButton label="Sidebar" bind:value={formData.sidebar} />
|
<MarkdownEditor previewButton label="Sidebar" bind:value={formData.sidebar} />
|
||||||
|
|
||||||
<Checkbox bind:checked={formData.nsfw}>NSFW</Checkbox>
|
<Checkbox bind:checked={formData.nsfw}>NSFW</Checkbox>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { profile } from '$lib/auth.js'
|
import { profile } from '$lib/auth.js'
|
||||||
import FileInput from '$lib/components/input/FileInput.svelte'
|
import { ImageInput, toast } from 'mono-svelte'
|
||||||
import { toast } from 'mono-svelte'
|
|
||||||
import { uploadImage } from '$lib/lemmy.js'
|
import { uploadImage } from '$lib/lemmy.js'
|
||||||
import { Button, Modal } from 'mono-svelte'
|
import { Button, Modal } from 'mono-svelte'
|
||||||
import { createEventDispatcher } from 'svelte'
|
import { createEventDispatcher } from 'svelte'
|
||||||
@@ -38,11 +37,7 @@
|
|||||||
<Modal bind:open>
|
<Modal bind:open>
|
||||||
<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}>
|
||||||
<FileInput
|
<ImageInput accept="image/jpeg,image/png,image/webp" bind:files={image} />
|
||||||
accept="image/jpeg,image/png,image/webp"
|
|
||||||
image
|
|
||||||
bind:files={image}
|
|
||||||
/>
|
|
||||||
<Button {loading} disabled={loading} submit color="primary" size="lg">
|
<Button {loading} disabled={loading} submit color="primary" size="lg">
|
||||||
Upload
|
Upload
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { profile } from '$lib/auth.js'
|
import { profile } from '$lib/auth.js'
|
||||||
import FileInput from '$lib/components/input/FileInput.svelte'
|
|
||||||
import MultiSelect from '$lib/components/input/MultiSelect.svelte'
|
import MultiSelect from '$lib/components/input/MultiSelect.svelte'
|
||||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||||
import { toast } from 'mono-svelte'
|
import { ImageInput, toast } from 'mono-svelte'
|
||||||
import { uploadImage } from '$lib/lemmy.js'
|
import { uploadImage } from '$lib/lemmy.js'
|
||||||
import { Button, Label, Modal, TextArea } from 'mono-svelte'
|
import { Button, Label, Modal, TextArea } from 'mono-svelte'
|
||||||
import { createEventDispatcher } from 'svelte'
|
import { createEventDispatcher } from 'svelte'
|
||||||
@@ -102,7 +101,7 @@
|
|||||||
<Modal bind:open={uploadingImage}>
|
<Modal bind:open={uploadingImage}>
|
||||||
<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}>
|
||||||
<FileInput image bind:files={image} />
|
<ImageInput bind:files={image} />
|
||||||
<Button {loading} disabled={loading} submit color="primary" size="lg">
|
<Button {loading} disabled={loading} submit color="primary" size="lg">
|
||||||
Upload
|
Upload
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { goto } from '$app/navigation'
|
import { goto } from '$app/navigation'
|
||||||
import { profile, profileData, setUserID } from '$lib/auth.js'
|
import { profile, profileData, setUserID } from '$lib/auth.js'
|
||||||
import FileInput from '$lib/components/input/FileInput.svelte'
|
|
||||||
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
||||||
import { Material, removeToast, toast } from 'mono-svelte'
|
import { ImageInput, Material, removeToast, toast } from 'mono-svelte'
|
||||||
import { getClient, uploadImage } from '$lib/lemmy.js'
|
import { getClient, uploadImage } from '$lib/lemmy.js'
|
||||||
import type { SaveUserSettings } from 'lemmy-js-client'
|
import type { SaveUserSettings } from 'lemmy-js-client'
|
||||||
import { Button, Checkbox, Modal, TextInput } from 'mono-svelte'
|
import { Button, Checkbox, Modal, TextInput } from 'mono-svelte'
|
||||||
@@ -160,7 +159,7 @@
|
|||||||
label="Bio"
|
label="Bio"
|
||||||
previewButton
|
previewButton
|
||||||
/>
|
/>
|
||||||
<FileInput label="Profile image" image bind:files={profileImage} />
|
<ImageInput label="Profile image" bind:files={profileImage} />
|
||||||
<TextInput label="Email" bind:value={formData.email} />
|
<TextInput label="Email" bind:value={formData.email} />
|
||||||
<TextInput
|
<TextInput
|
||||||
label="Matrix User"
|
label="Matrix User"
|
||||||
|
|||||||
@@ -2977,10 +2977,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@^0.2.18:
|
mono-svelte@^0.2.19:
|
||||||
version "0.2.18"
|
version "0.2.19"
|
||||||
resolved "https://registry.yarnpkg.com/mono-svelte/-/mono-svelte-0.2.18.tgz#c1d2cc4a3cd0d9ba0778e94476c40be974424760"
|
resolved "https://registry.yarnpkg.com/mono-svelte/-/mono-svelte-0.2.19.tgz#3c413d1200a86128bad250c429051742a322ec28"
|
||||||
integrity sha512-FlgPkbsz8DsltitQYr0wtVtU35ImWb6s1pZummMvd5rqvSXt5OY7pQZjyzrcZPiU1EtJidbPYXaOf9ywDRoy+Q==
|
integrity sha512-OhCe8WVAJk3BMLwz0/ngvsi/qfyW+g5GrpwLTDmrrb0Zbeit477cPrDfCGWuG1S6FK2l9vB09uBj2TUIJbdl/w==
|
||||||
|
|
||||||
mri@^1.1.0:
|
mri@^1.1.0:
|
||||||
version "1.2.0"
|
version "1.2.0"
|
||||||
|
|||||||
Reference in new issue
Block a user