rudeshark.net/src/client/app/common/views/components/ui/textarea.vue

128 lines
2.1 KiB
Vue
Raw Normal View History

2018-06-13 23:29:01 +02:00
<template>
2018-06-14 07:52:37 +02:00
<div class="ui-textarea" :class="{ focused, filled }">
2018-06-13 23:29:01 +02:00
<div class="input">
<span class="label" ref="label"><slot></slot></span>
2018-06-14 07:52:37 +02:00
<textarea ref="input"
2018-06-14 02:51:55 +02:00
:value="value"
:required="required"
:readonly="readonly"
2018-06-14 07:52:37 +02:00
:pattern="pattern"
:autocomplete="autocomplete"
2018-06-14 02:51:55 +02:00
@input="$emit('input', $event.target.value)"
@focus="focused = true"
@blur="focused = false">
2018-06-14 07:52:37 +02:00
</textarea>
2018-06-13 23:29:01 +02:00
</div>
2018-06-14 02:51:55 +02:00
<div class="text"><slot name="text"></slot></div>
2018-06-13 23:29:01 +02:00
</div>
</template>
<script lang="ts">
import Vue from 'vue';
2018-06-14 07:52:37 +02:00
const getPasswordStrength = require('syuilo-password-strength');
2018-06-13 23:29:01 +02:00
export default Vue.extend({
2018-06-14 02:51:55 +02:00
props: {
value: {
required: false
},
required: {
type: Boolean,
required: false
},
readonly: {
type: Boolean,
required: false
2018-06-14 07:52:37 +02:00
},
pattern: {
type: String,
required: false
},
autocomplete: {
type: String,
required: false
2018-06-14 02:51:55 +02:00
}
},
2018-06-13 23:29:01 +02:00
data() {
return {
2018-06-14 07:52:37 +02:00
focused: false,
passwordStrength: ''
2018-06-13 23:29:01 +02:00
}
},
computed: {
filled(): boolean {
return this.value != '' && this.value != null;
}
},
methods: {
focus() {
this.$refs.input.focus();
}
}
});
</script>
<style lang="stylus" scoped>
@import '~const.styl'
2018-06-14 07:52:37 +02:00
.ui-textarea
margin 32px 0
2018-06-13 23:29:01 +02:00
> .input
2018-06-14 07:52:37 +02:00
padding 12px
2018-06-14 02:51:55 +02:00
background rgba(#000, 0.035)
2018-06-14 00:22:50 +02:00
border-radius 6px
2018-06-13 23:29:01 +02:00
> .label
position absolute
2018-06-14 00:22:50 +02:00
top 6px
2018-06-14 07:52:37 +02:00
left 12px
2018-06-13 23:29:01 +02:00
pointer-events none
transition 0.4s cubic-bezier(0.25, 0.8, 0.25, 1)
transition-duration 0.3s
font-size 16px
line-height 32px
color rgba(#000, 0.54)
pointer-events none
2018-06-14 07:52:37 +02:00
//will-change transform
transform-origin top left
transform scale(1)
2018-06-13 23:29:01 +02:00
2018-06-14 07:52:37 +02:00
> textarea
2018-06-13 23:29:01 +02:00
display block
width 100%
2018-06-14 07:52:37 +02:00
min-height 100px
2018-06-13 23:29:01 +02:00
padding 0
2018-06-14 00:22:50 +02:00
font inherit
font-weight bold
2018-06-13 23:29:01 +02:00
font-size 16px
background transparent
border none
border-radius 0
outline none
box-shadow none
2018-06-14 02:51:55 +02:00
> .text
2018-06-14 07:52:37 +02:00
margin 6px 0
font-size 13px
2018-06-14 02:51:55 +02:00
2018-06-14 07:52:37 +02:00
*
2018-06-14 02:51:55 +02:00
margin 0
2018-06-13 23:29:01 +02:00
&.focused
> .input
2018-06-14 02:51:55 +02:00
background rgba(#000, 0.05)
2018-06-13 23:29:01 +02:00
> .label
color $theme-color
&.focused
&.filled
> .input
> .label
2018-06-14 07:52:37 +02:00
top -24px
2018-06-13 23:29:01 +02:00
left 0 !important
2018-06-14 07:52:37 +02:00
transform scale(0.8)
2018-06-13 23:29:01 +02:00
</style>