<template>
  <div class="text" :style="_style">
    <el-popover
      placement="right"
      width="400"
      trigger="click"
      :disabled="!edit"
    >
      <el-form label-position="left" label-width="100px" style="padding:20px 10px 0 10px" size="mini">
        <el-form-item label="文字大小">
          <el-slider
            v-model="item.css.fontSize"
            show-input
            :min="12"
            :max="50"
          />
        </el-form-item>
        <el-form-item label="对齐方式">
          <el-radio-group v-model="item.css.textAlign">
            <el-radio label="left" value="left">左边</el-radio>
            <el-radio label="center" value="center">居中</el-radio>
            <el-radio label="right" value="right">居右</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="文字颜色">
          <el-color-picker v-model="item.css.color" />
        </el-form-item>
      </el-form>

      <div slot="reference" style="min-font-size: 12px">
        自定义文字
      </div>
    </el-popover>
  </div>
</template>

<script>
export default {
  name: 'DkPosterViewText',
  props: {
    item: {
      default: () => {
        return {}
      },
      type: Object
    },
    edit: {
      default: false, type: Boolean
    }
  },
  data() {
    return {
    }
  },
  computed: {
    _style() {
      var css = this.item.css
      return {
        fontSize: css.fontSize + 'px',
        color: css.color,
        textAlign: css.textAlign
      }
    }
  },
  mounted() {
    var css = this.item.css
    if (!css.textAlign) {
      this.$set(css, 'textAlign', 'left')
    }
  },
  methods: {}
}
</script>

<style scoped lang="scss">

</style>
