-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
Copy pathProgress.vue
39 lines (35 loc) · 889 Bytes
/
Progress.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue'
import {
ProgressIndicator,
ProgressRoot,
type ProgressRootProps,
} from 'radix-vue'
import { cn } from '@/utils'
const props = withDefaults(
defineProps<ProgressRootProps & { class?: HTMLAttributes['class'], color?: string }>(),
{
modelValue: 0,
},
)
const delegatedProps = computed(() => {
const { class: _, ...delegated } = props
return delegated
})
</script>
<template>
<ProgressRoot
v-bind="delegatedProps"
:class="
cn(
'relative h-4 w-full overflow-hidden rounded-full bg-secondary',
props.class,
)
"
>
<ProgressIndicator
class="flex-1 w-full h-full transition-all bg-primary"
:style="[`transform: translateX(-${100 - (props.modelValue ?? 0)}%);`, `background-color: ${props.color}`]"
/>
</ProgressRoot>
</template>