22 lines
623 B
Vue
22 lines
623 B
Vue
<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>
|