Skip to content

Commit 2ced70f

Browse files
committed
feat: add subtle gradient on sparklines in dark mode
1 parent a057d6d commit 2ced70f

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

app/components/Chart/SplitSparkline.vue

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<script setup lang="ts">
22
import { VueUiSparkline } from 'vue-data-ui/vue-ui-sparkline'
33
import { useCssVariables } from '~/composables/useColors'
4-
import type {
5-
VueUiSparklineConfig,
6-
VueUiSparklineDatasetItem,
7-
VueUiXyDatasetItem,
4+
import {
5+
type VueUiSparklineConfig,
6+
type VueUiSparklineDatasetItem,
7+
type VueUiXyDatasetItem,
88
} from 'vue-data-ui'
9-
import { getPalette } from 'vue-data-ui/utils'
9+
import { getPalette, lightenColor } from 'vue-data-ui/utils'
1010
1111
import('vue-data-ui/style.css')
1212
@@ -99,6 +99,12 @@ const configs = computed(() => {
9999
? Array.from(new Set([...(unit.dashIndices ?? []), lastIndex]))
100100
: unit.dashIndices
101101
102+
const fallbackColor = palette[i] ?? palette[i % palette.length] ?? palette[0]!
103+
const seriesColor = unit.color ?? fallbackColor
104+
const lightenedSeriesColor: string = unit.color
105+
? lightenOklch(unit.color, 0.5) ?? seriesColor
106+
: lightenColor(seriesColor, 0.5) ?? seriesColor // palette uses hex colours
107+
102108
return {
103109
a11y: {
104110
translations: {
@@ -110,6 +116,10 @@ const configs = computed(() => {
110116
},
111117
},
112118
theme: isDarkMode.value ? 'dark' : '',
119+
temperatureColors: {
120+
show: isDarkMode.value,
121+
colors: [lightenedSeriesColor, seriesColor]
122+
},
113123
skeletonConfig: {
114124
style: {
115125
backgroundColor: 'transparent',

0 commit comments

Comments
 (0)