Skip to content

Commit b7c627c

Browse files
committed
feat: 新增 FaProgress 组件
1 parent 7d2279f commit b7c627c

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed

‎src/types/components.d.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ declare module 'vue' {
3333
FaPasswordStrength: typeof import('./../ui/components/FaPasswordStrength/index.vue')['default']
3434
FaPinInput: typeof import('./../ui/components/FaPinInput/index.vue')['default']
3535
FaPopover: typeof import('./../ui/components/FaPopover/index.vue')['default']
36+
FaProgress: typeof import('./../ui/components/FaProgress/index.vue')['default']
3637
FaScrollArea: typeof import('./../ui/components/FaScrollArea/index.vue')['default']
3738
FaSearchBar: typeof import('./../ui/components/FaSearchBar/index.vue')['default']
3839
FaSelect: typeof import('./../ui/components/FaSelect/index.vue')['default']
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<script setup lang="ts">
2+
import type { HTMLAttributes } from 'vue'
3+
import { Progress } from './progress'
4+
5+
const props = defineProps<{
6+
class?: HTMLAttributes['class']
7+
}>()
8+
9+
const modelValue = defineModel<number>({
10+
default: 0,
11+
})
12+
</script>
13+
14+
<template>
15+
<Progress v-bind="props" :model-value="modelValue" />
16+
</template>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<script setup lang="ts">
2+
import type { ProgressRootProps } from 'reka-ui'
3+
import type { HTMLAttributes } from 'vue'
4+
import { cn } from '@/utils'
5+
import {
6+
ProgressIndicator,
7+
ProgressRoot,
8+
} from 'reka-ui'
9+
import { computed } from 'vue'
10+
11+
const props = withDefaults(
12+
defineProps<ProgressRootProps & { class?: HTMLAttributes['class'] }>(),
13+
{
14+
modelValue: 0,
15+
},
16+
)
17+
18+
const delegatedProps = computed(() => {
19+
const { class: _, ...delegated } = props
20+
21+
return delegated
22+
})
23+
</script>
24+
25+
<template>
26+
<ProgressRoot
27+
v-bind="delegatedProps"
28+
:class="
29+
cn(
30+
'relative h-4 w-full overflow-hidden rounded-full bg-secondary',
31+
props.class,
32+
)
33+
"
34+
>
35+
<ProgressIndicator
36+
class="h-full w-full flex-1 bg-primary transition-all"
37+
:style="`transform: translateX(-${100 - (props.modelValue ?? 0)}%);`"
38+
/>
39+
</ProgressRoot>
40+
</template>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as Progress } from './Progress.vue'

0 commit comments

Comments
 (0)