All files / src/components MotwReasons.vue

100% Statements 33/33
100% Branches 3/3
100% Functions 0/0
100% Lines 33/33

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 901x 1x       1x 1x 1x 1x 1x 1x 1x 1x 1x 1x   1x 1x 1x 1x 1x 1x 1x 1x 7x 7x 1x 1x 1x 1x 1x       1x 1x   1x       1x   1x 1x                                                                                          
<template>
  <!--
    "Why this is the Match of the Week" (SB-1552, SB-1577). Shared by the hero
    and the match detail page so the two never disagree. null and [] render
    nothing — no heading over an empty list.
  -->
  <div v-if="show" class="motw-reasons" data-testid="motw-reasons">
    <h3 class="motw-reasons-title">{{ title }}</h3>
    <ul class="motw-reasons-list">
      <li
        v-for="(reason, i) in reasons"
        :key="i"
        class="motw-reason"
        data-testid="motw-reason"
        :data-kind="marker(reason.kind).value || 'none'"
      >
        <span
          class="motw-reason-mark"
          aria-hidden="true"
          data-testid="motw-reason-mark"
          >{{ marker(reason.kind).icon }}</span
        >
        <span>
          <span v-if="marker(reason.kind).label" class="sr-only"
            >{{ marker(reason.kind).label }}:
          </span>
          {{ reason.text }}
        </span>
      </li>
    </ul>
  </div>
</template>
 
<script setup>
import { computed } from 'vue';
import { hasReasons, reasonMarker } from '@/utils/featuredReasons';
 
const props = defineProps({
  // [{text, kind}] or null.
  reasons: { type: Array, default: null },
  title: { type: String, default: 'Why this is the Match of the Week' },
});
 
const show = computed(() => hasReasons(props.reasons));
const marker = reasonMarker;
</script>
 
<style scoped>
.motw-reasons {
  max-width: 62ch;
}
 
.motw-reasons-title {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #b45309;
}
 
:global(.dark .motw-reasons-title) {
  color: #f59e0b;
}
 
.motw-reasons-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
 
.motw-reason {
  display: flex;
  gap: 8px;
  font-size: 14px;
  line-height: 20px;
  color: rgb(var(--color-fg));
}
 
.motw-reason-mark {
  flex-shrink: 0;
  width: 1.25em;
  text-align: center;
  color: #f59e0b;
}
</style>