40 lines
1.5 KiB
Vue
40 lines
1.5 KiB
Vue
<script setup lang="ts">
|
|
import type { UnitType } from '~/types/game'
|
|
|
|
const props = defineProps<{
|
|
units: Partial<Record<string, number>>
|
|
/** null hides the losses row. */
|
|
lost: Record<string, number> | null
|
|
}>()
|
|
const columns = computed(() => unitRows(props.units).map(([u]) => u))
|
|
</script>
|
|
|
|
<!-- A Die Stämme report table: one column per unit, quantity and losses below. -->
|
|
<template>
|
|
<div class="overflow-x-auto">
|
|
<table class="text-sm tabular-nums">
|
|
<thead>
|
|
<tr>
|
|
<th class="pr-3" />
|
|
<th v-for="unit in columns" :key="unit" class="min-w-12 px-1.5 py-1 text-center" :title="$t(`units.${unit}`)">
|
|
<IconUnit :unit="unit as UnitType" class="mx-auto size-5 text-wood-800" />
|
|
<span class="sr-only">{{ $t(`units.${unit}`) }}</span>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr class="border-t border-parchment-300">
|
|
<th class="pr-3 py-1 text-left text-xs font-semibold text-ink-500">{{ $t('reports.battle.units') }}</th>
|
|
<td v-for="unit in columns" :key="unit" class="px-1.5 py-1 text-center">{{ units[unit] }}</td>
|
|
</tr>
|
|
<tr v-if="lost" class="border-t border-parchment-300">
|
|
<th class="pr-3 py-1 text-left text-xs font-semibold text-ink-500">{{ $t('reports.battle.losses') }}</th>
|
|
<td v-for="unit in columns" :key="unit" class="px-1.5 py-1 text-center" :class="lost[unit] ? 'text-blood-700' : 'text-ink-400'">
|
|
{{ lost[unit] ?? 0 }}
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</template>
|