<template>
  <div class="research-module flex" @click="toDetail(data.id)">
    <div class="research-img">
<!--      <template v-if="isMid">-->
<!--        <div :style="`background: url(${data.cover_image}) no-repeat center/cover content-box; margin-bottom: 10px;`" class="img" alt="The image cannot be displayed properly" />-->
<!--&lt;!&ndash;        <div :style="`background: url(/uploads/20221118/4e49a28329e187226d9305445aca0931.png) no-repeat center/100% 100% content-box`" class="img" alt="The image cannot be displayed properly" />&ndash;&gt;-->
<!--      </template>-->
<!--      <template v-else-if="isSma">-->
<!--        <div :style="`background: url(${data.cover_image}) no-repeat center/cover content-box`" class="img" alt="The image cannot be displayed properly" />-->
<!--      </template>-->
<!--      <template v-else>-->
<!--        <div :style="`background: url(${data.cover_image}) no-repeat center/cover content-box`" class="img" alt="The image cannot be displayed properly" />-->
<!--      </template>-->
      <img :src="data.cover_image" class="img" style="object-fit: cover" alt="The image cannot be displayed properly"/>
      <div class="featured" v-if="data.id < 3">
        Featured
      </div>
    </div>
    <div class="research-info" >
      <div class="research-nav"  v-if="!isSma">
        <div class="wrap flex">
          <div class="research-author" v-html="data.author && data.author.replace(/\\n/g, '<br />')"></div>
          <div class="topics" v-if="!isSma">
            <span class="topic_item" v-for="item in data.topic_names.split(',')">{{ item }}</span>
          </div>
        </div>
        <div class="research-date">{{ transformDate(data.publishedtime) }}</div>
      </div>

      <!-- <div class="topics" v-if="isMid">
        <span class="topic_item" v-for="item in data.topic_names.split(',')">{{ item }}</span>
      </div> -->
      <div class="research-title" v-html="data.title">
      </div>
      <div class="topics" v-if="isSma">
        <span class="topic_item" v-for="item in data.topic_names.split(',')">{{ item }}</span>
      </div>
      <div class="research-content">
        {{ data.description }}
      </div>
      <div class="research-nav" v-show="isSma">
        <div class="research-author">{{ data.author }}</div>
        <div class="research-date">{{ transformDate(data.publishedtime) }}</div>
      </div>
    </div>
  </div>
</template>
<script setup>
import { useRouter } from 'vue-router';
import {transformDate} from "../utils/tools.js";

const router = useRouter()

const props = defineProps({
  type: String,
  data: Object,
  isMid: Boolean,
  isSma: Boolean,
  showDate: Boolean
})

const toDetail = (id) => {
  router.push({ path: '/ContentPages', query: { contentId: id } })
}
</script>
<style lang="scss" scoped>
.research-module {
  margin-top: 36px;
  cursor: pointer;
  .research-img {
    //width: 150px;
    //height: 100px;
    width: 240px;
    height: 160px;
    margin-bottom: 60px;
    margin-right: 20px;
    position: relative;

    .featured {
      width: 60px;
      background: rgba(255, 255, 255, 0.75);
      position: absolute;
      top: 13px;
      left: 0;
      text-align: center;
      line-height: 17px;
      font-family: 'Libre Bodoni';
      font-style: normal;
      font-weight: 400;
      font-size: 14Px;
      color: #FF6D00;
    }

    .img {
      width: 100% !important;
      height: 100% !important;
    }
  }

  .research-info {
    flex: 1;
    .research-nav {
      display: flex;
      justify-content: space-between;

      .research-author {
        font-family: "Raleway";
        font-style: italic;
        font-weight: bolder;
        font-size: 14px;
        line-height: 21px;
        color: #00000080;
        margin-right: 10px;
      }

      .research-date {
        font-family: "Raleway";
        font-style: normal;
        font-weight: bolder;
        font-size: 14px;
        line-height: 21px;
        color: rgba(0, 0, 0, 0.25);
      }
      .wrap{
        align-items: center;
      }

    }
    .topics {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      @media screen and (min-width: 0Px) and (max-width: 431Px)  {
        margin-top: 10px;
      }
    }
    .topic_item {
      padding: 0 20px;
      font-family: Raleway-Semibold;
      color: #FF6D00;
      background: rgba(255, 109, 0, 0.1);
      font-size: 14px;
      line-height: 32px;
      height: 32px;
      display: block;
      &:first-child{
        margin-left: 0;

      }
    }
    .research-title {
      font-family: "Libre Bodoni";
      font-style: normal;
      font-weight: 400;
      font-size: 24px;
      line-height: 24px;
      text-overflow: ellipsis;
      margin-top: 6px;
    }

    .research-content {
      // height: 60px;
      margin-top: 14px;
      font-family: 'Raleway';
      font-style: normal;
      font-weight: 400;
      font-size: 12px;
      line-height: 16px;
      overflow: hidden;
      color: #000000bf;
      display: -webkit-box;
      overflow: hidden;
      white-space: normal !important;
      text-overflow: ellipsis;
      word-wrap: break-word;
      -webkit-line-clamp: 3;
      -webkit-box-orient: vertical;
    }
  }
}

@media (max-width: 1280Px) {
  .research-author {
    font-size: 14px !important;
  }
  .topic_item {
    font-size: 12px !important;
    height: 26px !important;
    line-height: 26px !important;
  }
  .research-module {
    margin-top: 36px !important;
    .research-img {
      width: 170px !important;
      height: 106px !important;
      margin-bottom: 40px !important;
    }
    .research-title {
      margin-top: 3px !important;
      font-size: 14px !important;
    }
    .research-content {
      margin-top: 6px !important;
      font-size: 12px !important;
    }
  }

}


@media (max-width: 767Px) {
  .research-module {
    flex-direction: column !important;
    .research-img {
      width: 100% !important;
      height: 190px !important;
      margin-bottom: 2px !important;
    }
    .research-info {
      width: 100% !important;
      .topics {
        width: 100% !important;
        margin-top: 2px !important;
      }
      .research-content {
        width: 100% !important;
      }
      .research-nav {
        margin-top: 2px !important;
        width: 100% !important;
      }
    }

  }
}
// @media screen and (min-width: 1440Px) and (max-width: 100vw) {

//   .research-module {
//     .research-img {
//       width: 400Px;
//       height: 200Px;
//       flex-shrink: 0;
//       //margin-right: 0 !important;
//       .img {
//         width: 100%;
//         height: 100%;
//       }
//     }

//   }
//   .research-author,
//   .research-date {
//     font-size: 24Px !important;
//   }

//   .research-title {
//     margin-top: 6px !important;
//     font-size: 24px !important;
//   }

//   .research-content {
//     margin-top: 14px !important;
//     font-size: 16Px !important;
//     line-height: 24Px !important;
//     -webkit-line-clamp: 4 !important;
//   }

//   .featured {
//     width: 60px;
//     top: 13px;
//     font-size: 14Px;
//     line-height: 14px;
//   }
// }

// @media screen and (min-width: 0Px) and (max-width: 431Px) {
//   .research-module {
//     display: block;
//     // width: 353Px !important;

//     .research-img {
//       width: 100% !important;
//       height: 100% !important;

//       .img {
//         width: 100% !important;
//         height: 4.5rem !important;
//       }
//     }
//   }

//   .research-title {
//     margin: 12px 0 0 !important;
//     width: 327px !important;
//   }

//   .research-content {
//     margin: 14px 0 0 !important;
//     width: 327px !important;
//   }

//   .research-info {
//     margin: 30px 0 !important;
//     width: 327px !important;
//   }

//   .featured {
//     width: 80px !important;
//     top: 13px;
//     right: 0;
//     font-size: 12Px;
//     line-height: 22px !important;
//   }
// }
</style>
