<template>
  <div class="countdown-widget" :class="sizeClass" @click="openDialog = true">
    <div class="title">Time left</div>
    <div class="time-display">02:37:46</div>
    <div class="footer">
      <span>Release 19d</span>
      <span>Weekend 1d</span>
      <span>Holiday 4d</span>
    </div>
  </div>
  <CountdownDialog v-model:open="openDialog" />
</template>

<script setup lang="ts">
import { computed, ref } from 'vue';
import CountdownDialog from './dialog.vue';

type WidgetSize = '1x1' | '1x2' | '2x1' | '2x2' | '2x4';

const props = defineProps<{
  size: WidgetSize;
  data?: any;
}>();

const openDialog = ref(false);
const sizeClass = computed(() => `size-${props.size}`);
</script>

<style lang="scss" scoped>
@import '@/styles/tokens.scss';

.countdown-widget {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;

  .title {
    font-size: 13px;
    color: $color-text-secondary;
  }

  .time-display {
    font-size: 28px;
    font-weight: 600;
    color: $color-text-primary;
  }

  .footer {
    display: flex;
    justify-content: space-around;
    gap: 6px;
    font-size: 12px;
    color: $color-text-secondary;
    flex-wrap: wrap;
  }

  &.size-1x1 {
    justify-content: center;

    .title,
    .footer {
      display: none;
    }

    .time-display {
      font-size: 22px;
    }
  }

  &.size-1x2 {
    .footer {
      display: none;
    }

    .time-display {
      font-size: 26px;
    }
  }

  &.size-2x2,
  &.size-2x4 {
    .time-display {
      font-size: 34px;
    }
  }
}
</style>
