<template>
  <a
    :href="data.link"
    rel="nofollow"
    target="_blank"
    class="review"
    :class="direction">
    <div class="top">
      <div class="stars">
        <img v-for="i in 5" :key="i" v-lazy="starIcon" width="25" height="25" />
      </div>
      <div class="date">{{ data.date }}</div>
    </div>
    <h3 class="content" v-html="data.content"></h3>
    <div class="images">
      <div class="avatar">
        <img v-lazy="{ src: data.customerAvatar }" :alt="data.customerName" />
      </div>
      <div class="platform-icon">
        <img v-lazy="{ src: data.platformIcon }" />
      </div>
    </div>
    <div class="customer-name">{{ data.customerName }}</div>
    <div class="customer-position">{{ data.customerPosition }}</div>
    <div class="bottom">
      <div class="industry">{{ data.industry }}</div>
      <ArrowLink class="read-full">Read Full Review</ArrowLink>
    </div>
  </a>
</template>

<script lang="ts">
import { defineComponent, PropType } from 'vue';
import { IFeedbackGrid } from '@/components/sections/FeedbackGrid/FeedbackGrid.types';
import ArrowLink from '@/components/ui/ArrowLink.vue';
import starIcon from '@/assets/img/static-icons/star.svg?url';

export default defineComponent({
  components: { ArrowLink },

  props: {
    direction: {
      type: String as PropType<'horizontal' | 'vertical'>,
      default: 'horizontal',
    },
    data: {
      type: Object as PropType<IFeedbackGrid.Review>,
      required: true,
    },
  },

  data: () => ({
    starIcon,
  }),
});
</script>

<style lang="scss" scoped>
.review {
  height: 380px;
  padding: 32px;

  background: #ffffff;
  border-radius: 16px;

  &.vertical {
    height: 560px;
  }

  &:hover {
    .read-full {
      color: #ff5f21;
    }
  }
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;

  column-gap: 10px;

  .vertical & {
    margin-bottom: 32px;
  }

  .stars {
    display: flex;
    flex: 1;
    justify-content: space-between;
    max-width: 155px;

    color: #ff5f21;
  }

  .date {
    color: #b1b2b4;
    font-weight: 500;
    font-size: 14px;
    line-height: 100%;
    white-space: nowrap;
  }
}

.content {
  position: relative;
  z-index: 2;

  max-width: 280px;
  margin-bottom: 40px;

  color: #b1b2b4;
  font-weight: bold;
  font-size: 32px;
  line-height: 136%;
  letter-spacing: -0.01em;

  .horizontal & {
    max-width: 360px;
    margin-bottom: 0;
  }
}

.images {
  position: relative;
  top: -25px;

  display: flex;
  justify-content: flex-end;
  margin-bottom: -35px;

  .vertical & {
    position: static;

    margin-top: 14px;
    margin-bottom: 45px;
  }
}

.avatar,
.platform-icon {
  width: 80px;
  height: 80px;

  .vertical & {
    width: 104px;
    height: 104px;
  }

  img {
    width: 100%;
    height: 100%;
  }
}

.avatar {
  z-index: 1;

  margin-right: -13px;
  margin-left: 20px;
}

.customer-name {
  margin-bottom: 6px;

  color: #242628;
  font-weight: bold;
  font-size: 24px;
  line-height: 132%;
}

.customer-position {
  margin-bottom: 12px;

  color: #3c3d3e;
  font-size: 14px;
  line-height: 100%;
}

.bottom {
  display: flex;
  justify-content: space-between;

  .vertical & {
    flex-direction: column;
    row-gap: 40px;
  }

  .industry {
    color: #b1b2b4;
    font-size: 14px;
    line-height: 100%;
  }

  .read-full {
    color: #b1b2b4;
  }
}
</style>
