Skip to content

Commit 60fe888

Browse files
committed
fix(color): rename info-color to color-info
1 parent b7da524 commit 60fe888

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/components/common/numbers/ProgressNumber.vue

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<script lang="ts" setup>
22
import { NProgress, NSkeleton, NSpin } from 'naive-ui';
33
4-
import { onDeactivated, onMounted, onUnmounted, ref, toRefs, watch } from 'vue';
4+
import { computed, onMounted, onUnmounted, ref, toRefs, watch } from 'vue';
55
66
import AnimatedNumber from './AnimatedNumber.vue';
77
8+
import { Rating } from '~/models/rating.model';
89
import { wait } from '~/utils/promise.utils';
910
1011
const props = defineProps({
@@ -47,6 +48,13 @@ const { progress, delay } = toRefs(props);
4748
4849
const _progress = ref(0);
4950
51+
const color = computed(() => {
52+
if (_progress.value <= Rating.Bad * 10) return 'color-error';
53+
if (_progress.value <= Rating.Mediocre * 10) return 'color-warning';
54+
if (_progress.value <= Rating.Good * 10) return 'color-info';
55+
return 'color-primary';
56+
});
57+
5058
onMounted(async () => {
5159
watch(
5260
progress,
@@ -74,7 +82,10 @@ onUnmounted(() => {
7482
class="progress custom-color"
7583
type="circle"
7684
:percentage="_progress"
77-
:style="{ '--duration': `${duration - delay}ms` }"
85+
:style="{
86+
'--duration': `${ duration - delay }ms`,
87+
'--custom-progress-color': `var(--${ color })`,
88+
}"
7889
>
7990
<AnimatedNumber
8091
:from="from"
@@ -94,7 +105,7 @@ onUnmounted(() => {
94105
}
95106
96107
.custom-color {
97-
--custom-color: var(--info-color) --n-fill-color: var(--custom-color) !important;
108+
--n-fill-color: var(--custom-progress-color, var(--color-info)) !important;
98109
}
99110
100111
.spin {

src/styles/base.scss

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@
104104
--color-primary-disabled: #548272;
105105
--color-primary-dark: color-mix(in srgb, var(--color-primary) 40%, black 60%);
106106
--color-primary-focus: rgba(99 226 183 / 10%);
107-
--info-color: #70c0e8;
108-
--info-color-dark: color-mix(in srgb, var(--info-color) 40%, black 60%);
107+
--color-info: #70c0e8;
108+
--color-info-dark: color-mix(in srgb, var(--color-info) 40%, black 60%);
109109
--color-disabled: rgba(255 255 255 / 6%);
110110
--text-color-disabled: rgba(255 255 255 / 38%);
111111
--color-warning: #f2c97d;

0 commit comments

Comments
 (0)