From 438b277be033c401ae23a35f83bbd3717324ee03 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sun, 20 Oct 2024 19:04:30 -0700 Subject: [PATCH] refac: styling --- src/lib/components/common/Textarea.svelte | 13 +++++++------ .../(app)/workspace/prompts/create/+page.svelte | 9 +++++---- .../(app)/workspace/prompts/edit/+page.svelte | 9 +++++---- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/lib/components/common/Textarea.svelte b/src/lib/components/common/Textarea.svelte index 78f07450a..f0c4691b2 100644 --- a/src/lib/components/common/Textarea.svelte +++ b/src/lib/components/common/Textarea.svelte @@ -4,6 +4,9 @@ export let value = ''; export let placeholder = ''; + export let rows = 1; + export let required = false; + export let className = 'w-full rounded-lg px-3 py-2 text-sm bg-gray-50 dark:text-gray-300 dark:bg-gray-850 outline-none resize-none h-full'; @@ -12,7 +15,7 @@ onMount(async () => { await tick(); if (textareaElement) { - setInterval(adjustHeight, 0); + setTimeout(adjustHeight, 0); } }); @@ -28,10 +31,8 @@ bind:this={textareaElement} bind:value {placeholder} + on:input={adjustHeight} class={className} - on:input={(e) => { - e.target.style.height = ''; - e.target.style.height = `${e.target.scrollHeight}px`; - }} - rows="1" + {rows} + {required} /> diff --git a/src/routes/(app)/workspace/prompts/create/+page.svelte b/src/routes/(app)/workspace/prompts/create/+page.svelte index 7b053680e..5af9b1186 100644 --- a/src/routes/(app)/workspace/prompts/create/+page.svelte +++ b/src/routes/(app)/workspace/prompts/create/+page.svelte @@ -6,6 +6,7 @@ import { onMount, tick, getContext } from 'svelte'; import { createNewPrompt, getPrompts } from '$lib/apis/prompts'; + import Textarea from '$lib/components/common/Textarea.svelte'; const i18n = getContext('i18n'); @@ -114,7 +115,7 @@
{ submitHandler(); }} @@ -170,11 +171,11 @@
-