<template>
   <div class="courseMenuCollapse">
      <div
         class="courseMenuItem"
         :class="item.useFlag ? 'current' : ''"
         v-for="item in props.courseMenuList"
         :key="item.id"
         :name="item.id"
         @click="handleClick(item)"
      >
         <div class="cover">
            <img :src="item.coverImg" />
            <div class="current" v-if="item.useFlag">当前</div>
         </div>
         <div class="text">
            <ellipsisScroll :autoScroll="item.useFlag" :title="item.lessonCoursewareName" />
         </div>
      </div>
   </div>
</template>

<script lang="ts" setup>
// import { ref, watch } from "vue"
type courseMenuListType = {
   id: string
   lessonCoursewareId: string
   lessonCoursewareName: string
   coverImg: string
   courseTypeCode: string
   lockFlag: boolean | null
   useFlag: boolean
}[]

const props = defineProps<{
   courseMenuList: courseMenuListType
}>()

const emits = defineEmits<{
   (e: "handleClick", value: any): void
}>()
function handleClick(value: any) {
   emits("handleClick", value)
}
</script>

<style lang="scss" scoped>
.courseMenuCollapse {
   display: flex;
   flex-wrap: wrap;

   .courseMenuItem {
      width: 89px;
      margin-top: 24px;
      margin-left: 24px;
      box-sizing: content-box;
      cursor: pointer;
      &.current {
         .text {
            color: #131415;
         }
      }
      .cover {
         position: relative;
         width: 100%;
         height: 110px;
         &::before {
            position: absolute;
            top: 0;
            left: 0;
            bottom: 0;
            z-index: 9;
            content: "";
            width: 4px;
            height: 100%;
            background: url("@/img/coursewarePlay/book-cover-line.png");
         }
         img {
            width: inherit;
            height: inherit;
         }
         .current {
            position: absolute;
            top: 4px;
            left: 4px;
            z-index: 9;
            background: rgba(0, 0, 0, 0.5);
            border-radius: 3px;
            font-weight: 500;
            font-size: 13px;
            color: #ffffff;
            line-height: 17px;
            padding: 0 5px;
         }
      }
      .text {
         padding-top: 6px;
         font-weight: 600;
         font-size: 14px;
         color: rgba(0, 0, 0, 0.5);
         line-height: 20px;
         overflow: hidden;
      }
   }
}
</style>
