82 lines
1.5 KiB
Vue
82 lines
1.5 KiB
Vue
<script setup lang="ts">
|
|
withDefaults(
|
|
defineProps<{
|
|
placeholder?: string;
|
|
disabled?: boolean;
|
|
readonly?: boolean;
|
|
required?: boolean;
|
|
error?: boolean | string;
|
|
rows?: number;
|
|
maxlength?: number;
|
|
id?: string;
|
|
}>(),
|
|
{
|
|
rows: 3,
|
|
disabled: false,
|
|
readonly: false,
|
|
required: false,
|
|
},
|
|
);
|
|
|
|
const model = defineModel<string>({ default: '' });
|
|
</script>
|
|
|
|
<template>
|
|
<textarea
|
|
:id="id"
|
|
v-model="model"
|
|
class="ui-textarea"
|
|
:class="{ disabled, hasError: !!error }"
|
|
:placeholder="placeholder"
|
|
:disabled="disabled"
|
|
:readonly="readonly"
|
|
:required="required"
|
|
:rows="rows"
|
|
:maxlength="maxlength"
|
|
:aria-invalid="!!error"
|
|
/>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.ui-textarea {
|
|
width: 100%;
|
|
min-width: 0;
|
|
box-sizing: border-box;
|
|
padding: var(--sp-3);
|
|
border: 1px solid var(--line);
|
|
border-radius: var(--radius);
|
|
background: var(--surface);
|
|
color: var(--ink);
|
|
font: inherit;
|
|
font-size: var(--fs-base);
|
|
line-height: var(--lh-normal);
|
|
resize: vertical;
|
|
min-height: 80px;
|
|
transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
|
|
}
|
|
|
|
.ui-textarea::placeholder {
|
|
color: #c0c8d4;
|
|
}
|
|
|
|
.ui-textarea:focus {
|
|
outline: 2px solid var(--accent-soft);
|
|
border-color: var(--accent);
|
|
}
|
|
|
|
.ui-textarea.hasError {
|
|
border-color: var(--danger);
|
|
}
|
|
|
|
.ui-textarea.hasError:focus {
|
|
outline: 2px solid var(--danger-soft);
|
|
border-color: var(--danger);
|
|
}
|
|
|
|
.ui-textarea.disabled {
|
|
background: var(--surface-subtle);
|
|
opacity: 0.65;
|
|
cursor: not-allowed;
|
|
}
|
|
</style>
|