feat: inherit attrs to Textarea + fix Input label color (#245)

* feat: add more attributes to Textarea

* refactor: use `inheritAttrs` option to simplify code

* fix: `Input` label color in dark mode
This commit is contained in:
WangYK
2023-11-21 19:22:25 +08:00
committed by GitHub
parent 67091e1d90
commit a4a717f4e0
7 changed files with 147 additions and 18 deletions

View File

@@ -55,7 +55,7 @@ export function useInputClasses (props: UseInputClassesProps): {
? 'text-green-700 dark:text-green-500'
: vs === validationStatusMap.Error
? 'text-red-700 dark:text-red-500'
: 'text-gray-900 dark:text-gray-300'
: 'text-gray-900 dark:text-white'
return twMerge(baseLabelClasses, classByStatus)
})

View File

@@ -4,8 +4,9 @@
<span :class="wrapperClasses">
<textarea
v-model="model"
:rows="rows"
v-bind="$attrs"
:class="textareaClasses"
:rows="rows"
:placeholder="placeholder"
/>
<span
@@ -23,13 +24,17 @@ import { computed } from 'vue'
import { useTextareaClasses } from './composables/useTextareaClasses'
interface TextareaProps {
modelValue?: string;
label?: string;
rows?: number;
custom?: boolean;
placeholder?: string;
modelValue?: string
label?: string
rows?: number
custom?: boolean
placeholder?: string
}
defineOptions({
inheritAttrs: false,
})
const props = withDefaults(defineProps<TextareaProps>(), {
modelValue: '',
label: 'Your message',
@@ -48,10 +53,5 @@ const model = computed({
},
})
const {
textareaClasses,
labelClasses,
wrapperClasses,
footerClasses,
} = useTextareaClasses(props.custom)
const { textareaClasses, labelClasses, wrapperClasses, footerClasses } = useTextareaClasses(props.custom)
</script>