all files / src/textField/ textFieldLabel.vue

0% Statements 0/8
0% Branches 0/4
100% Functions 0/0
0% Lines 0/6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61                                                                                                                         
<template>
<div class="mu-text-field-label" :class="labelClass">
  <slot></slot>
</div>
</template>
 
<script>
import {convertClass} from '../utils'
export default {
  props: {
    focus: {
      type: Boolean,
      default: false
    },
    float: {
      type: Boolean,
      default: false
    },
    normalClass: {
      type: [String, Object, Array]
    },
    focusClass: {
      type: [String, Object, Array]
    }
  },
  computed: {
    labelClass () {
      const {float, focus, normalClass, focusClass} = this
      let classNames = []
      if (float) classNames.push('float')
      classNames = classNames.concat(convertClass(normalClass))
      if (focus) classNames = classNames.concat(convertClass(focusClass))
      return classNames
    }
  }
}
</script>
 
<style lang="less">
@import "../styles/import.less";
.mu-text-field-label {
  line-height: 20px;
  transition: all .45s @easeOutFunction;
  z-index: 1;
  cursor: text;
  transform: translate3d(0, 0, 0) scale(0.75);
  transform-origin: left top;
  user-select: none;
  pointer-events: none;
  backface-visibility: hidden;
  .mu-text-field.has-label & {
    top: 8px;
    position: absolute;
  }
  .mu-text-field.has-label &.float {
    transform: translate3d(0, 28px, 0) scale(1);
    color: @disabledColor;
  }
}
</style>