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
40
41
42
43
44
45
| <template>
| <div class="progress-container" :style="{ backgroundColor: props.backgroundColor || '#d6def1' }">
| <div
| class="progress-bar"
| :style="{
| width: computedWidth,
| backgroundColor: color,
| borderRadius: '0 999px 999px 0',
| }"
| ></div>
| </div>
| </template>
|
| <script setup lang="ts">
| import { computed } from "vue";
|
| interface Props {
| percent: number; // 0 ~ 100
| color?: string;
| backgroundColor?: string;
| borderRadius?: string;
| }
|
| const props = defineProps<Props>();
|
| const computedWidth = computed(
| () => Math.min(Math.max(props.percent, 0), 100) + "%"
| );
| </script>
|
| <style scoped>
| .progress-container {
| width: 46px;
| height: 6px;
| background: #d6def1;
| border-radius: 999px;
| overflow: hidden;
| }
|
| .progress-bar {
| height: 100%;
| transition: width 0.3s ease;
| border-radius: 0 999px 999px 0;
| }
| </style>
|
|