<script lang="ts">
import Vue from 'vue'

export default Vue.extend({
  name: "index",
  props: {
    video: {
      type: String,
      default: ''
    },
    text: {
      type: String,
      default: ''
    },
    title: {
      type: String,
      default: ''
    },
    placement: {
      type: String,
      default: 'left'
    }
  },
  methods: {
    isPicture(url) {
      return /\.(jpg|jpeg|png|gif)$/.test(url)
    }
  }
})
</script>

<template>
  <el-popover
    popper-class="popover"
    :placement="placement"
    width="400"
    trigger="hover">
    <div class="guide-cont">
      <img :src="video" class="guide-video" v-if="isPicture(video)" />
      <video v-else class="guide-video" autoplay loop :src="video" muted/>
      <div class="title">{{title}}</div>
      <div class="text">{{text}}</div>
    </div>
    <div class="guide" slot="reference">?</div>
  </el-popover>
</template>

<style scoped>
  .guide{
    color: gray;
    cursor: help;
    border-radius: 50%;
    display: inline-block;
    font-weight: bold;
    font-size: 13px;
    width: 16px;
    line-height: 14px;
    text-align: center;
    border: 1px solid gray;
    height: 16px;
  }
  .guide-cont{
    width: 100%;
    .title{
      color: #353535;
      font-size: 22px;
      font-weight: bold;
    }
    .text{
      margin-top: 8px;
    }
    .guide-video{
      mix-blend-mode: darken;
      width: 100%;
      aspect-ratio: 2/1;
    }
  }
</style>
