<template>
  <div class="ImgBlock">
    <vimi-title-bar/>
    <div class="img-box">
      <div class="img" :style="{'background-image':`url(${form.img})`}"/>
    </div>

    <div class="img-footer">
      <span class="img-name" :title="form.name">{{form.name}}</span>
      <div class="slot-tool"></div>
      <vimi-popper :append-to-body="true" :visible-arrow="true" trigger="hover" :options="{
      placement:'bottom'
    }">
        <div  class="popper">
          <slot></slot>
        </div>
        <div class="tool-btn"  slot="reference">
          ...
        </div>
      </vimi-popper>
    </div>
  </div>
</template>

<script>
import VimiTitleBar from "../TitleBar/vimiTitleBar";
export default {
  name: "vimiTableTile",
  components: {VimiTitleBar},
  model: {
    prop: 'value',
    event: 'input'
  },
  props: {
    value: {
      type: Object,
      default: () => {
        return {img: '',name:'名称'}
      }
    },
  },
  data() {
    return {
      form: this.value
    }
  }
}
</script>

<style scoped lang="scss">
.ImgBlock {
  width: 100%;
  margin: 5px auto;
  height: fit-content;
  padding: 8px;
  box-sizing: border-box;
  cursor: pointer;
  background: rgb(27, 28, 28);
  position: relative;
  border-radius: 5px;
  overflow: visible;

  .img-box {
    width: 100%;
    box-sizing: border-box;
    padding: 5%;
    background-color:#18181c ;
    background-image:  linear-gradient(#18181c 14px, transparent 0), linear-gradient(90deg, transparent 14px, #474953 0);
    background-size: 16px 16px;

    .img {
      width: 100%;
      height: 0;
      padding: 0 0 55% 0;
      background-size: 100% 100%;
    }
  }

  .img-footer {
    margin-top: 5px;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 5px 0;

    .img-name {
      vertical-align: middle;
      width: 50%;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      cursor: default;
      &:before{
        content: '';
        width: 0px;
        height: 100%;
        display: inline-block;
        vertical-align: middle;
      }
    }

    .slot-tool {
      flex: 1;
      vertical-align: middle;
    }

    .tool-btn {
      position: relative;
      vertical-align: middle;
      width: 58px;
      box-sizing: border-box;
      border: 1px solid #4c4c4c;
      border-radius: 5px;
      color: white;
      font-size: 24px;
      height: 32px;
      text-align: center;
      line-height: 17px;

    }
  }
  .btn-panel{
    font-size: 12px;
    position: absolute;
    bottom:-12px;
    right: 0;
    width: 58px;
    border: 1px solid #575252;
    padding: 5px;
    z-index: 4;
  }
}
</style>
