Skip to content

Commit 4511b9a

Browse files
committed
Add AppTextArea Vue Component
1 parent 15d04ec commit 4511b9a

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<template>
2+
<textarea
3+
ref="textarea"
4+
placeholder="Enter your message here"
5+
class="text-skin-base-neutral-12 focus:ring-skin-primary-focus mt-1 block w-full rounded-md border-0 bg-skin-neutral-1 px-3 py-2 placeholder-skin-neutral-9 shadow-sm ring-1 ring-inset ring-skin-neutral-7 focus:ring-2 focus:ring-inset sm:text-sm sm:leading-6"
6+
:class="{ 'overflow-y-hidden': autoResize }"
7+
:value="modelValue"
8+
@input="handleInput"
9+
></textarea>
10+
</template>
11+
12+
<script setup>
13+
import { ref, onMounted } from 'vue'
14+
15+
const props = defineProps({
16+
modelValue: {
17+
type: String,
18+
required: true
19+
},
20+
autoResize: {
21+
type: Boolean,
22+
default: true
23+
}
24+
})
25+
26+
onMounted(() => {
27+
if (props.autoResize) {
28+
resizeTextarea()
29+
}
30+
})
31+
32+
const emit = defineEmits(['update:modelValue'])
33+
const textarea = ref(null)
34+
35+
function handleInput() {
36+
const value = textarea.value.value
37+
emit('update:modelValue', value)
38+
if (props.autoResize) {
39+
resizeTextarea()
40+
}
41+
}
42+
43+
function resizeTextarea() {
44+
if (textarea.value) {
45+
textarea.value.style.height = `${textarea.value.scrollHeight}px`
46+
}
47+
}
48+
</script>
49+
50+
<style scoped>
51+
* {
52+
scrollbar-width: thin;
53+
scrollbar-color: theme('colors.skin.neutral.7')
54+
theme('colors.skin.neutral.1');
55+
}
56+
57+
::-webkit-scrollbar {
58+
background-color: theme('colors.skin.neutral.1');
59+
}
60+
61+
::-webkit-scrollbar-corner {
62+
background-color: theme('colors.skin.neutral.1');
63+
}
64+
65+
::-webkit-scrollbar-corner,
66+
::-webkit-scrollbar-track {
67+
background-color: theme('colors.skin.neutral.7');
68+
}
69+
70+
::-webkit-scrollbar-thumb {
71+
background-color: theme('colors.skin.neutral.1');
72+
border-radius: 20px;
73+
border: 3px solid theme('colors.skin.neutral.7');
74+
}
75+
</style>

stubs/resources/js/Resolvers/AppComponentsResolver.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const componentGroups = {
1717
'AppInputText',
1818
'AppLabel',
1919
'AppRadioButton',
20+
'AppTextArea',
2021
'AppTipTapEditor'
2122
],
2223
Menu: [

0 commit comments

Comments
 (0)