adrema/resources/js/components/form/Textarea.vue

105 lines
2.7 KiB
Vue
Raw Normal View History

2021-04-10 19:45:11 +02:00
<template>
<label class="flex flex-col relative">
2023-03-06 23:00:46 +01:00
<span
v-if="label && !inset"
class="font-semibold text-gray-400"
:class="{
'text-xs': size == 'sm',
'text-sm': size === null,
}"
>{{ label }}<span v-show="required" class="text-red-800">&nbsp;*</span></span
>
<span
v-if="label && inset"
class="absolute top-0 left-0 -mt-2 px-1 ml-3 inset-bg font-semibold text-gray-700"
:class="{
'text-xs': size == 'sm',
'text-sm': size === null,
}"
>{{ label }}<span v-show="required" class="text-red-800">&nbsp;*</span></span
>
<textarea
v-text="value"
@input="trigger"
:placeholder="placeholder"
class="h-full outline-none bg-gray-700 border-gray-600 border-solid"
:rows="rows"
2021-04-10 19:45:11 +02:00
:class="{
2021-04-11 17:37:26 +02:00
'rounded-lg text-sm border-2 p-2 text-gray-300': size === null,
2023-03-06 23:00:46 +01:00
'rounded-lg py-2 px-2 text-xs border-2 text-gray-300': size == 'sm',
2021-04-10 19:45:11 +02:00
}"
></textarea>
<div v-if="hint" v-tooltip="hint" class="absolute right-0 top-0 mr-2 mt-2">
2022-02-12 15:22:22 +01:00
<svg-sprite src="info-button" class="w-5 h-5 text-indigo-200"></svg-sprite>
2021-04-10 19:45:11 +02:00
</div>
</label>
</template>
<script>
export default {
2023-03-06 23:00:46 +01:00
data: function () {
2021-04-10 19:45:11 +02:00
return {
2023-03-06 23:00:46 +01:00
focus: false,
2021-04-10 19:45:11 +02:00
};
},
props: {
required: {
type: Boolean,
2023-03-06 23:00:46 +01:00
default: false,
2021-04-10 19:45:11 +02:00
},
inset: {
default: false,
2023-03-06 23:00:46 +01:00
type: Boolean,
2021-04-10 19:45:11 +02:00
},
size: {
2023-03-06 23:00:46 +01:00
default: null,
2021-04-10 19:45:11 +02:00
},
rows: {
2023-03-06 23:00:46 +01:00
default: function () {
2021-04-10 19:45:11 +02:00
return 4;
2023-03-06 23:00:46 +01:00
},
2021-04-10 19:45:11 +02:00
},
id: {
2023-03-06 23:00:46 +01:00
required: true,
2021-04-10 19:45:11 +02:00
},
hint: {
2023-03-06 23:00:46 +01:00
default: null,
2021-04-10 19:45:11 +02:00
},
value: {
2023-03-06 23:00:46 +01:00
default: undefined,
2021-04-10 19:45:11 +02:00
},
mask: {
2023-03-06 23:00:46 +01:00
default: undefined,
2021-04-10 19:45:11 +02:00
},
label: {
2023-03-06 23:00:46 +01:00
default: false,
2021-04-10 19:45:11 +02:00
},
type: {
required: false,
2023-03-06 23:00:46 +01:00
default: function () {
return 'text';
},
2021-04-10 19:45:11 +02:00
},
placeholder: {
2023-03-06 23:00:46 +01:00
default: '',
},
2021-04-10 19:45:11 +02:00
},
methods: {
trigger(v) {
this.$emit('input', v.target.value);
2023-03-06 23:00:46 +01:00
},
2021-04-10 19:45:11 +02:00
},
created() {
if (typeof this.value === 'undefined') {
this.$emit('input', '');
}
2023-03-06 23:00:46 +01:00
},
2021-04-10 19:45:11 +02:00
};
</script>
<style scope>
.inset-bg {
background: linear-gradient(to bottom, hsl(247.5, 66.7%, 97.6%) 0%, hsl(247.5, 66.7%, 97.6%) 41%, hsl(0deg 0% 100%) 41%, hsl(180deg 0% 100%) 100%);
}
</style>