refac: banners

This commit is contained in:
Timothy Jaeryang Baek
2025-07-02 13:48:18 +04:00
parent bab7a65c2c
commit 7e273ebe86
3 changed files with 29 additions and 12 deletions
+11 -3
View File
@@ -5,6 +5,7 @@
export let placeholder = '';
export let rows = 1;
export let minSize = null;
export let maxSize = null;
export let required = false;
export let className =
'w-full rounded-lg px-3.5 py-2 text-sm bg-gray-50 dark:text-gray-300 dark:bg-gray-850 outline-hidden h-full';
@@ -30,9 +31,16 @@
const resize = () => {
if (textareaElement) {
textareaElement.style.height = '';
textareaElement.style.height = minSize
? `${Math.max(textareaElement.scrollHeight, minSize)}px`
: `${textareaElement.scrollHeight}px`;
let height = textareaElement.scrollHeight;
if (maxSize && height > maxSize) {
height = maxSize;
}
if (minSize && height < minSize) {
height = minSize;
}
textareaElement.style.height = `${height}px`;
}
};
</script>