49 lines
2.0 KiB
Vue
49 lines
2.0 KiB
Vue
<script setup lang="ts">
|
|
import type { Resource, Resources, VillageState } from '~/types/game'
|
|
|
|
defineProps<{ village: VillageState; resources: Resources }>()
|
|
|
|
const list: Resource[] = ['wood', 'clay', 'iron', 'food']
|
|
</script>
|
|
|
|
<!-- Projected stock per resource, its rate, and how full storage is. -->
|
|
<template>
|
|
<div class="border-b border-parchment-300/70 bg-parchment-50/95 shadow-sm backdrop-blur">
|
|
<div class="grid grid-cols-4 gap-x-3 px-4 py-2 sm:px-6 sm:grid-cols-[repeat(4,minmax(0,1fr))_auto] sm:gap-x-5">
|
|
<div
|
|
v-for="r in list"
|
|
:key="r"
|
|
class="flex min-w-0 items-center gap-2"
|
|
:title="`${$t(`resources.${r}`)}, ${$t('village.resources.cap')} ${village.storage_cap}`"
|
|
>
|
|
<IconResource :resource="r" class="hidden size-7 sm:block" />
|
|
<div class="min-w-0 flex-1">
|
|
<div class="flex flex-wrap items-baseline justify-between gap-x-1">
|
|
<span class="flex items-center gap-1 font-semibold tabular-nums">
|
|
<IconResource :resource="r" class="size-4 sm:hidden" />
|
|
<span class="sr-only">{{ $t(`resources.${r}`) }}</span>
|
|
{{ formatAmount(resources[r]) }}
|
|
</span>
|
|
<span
|
|
class="text-[11px] tabular-nums sm:text-xs"
|
|
:class="village.rates[r] < 0 ? 'text-rose-700' : village.rates[r] > 0 ? 'text-emerald-700' : 'text-ink-400'"
|
|
>
|
|
{{ $t('village.resources.per_hour', { rate: formatRate(village.rates[r]) }) }}
|
|
</span>
|
|
</div>
|
|
<UiBar
|
|
class="mt-1"
|
|
:value="resources[r] / village.storage_cap"
|
|
:tone="resources[r] >= village.storage_cap ? 'rose' : 'amber'"
|
|
/>
|
|
</div>
|
|
</div>
|
|
<div class="hidden items-center justify-end gap-1.5 text-xs text-ink-500 sm:flex">
|
|
<IconBuilding type="storage" class="size-4" />
|
|
{{ $t('village.resources.cap') }}
|
|
<span class="font-semibold text-ink-700 tabular-nums">{{ village.storage_cap }}</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|