char count for textarea (#94)
Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
parent
29c09d9ea2
commit
5a1bd0e0c6
|
@ -11,10 +11,17 @@
|
||||||
class="resize-y"
|
class="resize-y"
|
||||||
:name="name" :style="inputStyle"
|
:name="name" :style="inputStyle"
|
||||||
:placeholder="placeholder"
|
:placeholder="placeholder"
|
||||||
|
:maxlength="maxCharLimit"
|
||||||
/>
|
/>
|
||||||
<small v-if="help" :class="theme.default.help">
|
<div v-if="help || showCharLimit" class="flex">
|
||||||
|
<small v-if="help" :class="theme.default.help" class="flex-grow">
|
||||||
<slot name="help">{{ help }}</slot>
|
<slot name="help">{{ help }}</slot>
|
||||||
</small>
|
</small>
|
||||||
|
<small v-else class="flex-grow"></small>
|
||||||
|
<small v-if="showCharLimit && maxCharLimit" :class="theme.default.help">
|
||||||
|
{{ charCount }}/{{ maxCharLimit }}
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
<has-error v-if="hasValidation" :form="form" :field="name" />
|
<has-error v-if="hasValidation" :form="form" :field="name" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -24,6 +31,16 @@ import inputMixin from '~/mixins/forms/input.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'TextAreaInput',
|
name: 'TextAreaInput',
|
||||||
mixins: [inputMixin]
|
mixins: [inputMixin],
|
||||||
|
|
||||||
|
props: {
|
||||||
|
maxCharLimit: { type: Number, required: false, default: null },
|
||||||
|
showCharLimit: { type: Boolean, required: false, default: false },
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
charCount() {
|
||||||
|
return (this.compVal) ? this.compVal.length : 0
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue