<!--
 * @Author: gtz
 * @Date: 2021-01-27 10:07:42
 * @LastEditors: gtz
 * @LastEditTime: 2021-03-12 17:07:14
 * @Description: file content
-->
<template>
  <div class="sidebar-logo-container" :class="{ collapse: collapse }">
    <transition name="sidebarLogoFade">
      <router-link v-if="collapse" key="collapse" class="sidebar-logo-link" to="/">
        <img v-if="logo" :src="logo" class="sidebar-logo" />
        <h1 v-else :style="{ fontSize }" class="sidebar-title">{{ 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 :style="{ fontSize }" class="sidebar-title">{{ title }}</h1>
      </router-link>
    </transition>
  </div>
</template>

<script>
export default {
  name: 'SidebarLogo',
  props: {
    collapse: {
      type: Boolean,
      required: true
    },
    title: {
      type: String,
      required: true
    },
    fontSize: {
      type: String,
      required: true
    }
  },
  data() {
    return {
      logo: require('../../../assets/img/cnbm.png')
    }
  }
}
</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: calc(48px * var(--beilv));
  line-height: calc(48px * var(--beilv));
  background: #001529;
  padding-left: calc(10px * var(--beilv));
  overflow: hidden;

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

    & .sidebar-logo {
      width: 26px;
      height: 26px;
      margin-right: 12px;
      // width: calc(26px * var(--beilv));
      // height: calc(26px * var(--beilv));
      // margin-right: calc(12px * var(--beilv));
      vertical-align: middle;
    }

    & .sidebar-title {
      display: inline-block;
      margin: 0;
      color: #fff;
      // width: calc(189px * var(--beilv));
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      font-weight: 500;
      line-height: calc(50px * var(--beilv));
      font-size: calc(14px * var(--beilv));
      font-family: Avenir, Helvetica Neue, Arial, Helvetica, sans-serif;
      vertical-align: middle;
    }
  }

  &.collapse {
    .sidebar-logo {
      margin-right: 0px;
    }
  }
}
</style>
