Skip to content

Commit bc80452

Browse files
committed
Refactor palette
1 parent dc67243 commit bc80452

1 file changed

Lines changed: 28 additions & 28 deletions

File tree

assets/js/dashboard/stats/graph/main-graph.tsx

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ export const MainGraph = ({
178178
stopBottom
179179
}: {
180180
id: string
181-
stopTop: [string, number]
182-
stopBottom: [string, number]
181+
stopTop: { color: string; opacity: number }
182+
stopBottom: { color: string; opacity: number }
183183
}): string => {
184184
const grad = svg
185185
.append('defs')
@@ -193,14 +193,14 @@ export const MainGraph = ({
193193
grad
194194
.append('stop')
195195
.attr('offset', '0%')
196-
.attr('stop-color', stopTop[0])
197-
.attr('stop-opacity', stopTop[1])
196+
.attr('stop-color', stopTop.color)
197+
.attr('stop-opacity', stopTop.opacity)
198198

199199
grad
200200
.append('stop')
201201
.attr('offset', '100%')
202-
.attr('stop-color', stopBottom[0])
203-
.attr('stop-opacity', stopBottom[1])
202+
.attr('stop-color', stopBottom.color)
203+
.attr('stop-opacity', stopBottom.opacity)
204204
return id
205205
}
206206

@@ -254,13 +254,13 @@ export const MainGraph = ({
254254

255255
const mainGradientId = addGradient({
256256
id: 'main',
257-
stopTop: primaryGradient[0],
258-
stopBottom: primaryGradient[1]
257+
stopTop: primaryGradient.stopTop,
258+
stopBottom: primaryGradient.stopBottom
259259
})
260260
const comparisonGradientId = addGradient({
261261
id: 'comparisonGradient',
262-
stopTop: secondaryGradient[0],
263-
stopBottom: secondaryGradient[1]
262+
stopTop: secondaryGradient.stopTop,
263+
stopBottom: secondaryGradient.stopBottom
264264
})
265265

266266
paintUnderLine(
@@ -323,7 +323,7 @@ export const MainGraph = ({
323323
return () => {
324324
svg.selectAll('*').remove()
325325
}
326-
}, [primaryGradient, width, data])
326+
}, [primaryGradient, secondaryGradient, width, data])
327327

328328
return (
329329
<div
@@ -518,26 +518,26 @@ const remapToGraphData = (
518518

519519
const paletteByTheme = {
520520
[UIMode.dark]: {
521-
primaryGradient: [
522-
['#4f46e5', 0.15],
523-
['#4f46e5', 0]
524-
],
525-
secondaryGradient: [
526-
['#4f46e5', 0.05],
527-
['#4f46e5', 0]
528-
]
521+
primaryGradient: {
522+
stopTop: { color: '#4f46e5', opacity: 0.15 },
523+
stopBottom: { color: '#4f46e5', opacity: 0 }
524+
},
525+
secondaryGradient: {
526+
stopTop: { color: '#4f46e5', opacity: 0.05 },
527+
stopBottom: { color: '#4f46e5', opacity: 0 }
528+
}
529529
},
530530
[UIMode.light]: {
531-
primaryGradient: [
532-
['#4f46e5', 0.15],
533-
['#4f46e5', 0]
534-
],
535-
secondaryGradient: [
536-
['#4f46e5', 0.05],
537-
['#4f46e5', 0]
538-
]
531+
primaryGradient: {
532+
stopTop: { color: '#4f46e5', opacity: 0.15 },
533+
stopBottom: { color: '#4f46e5', opacity: 0 }
534+
},
535+
secondaryGradient: {
536+
stopTop: { color: '#4f46e5', opacity: 0.05 },
537+
stopBottom: { color: '#4f46e5', opacity: 0 }
538+
}
539539
}
540-
} as const
540+
}
541541

542542
const tickLineClass =
543543
'stroke-gray-150 dark:stroke-gray-800/75 group-first:stroke-gray-300 dark:group-first:stroke-gray-700'

0 commit comments

Comments
 (0)