From a9072370ca1eb9a5cce928b1d487db0f307edea6 Mon Sep 17 00:00:00 2001
From: ivarlovlie <git@ivarlovlie.no>
Date: Tue, 20 Sep 2022 15:24:27 +0800
Subject: feat: Move old apps into it's own directory

---
 .../web-shared/src/components/form/textarea.svelte | 48 ++++++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 old-apps/web-shared/src/components/form/textarea.svelte

(limited to 'old-apps/web-shared/src/components/form/textarea.svelte')

diff --git a/old-apps/web-shared/src/components/form/textarea.svelte b/old-apps/web-shared/src/components/form/textarea.svelte
new file mode 100644
index 0000000..b313d2e
--- /dev/null
+++ b/old-apps/web-shared/src/components/form/textarea.svelte
@@ -0,0 +1,48 @@
+<script lang="ts">
+    export let id;
+    export let disabled = false;
+    export let loading = false;
+    export let rows = 2;
+    export let cols = 0;
+    export let name;
+    export let placeholder;
+    export let value;
+    export let label;
+    export let errorText;
+
+    $: shared_props = {
+        rows: rows || null,
+        cols: cols || null,
+        name: name || null,
+        id: id || null,
+        disabled: disabled || null,
+        class: [`form-control ${loading ? "c-disabled loading" : ""}`, $$restProps.class ?? ""].filter(Boolean).join(" "),
+    };
+
+    let textarea;
+    let scrollHeight = 0;
+
+    $:if (textarea) {
+        scrollHeight = textarea.scrollHeight;
+    }
+
+    function on_input(event) {
+        event.target.style.height = "auto";
+        event.target.style.height = (this.scrollHeight) + "px";
+    }
+</script>
+
+{#if label}
+    <label for="{id}"
+           class="form-label margin-bottom-xxs">{label}</label>
+{/if}
+<textarea {...shared_props}
+          {placeholder}
+          style="overflow-y:hidden;min-height:calc(1.5em + .75rem + 2px);{scrollHeight ? 'height:{scrollHeight}px' : ''};"
+          bind:value={value}
+          bind:this={textarea}
+          on:input={on_input}
+></textarea>
+{#if errorText}
+    <small class="color-error">{errorText}</small>
+{/if}
-- 
cgit v1.3

