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

22 lines
623 B
Vue
Raw Normal View History

<script setup lang="ts">
const props = withDefaults(defineProps<{ value: number; tone?: 'amber' | 'emerald' | 'rose' | 'sky' }>(), {
tone: 'amber',
})
const fill = {
amber: 'bg-amber-500',
emerald: 'bg-emerald-500',
rose: 'bg-rose-500',
sky: 'bg-sky-500',
}
const width = computed(() => `${Math.round(Math.min(1, Math.max(0, props.value)) * 100)}%`)
</script>
<!-- A thin fill bar, 0..1. -->
<template>
<div class="h-1.5 w-full overflow-hidden rounded-full bg-parchment-200">
<div class="h-full rounded-full transition-[width] duration-300" :class="fill[tone]" :style="{ width }" />
</div>
</template>