<template>
<div class="folder">
  <div class="folder-icon">
    <img v-if="folder.img" :src="folder.img" alt=""/>
    <img v-else src="../../../static/img/folder_pic.png" alt=""/>
  </div>
  <p class="folder-name">{{ folder.name }}</p>
</div>
</template>
<script>
export default {
  name: 'folder-item',
  props: {
    folder: Object
  }
}
</script>
<style lang="scss" scoped>
.folder {
  position: relative;
  margin: 0 15px 15px 0;
  padding: 10px 10px 47px 10px;
  width: 120px;
  height: 120px;
  border-radius: 2px;
  border: 1px solid #e4e7ed;
  .folder-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    width: 100px;
    height: 100px;
    background-color: #f5f5f8;
    img {
      max-width: 100%;
      max-height: 100%;
    }
  }
  .folder-name {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1;
    margin: 0;
    width: 100%;
    height: 37px;
    font-size: 14px;
    line-height: 37px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  &:hover .folder-name {
    background-color: #f0f2f5;
  }
}
</style>
