feat: 新增 FaProgress 组件

This commit is contained in:
Hooray
2025-05-14 10:43:27 +08:00
parent 7d2279f38d
commit b7c627c556
4 changed files with 58 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
<script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { Progress } from './progress'
const props = defineProps<{
class?: HTMLAttributes['class']
}>()
const modelValue = defineModel<number>({
default: 0,
})
</script>
<template>
<Progress v-bind="props" :model-value="modelValue" />
</template>
@@ -0,0 +1,40 @@
<script setup lang="ts">
import type { ProgressRootProps } from 'reka-ui'
import type { HTMLAttributes } from 'vue'
import { cn } from '@/utils'
import {
ProgressIndicator,
ProgressRoot,
} from 'reka-ui'
import { computed } from 'vue'
const props = withDefaults(
defineProps<ProgressRootProps & { class?: HTMLAttributes['class'] }>(),
{
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="h-full w-full flex-1 bg-primary transition-all"
:style="`transform: translateX(-${100 - (props.modelValue ?? 0)}%);`"
/>
</ProgressRoot>
</template>
@@ -0,0 +1 @@
export { default as Progress } from './Progress.vue'