game-village-politics-frontend/app/components/ui/Cost.vue

29 lines
818 B
Vue

<script setup lang="ts">
import type { Cost, Resources } from '~/types/game'
defineProps<{
cost: Cost
/** Projected stock; amounts the village lacks show in red. */
have?: Resources | null
/** Keep the three amounts on one line, for table cells. */
nowrap?: boolean
}>()
const list = ['wood', 'clay', 'iron'] as const
</script>
<template>
<span class="inline-flex items-center gap-x-2.5 gap-y-1 text-xs tabular-nums" :class="nowrap ? 'whitespace-nowrap' : 'flex-wrap'">
<span
v-for="r in list"
:key="r"
class="inline-flex items-center gap-1"
:class="have && have[r] < cost[r] ? 'font-semibold text-blood-700' : 'text-ink-700'"
:title="$t(`resources.${r}`)"
>
<IconResource :resource="r" class="size-4" />
{{ cost[r] }}
</span>
</span>
</template>