<template>
  <div class="results">
    <div v-for="(result, index) in results" :key="index" :class="resultClass">
      <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<'orange' | 'white'>,
      default: 'white',
      validator: value => ['orange', 'white'].includes(value),
    },
  },

  computed: {
    resultClass() {
      return ['result', this.backgroundColor];
    },
  },

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

<style lang="scss" scoped>
.results {
  display: flex;
  flex-direction: column;

  row-gap: 24px;
  margin-right: 64px;
}

.result {
  width: 248px;
  padding: 18px 24px;

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

  &.orange {
    background: #ffe4d8;
  }

  &-value {
    margin-bottom: 12px;

    color: #ff5f21;
    font-weight: 700;
    font-size: 48px;
    line-height: 120%;
    letter-spacing: -0.005em;
  }

  &-title {
    padding-bottom: 3px;

    color: #ff5f21;
    font-size: 14px;
    line-height: 16px;
  }
}
</style>
