<template>
  <AppCard title="优秀师资">
    <swiper ref="mySwiper" :options="swiperOptions" class="teacher-list">
      <swiper-slide v-for="(item, index) in list" :key="index" class="teacher-item">
        <div class="teacher-item-inner">
          <img :src="item.imgUrl" />
          <p>{{ item.name }}</p>
        </div>
        <div class="teacher-item-cover">
          <h3>{{ item.name }}</h3>
          <p>{{ item.project }} | {{ item.title }}</p>
          <div v-html="item.desc"></div>
        </div>
      </swiper-slide>
    </swiper>
  </AppCard>
</template>
<script>
import AppCard from '@/components/AppCard.vue'
export default {
  name: 'TeacherCard',
  props: { list: { type: Array, default: () => [] } },
  components: { AppCard },
  data() {
    return {
      swiperOptions: {
        autoplay: true,
        loop: true,
        slidesPerView: 'auto',
        spaceBetween: 20
      }
    }
  }
}
</script>

<style lang="scss">
.teacher-list {
  margin-bottom: 60px;
}
.teacher-item {
  position: relative;
  width: 286px;
  height: 258px;
  &:hover {
    .teacher-item-cover {
      transform: translateY(0);
    }
  }
}
.teacher-item-inner {
  position: relative;
  height: 100%;
  img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
  p {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0 20px;
    height: 34px;
    font-size: 16px;
    line-height: 34px;
    color: #ffffff;
    background: rgba(0, 0, 0, 0.39);
  }
}
.teacher-item-cover {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  background: #a81840;
  color: #fff;
  padding: 10px;
  transform: translateY(100%);
  transition: all 0.3s;
  h3 {
    font-size: 20px;
    font-weight: 500;
    line-height: 28px;
    text-align: center;
  }
  p {
    margin-top: 8px;
    margin-bottom: 20px;
    text-align: center;
  }
}
</style>
