<template>
  <div class="unnnic-banner-info">
    <section class="unnnic-banner-info__section">
      <div class="unnnic-banner-info__title">{{ firstTitle }}</div>
      <div class="unnnic-banner-info__description">{{ firstDescription }}</div>
    </section>
    <div class="unnnic-banner-info__divider" />
    <section class="unnnic-banner-info__section">
      <div class="unnnic-banner-info__title">{{ secondTitle }}</div>
      <div class="unnnic-banner-info__description">{{ secondDescription }}</div>
      <div class="unnnic-banner-info__subtitle">{{ subtitle }}</div>
    </section>
    <div class="unnnic-banner-info__divider" />
    <section class="unnnic-banner-info__section">
      <div class="unnnic-banner-info__title">{{ thirdTitle }}</div>
      <div class="unnnic-banner-info__description">{{ thirdDescription }}</div>
      <div class="unnnic-banner-info__rating">
        <UnnnicIcon
          v-for="index in 5"
          :key="index"
          :class="{
            'unnnic-banner-info__rating__star': true,
            'unnnic-banner-info__rating__star__active': index <= baseRating,
          }"
          :scheme="starScheme(index)"
          icon="rating-star-1"
          size="ant"
          @click="emitRatingAction(index)"
          @mouseover="starOver(index)"
          @mouseout="starOut"
        />
      </div>
    </section>
  </div>
</template>

<script>
import UnnnicIcon from '../Icon.vue';

export default {
  name: 'UnnnicBanner',
  components: { UnnnicIcon },
  props: {
    firstTitle: {
      type: String,
      default: null,
    },
    secondTitle: {
      type: String,
      default: null,
    },
    thirdTitle: {
      type: String,
      default: null,
    },
    firstDescription: {
      type: String,
      default: null,
    },
    secondDescription: {
      type: String,
      default: null,
    },
    thirdDescription: {
      type: String,
      default: null,
    },
    subtitle: {
      type: String,
      default: null,
    },
    rating: {
      type: Number,
      default: 0,
    },
  },
  data() {
    return {
      tempRating: null,
      baseRating: this.rating,
    };
  },
  methods: {
    emitRatingAction(star) {
      this.$emit('ratingAction', star);
    },
    starScheme(star) {
      return star <= this.baseRating ? 'feedback-yellow' : 'fg-base';
    },
    starOver(star) {
      this.tempRating = this.baseRating;
      this.baseRating = star;
    },
    starOut() {
      this.baseRating = this.tempRating;
    },
  },
};
</script>

<style lang="scss">
@use '@/assets/scss/unnnic' as *;

.unnnic-banner-info {
  display: flex;
  flex-direction: row;

  border-radius: $unnnic-border-radius-sm;
  padding: $unnnic-squish-md;
  background-color: $unnnic-color-bg-base-soft;
  text-align: center;
  justify-content: center;

  &__section {
    flex: 1;
  }

  &__title {
    font-family: $unnnic-font-family-secondary;
    font-weight: $unnnic-font-weight-regular;
    font-size: $unnnic-font-size-body-lg;
    line-height: $unnnic-font-size-body-lg + $unnnic-line-height-md;
    color: $unnnic-color-fg-base;
    margin-bottom: $unnnic-spacing-stack-nano;
  }

  &__description {
    font-family: $unnnic-font-family-secondary;
    font-weight: $unnnic-font-weight-bold;
    font-size: $unnnic-font-size-title-md;
    line-height: $unnnic-font-size-title-md + $unnnic-line-height-md;
    color: $unnnic-color-fg-base;
  }

  &__subtitle {
    font-family: $unnnic-font-family-secondary;
    font-weight: $unnnic-font-weight-regular;
    font-size: $unnnic-font-size-body-lg;
    line-height: $unnnic-font-size-body-lg + $unnnic-line-height-md;
    color: $unnnic-color-fg-base;
    margin-top: $unnnic-spacing-stack-nano;
  }

  &__divider {
    align-self: center;

    border-left: 1px solid $unnnic-color-fg-base;
    height: 36px;
    margin: 0 $unnnic-inline-md;
  }

  &__rating {
    display: flex;
    flex-direction: row;
    justify-content: center;
  }
}
</style>
