<template>
  <div class="results">
    <div
      v-for="(result, index) in results"
      :key="index"
      :class="backgroundColor"
      class="result">
      <div class="result-value">
        {{ getResultValue(result) }}
      </div>
      <div class="result-title">{{ result.resultTitle }}</div>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent, PropType } from 'vue';
import type { CaseStudiesInterface } from '@/database/case-studies/caseStudies.types';

export default defineComponent({
  props: {
    results: {
      type: Array as PropType<CaseStudiesInterface.Result[]>,
      required: true,
    },
    backgroundColor: {
      type: String as PropType<'white' | 'orange'>,
      default: 'white',
    },
  },

  methods: {
    getResultValue({
      resultValue,
      chartValue,
    }: CaseStudiesInterface.Result): string {
      return resultValue || `${chartValue}%`;
    },
  },
});
</script>

<style lang="scss" scoped>
.results {
  display: flex;
  justify-content: space-between;
  margin-bottom: 24px;

  column-gap: 30px;
}

.result {
  flex-grow: 1;
  max-width: 206px;
  max-height: 124px;
  padding: 16px 20px 23px 21px;

  background: rgba(255, 255, 255, 0.5);
  border: 1px solid #ffe4d8;
  border-radius: 10px;
  backdrop-filter: blur(42px);

  &.orange {
    background: #ffe4d8;
  }

  &-value {
    color: #ff5f21;
    font-weight: bold;
    font-size: 48px;
    line-height: 120%;
  }

  &-title {
    display: -webkit-box;
    overflow: hidden;

    color: #ff5f21;
    font-size: 14px;
    line-height: 16px;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
}
</style>
