<template>
  <div class="sidebar-logo-container" :class="{'collapse':collapse}" :style="{ backgroundColor: sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground }">
    <el-popover
      placement="right"
      popper-class='tooltips'
      visible-arrow="true"
      trigger="hover">
      <div>
        <img :src="logo" class="tips_logo" />
        <div class="tips_title">{{title}}</div>
      </div>
      <transition name="sidebarLogoFade" slot="reference">
        <router-link v-if="collapse" key="collapse" class="sidebar-logo-link" to="/">
          <img v-if="logo" :src="logo" class="sidebar-logo" />
          <h1 v-else class="sidebar-title" :style="{ color: sideTheme === 'theme-dark' ? variables.logoTitleColor : variables.logoLightTitleColor }">{{ title }} </h1>
        </router-link>
        <router-link v-else key="expand" class="sidebar-logo-link" to="/">
          <img v-if="logo" :src="logo" class="sidebar-logo" />
          <h1 class="text-cl1 sidebar-title" :style="{ width: '98px', color: sideTheme === 'theme-dark' ? variables.logoTitleColor : variables.logoLightTitleColor }">{{ title }} </h1>
        </router-link>
      </transition>
    </el-popover>
  </div>
</template>

<script>
import logoImg from '@/assets/images/logo/logo.png'
import variables from '@/assets/styles/variables.scss'

export default {
  name: 'SidebarLogo',
  props: {
    collapse: {
      type: Boolean,
      required: true
    }
  },
  computed: {
    variables() {
      return variables;
    },
    sideTheme() {
      return this.$store.state.settings.sideTheme
    }
  },
  data() {
    return {
      title: '数字化经营履约全生命链路管理系统',
      logo: logoImg
    }
  }
}
</script>

<style lang="scss" scoped>
.sidebarLogoFade-enter-active {
  transition: opacity 1.5s;
}

.sidebarLogoFade-enter,
.sidebarLogoFade-leave-to {
  opacity: 0;
}

.sidebar-logo-container {
  position: relative;
  width: 100%;
  height: 55px;
  line-height: 55px;
  background: #141b2f;
  border-bottom: 1px solid #1a2743;
  text-align: center;
  /*overflow: hidden;*/

  & .sidebar-logo-link {
    height: 100%;
    width: 100%;

    & .sidebar-logo {
      width: 16px;
      height: 23px;
      vertical-align: middle;
      margin-right: 3px;
    }

    & .sidebar-title {
      display: inline-block;
      margin: 0;
      color: #fff;
      font-weight: 600;
      line-height: 50px;
      font-size: 14px;
      font-family: Avenir, Helvetica Neue, Arial, Helvetica, sans-serif;
      vertical-align: middle;
    }
  }

  &.collapse {
    .sidebar-logo {
      margin-right: 0px;
    }
  }
}
.tooltips{

}
</style>
<style lang="scss">
  .tooltips.el-popover{
    min-width: 96px!important;
    width: 96px;
    padding: 0;
    .tips_logo{
      display: block;
      margin: 17px auto 8px;
    }
    .tips_title{
      font-family: MicrosoftYaHei-Regular, MicrosoftYaHei;
      color: #232323;
      line-height: 28px;
      width: 192px;
      font-size:22px;
      transform:scale(0.5);
      -webkit-transform:scale(0.5);
      padding: 0 16px;
      float: left;
      margin-top: -14px;
      margin-left: -48px;
      text-align: center;
    }
  }
  .tooltips.el-popper {
    .popper__arrow{
    display: block !important;
    }
  }
  .tooltips.el-popper[x-placement^=right]{
    margin-left: 3px !important;
  }
</style>
