Skip to content

Commit 8ace4fd

Browse files
committed
新增 FaProgress 组件
1 parent 3cba388 commit 8ace4fd

File tree

6 files changed

+79
-0
lines changed

6 files changed

+79
-0
lines changed

src/router/modules/component.example.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,14 @@ const routes: RouteRecordRaw = {
182182
title: '浮动面板',
183183
},
184184
},
185+
{
186+
path: 'progress',
187+
name: 'componentExampleBuiltInProgress',
188+
component: () => import('@/views/component_built_in_example/progress.vue'),
189+
meta: {
190+
title: '进度条',
191+
},
192+
},
185193
{
186194
path: 'scrollarea',
187195
name: 'componentExampleBuiltInScrollarea',

src/types/components.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ declare module 'vue' {
3434
FaPasswordStrength: typeof import('./../ui/components/FaPasswordStrength/index.vue')['default']
3535
FaPinInput: typeof import('./../ui/components/FaPinInput/index.vue')['default']
3636
FaPopover: typeof import('./../ui/components/FaPopover/index.vue')['default']
37+
FaProgress: typeof import('./../ui/components/FaProgress/index.vue')['default']
3738
FaScrollArea: typeof import('./../ui/components/FaScrollArea/index.vue')['default']
3839
FaSearchBar: typeof import('./../ui/components/FaSearchBar/index.vue')['default']
3940
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'
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<route lang="yaml">
2+
meta:
3+
enabled: false
4+
</route>
5+
6+
<template>
7+
<div>
8+
<FaPageHeader title="进度条" description="FaProgress" />
9+
<FaPageMain>
10+
<FaProgress :model-value="33" />
11+
</FaPageMain>
12+
</div>
13+
</template>

0 commit comments

Comments
 (0)