feat: use new textarea

This commit is contained in:
Xyphyn committed 2023-09-03 18:46:43 -07:00
1 parent 721fa81fd6
commit 1f9bb5418d
11 files changed
+49 -99

No files matched your search

+1 -1
View File
@@ -42,7 +42,7 @@
"@dicebear/initials": "^6.0.4",
"lemmy-js-client": "^0.18.0-rc.2",
"markdown-it": "^13.0.1",
"mono-svelte": "^0.1.5"
"mono-svelte": "^0.1.6"
},
"type": "module"
}
-42
View File
@@ -1,42 +0,0 @@
<script lang="ts">
import { createEventDispatcher } from 'svelte'
export let label: string = ''
export let placeholder: string = ''
export let value: string = ''
export let maxlength: number = -1
export let rows: number = 3
export let required: boolean = false
export let item: any = undefined
let clazz = ''
export { clazz as class }
const dispatcher = createEventDispatcher()
</script>
<label class="flex flex-col items-center {clazz}">
{#if label != ''}
<span
class="font-bold text-sm text-left mb-1 cursor-pointer w-max self-start"
>
{label}
{#if required}
<span class="font-bold text-red-500">*</span>
{/if}
</span>
{/if}
<textarea
bind:value
bind:this={item}
on:input={(e) => dispatcher('input', e)}
on:keydown
{placeholder}
{maxlength}
{rows}
class="w-full px-3 text-sm py-2.5 bg-white dark:bg-black
border border-slate-300 dark:border-zinc-700 dark:focus:border-white
focus:outline-none focus:border-black transition-colors rounded-md {clazz}"
{...$$restProps}
/>
</label>
@@ -1,9 +1,7 @@
<script lang="ts">
import { Color } from '$lib/ui/colors.js'
import type { CommentResponse } from 'lemmy-js-client'
import { getClient } from '$lib/lemmy.js'
import { createEventDispatcher } from 'svelte'
import TextArea from '$lib/components/input/TextArea.svelte'
import MultiSelect from '$lib/components/input/MultiSelect.svelte'
import Markdown from '$lib/components/markdown/Markdown.svelte'
import { profile } from '$lib/auth.js'
@@ -75,30 +73,23 @@
bind:value
disabled={locked || loading}
on:confirm={submit}
/>
{/if}
{#if actions || previewAction}
<div class="flex flex-row items-center justify-between">
{#if previewAction}
<MultiSelect
options={[false, true]}
optionNames={['Edit', 'Preview']}
bind:selected={preview}
/>
{/if}
previewButton={previewAction}
>
{#if actions}
<Button
large
on:click={submit}
color="primary"
size="lg"
class="sm:ml-auto w-28"
{loading}
disabled={locked || loading}
>
Submit
</Button>
<div class="ml-auto">
<Button
large
on:click={submit}
color="primary"
size="lg"
class="sm:ml-auto w-28"
{loading}
disabled={locked || loading}
>
Submit
</Button>
</div>
{/if}
</div>
</MarkdownEditor>
{/if}
</div>
@@ -1,11 +1,11 @@
<script lang="ts">
import TextArea from '$lib/components/input/TextArea.svelte'
import Avatar from '$lib/components/ui/Avatar.svelte'
import type { Community, Person, PersonView } from 'lemmy-js-client'
import { getClient } from '$lib/lemmy.js'
import { toast } from '$lib/components/ui/toasts/toasts.js'
import { profile } from '$lib/auth.js'
import { Button, Checkbox, Modal, TextInput } from 'mono-svelte'
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
export let open = false
let item: Person | undefined
@@ -114,7 +114,7 @@
{banned ? 'Unbanning' : 'Banning'} from
<span class="font-bold">{community ? community.name : 'site'}</span>
</p>
<TextArea
<MarkdownEditor
required
bind:value={reason}
label="Reason"
@@ -1,5 +1,4 @@
<script lang="ts">
import TextArea from '$lib/components/input/TextArea.svelte'
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
import Post from '$lib/components/lemmy/post/Post.svelte'
import { toast } from '$lib/components/ui/toasts/toasts.js'
@@ -193,7 +192,7 @@
<Post actions={false} post={item} />
{/if}
<TextArea
<MarkdownEditor
rows={3}
label="Reason"
placeholder="Optional"
@@ -1,5 +1,4 @@
<script lang="ts">
import TextArea from '$lib/components/input/TextArea.svelte'
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
import Post from '$lib/components/lemmy/post/Post.svelte'
import { toast } from '$lib/components/ui/toasts/toasts.js'
@@ -7,6 +6,7 @@
import type { CommentView, PostView } from 'lemmy-js-client'
import { profile } from '$lib/auth.js'
import { Button, Modal } from 'mono-svelte'
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
export let open: boolean
export let item: PostView | CommentView | undefined = undefined
@@ -81,9 +81,9 @@
{/if}
</div>
{/if}
<TextArea
<MarkdownEditor
required
rows={3}
rows={4}
label="Reason"
placeholder="he's being a meanie :("
bind:value={reason}
@@ -2,11 +2,10 @@
import { profile } from '$lib/auth.js'
import FileInput from '$lib/components/input/FileInput.svelte'
import MultiSelect from '$lib/components/input/MultiSelect.svelte'
import TextArea from '$lib/components/input/TextArea.svelte'
import Markdown from '$lib/components/markdown/Markdown.svelte'
import { toast } from '$lib/components/ui/toasts/toasts.js'
import { uploadImage } from '$lib/lemmy.js'
import { Button, Modal } from 'mono-svelte'
import { Button, Modal, TextArea } from 'mono-svelte'
import { createEventDispatcher } from 'svelte'
import {
CodeBracket,
@@ -226,7 +225,7 @@ overflow-hidden focus-within:border-black focus-within:dark:border-white transit
</div>
<!--Actual text area-->
<TextArea
class="bg-inherit border-0 rounded-none"
class="bg-inherit border-0 rounded-none !ring-0 focus:!ring-transparent !transition-none"
bind:value
bind:item={textArea}
on:keydown={(e) => {
@@ -244,14 +243,18 @@ overflow-hidden focus-within:border-black focus-within:dark:border-white transit
{...$$restProps}
/>
{/if}
{#if $$slots.default || previewButton}
<div class="p-2 flex items-center w-full">
{#if previewButton}
<MultiSelect
bind:selected={previewing}
options={[false, true]}
optionNames={['Edit', 'Preview']}
/>
{/if}
<slot />
</div>
{/if}
</div>
{#if previewButton}
<div class="mt-2">
<MultiSelect
bind:selected={previewing}
options={[false, true]}
optionNames={['Edit', 'Preview']}
/>
</div>
{/if}
</div>
+2 -2
View File
@@ -1,6 +1,5 @@
<script lang="ts">
import { goto } from '$app/navigation'
import TextArea from '$lib/components/input/TextArea.svelte'
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
import Markdown from '$lib/components/markdown/Markdown.svelte'
import Card from '$lib/components/ui/Card.svelte'
@@ -18,6 +17,7 @@
import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
import { Button } from 'mono-svelte'
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
export let item: CommentReplyView | PersonMentionView | PrivateMessageView
export let read: boolean
@@ -176,7 +176,7 @@
{#if isPrivateMessage(item)}
{#if replying}
<div class="mt-2 flex flex-col gap-2">
<TextArea placeholder="Message" bind:value={reply} rows={3} />
<MarkdownEditor placeholder="Message" bind:value={reply} rows={4} />
<div class="ml-auto w-24">
<Button
disabled={loading}
+3 -3
View File
@@ -2,8 +2,8 @@
import { goto } from '$app/navigation'
import { page } from '$app/stores'
import { setUser } from '$lib/auth.js'
import TextArea from '$lib/components/input/TextArea.svelte'
import Markdown from '$lib/components/markdown/Markdown.svelte'
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
import Avatar from '$lib/components/ui/Avatar.svelte'
import Card from '$lib/components/ui/Card.svelte'
import Placeholder from '$lib/components/ui/Placeholder.svelte'
@@ -11,7 +11,7 @@
import { toast } from '$lib/components/ui/toasts/toasts.js'
import { getClient } from '$lib/lemmy.js'
import type { GetCaptchaResponse } from 'lemmy-js-client'
import { Button, TextInput } from 'mono-svelte'
import { Button, TextArea, TextInput } from 'mono-svelte'
import {
ArrowPath,
ExclamationCircle,
@@ -143,7 +143,7 @@
{#if data.site_view.local_site.application_question}
<Markdown source={data.site_view.local_site.application_question} />
{/if}
<TextArea
<MarkdownEditor
label="Application"
required
placeholder="i like this instance's icon "
+2 -3
View File
@@ -24,10 +24,8 @@
import { isCommentView } from '$lib/lemmy/item.js'
import { getClient } from '$lib/lemmy.js'
import { isBlocked } from '$lib/lemmy/user.js'
import MultiSelect from '$lib/components/input/MultiSelect.svelte'
import { toast } from '$lib/components/ui/toasts/toasts.js'
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
import TextArea from '$lib/components/input/TextArea.svelte'
import { profile } from '$lib/auth.js'
import { ban, isAdmin } from '$lib/components/lemmy/moderation/moderation.js'
import Menu from '$lib/components/ui/menu/Menu.svelte'
@@ -36,6 +34,7 @@
import { searchParam } from '$lib/util.js'
import Placeholder from '$lib/components/ui/Placeholder.svelte'
import { Button, Modal, Select } from 'mono-svelte'
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
export let data
@@ -122,7 +121,7 @@
<p class="inline-flex flex-row gap-2 items-center">
Sending <UserLink avatar user={data.person_view.person} /> a message
</p>
<TextArea
<MarkdownEditor
bind:value={message}
label="Message"
placeholder="your hair looks nice today"
+4 -4
View File
@@ -2977,10 +2977,10 @@ mlly@^1.2.0, mlly@^1.4.0:
pkg-types "^1.0.3"
ufo "^1.1.2"
mono-svelte@^0.1.5:
version "0.1.5"
resolved "https://registry.yarnpkg.com/mono-svelte/-/mono-svelte-0.1.5.tgz#0306598c171d32b8acebc2350a363ab15e3b7613"
integrity sha512-4Hz9wEPOrlfvJ157YE7agKgJiyh2XHVRmObLD1r27IcRBUmTB/ANdrUBwtyZS9CsSX4RNY1Zpxm2z/g2gsJMgw==
mono-svelte@^0.1.6:
version "0.1.6"
resolved "https://registry.yarnpkg.com/mono-svelte/-/mono-svelte-0.1.6.tgz#2b2bdfea6a52813592658992d0676f9b7a6135e0"
integrity sha512-HcsNhWwdXdCdpEmCa2RsAwJsROGZZy3XRymiLJH+Bglk0bcW+kTO9yRxDCVWqrWu9ac7GRKYvtY54kvLNpdJ6g==
mri@^1.1.0:
version "1.2.0"