Skip to content

Commit c2d88a1

Browse files
committed
fix: dashboard dark theme
1 parent 4281f57 commit c2d88a1

6 files changed

Lines changed: 97 additions & 16 deletions

File tree

src/frontend/platform/src/pages/Dashboard/components/AdvancedDatePicker.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,15 +252,16 @@ export function AdvancedDatePicker({
252252
<Button
253253
variant={"outline"}
254254
className={cn(
255-
"w-92 flex-1 justify-start text-left font-normal dark:text-gray-200",
256-
!value && "text-muted-foreground"
255+
"w-92 flex-1 justify-start text-left font-normal",
256+
value ? "text-prompt-description" : "text-muted-foreground",
257+
isDark && "dark:text-gray-200"
257258
)}
258259
>
259260
<CalendarIcon className="mr-2 h-4 w-4" />
260261
{getDisplayValue() || placeholder}
261262
</Button>
262263
</PopoverTrigger>
263-
<PopoverContent className={cn("w-auto p-0", isDark && 'dark bg-gray-950 border-gray-600')} align="start">
264+
<PopoverContent className={cn("w-auto p-0", isDark ? 'dark bg-gray-950 border-gray-600' : "theme-force-light")} align="start">
264265
<div className="no-drag flex flex-col">
265266

266267
{/* Calendar Area */}

src/frontend/platform/src/pages/Dashboard/components/charts/BaseChart.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
import { ChartType, ComponentConfig, ComponentStyleConfig } from '@/pages/Dashboard/types/dataConfig'
44
import { useEffect, useRef, useState } from 'react'
5+
import { useTranslation } from 'react-i18next'
56
import { colorSchemes, convertToEChartsTheme } from '../../colorSchemes'
67
import { ChartDataResponse } from '../../types/chartData'
78
import { unitConversion } from './MetricCard'
8-
import { useTranslation } from 'react-i18next'
99

1010
// Dynamic loading of ECharts.
1111
const loadECharts = async () => {
@@ -264,7 +264,8 @@ const getCartesianChartOption = (
264264
},
265265
name: styleConfig.xAxisTitle || '',
266266
nameLocation: styleConfig.xAxisAlign === 'right' ? 'end' : styleConfig.xAxisAlign === 'left' ? 'start' : 'center',
267-
nameTextStyle: xAxisTitleStyle
267+
nameTextStyle: xAxisTitleStyle,
268+
inverse: isHorizontal
268269
};
269270

270271
// (Value Axis)
@@ -280,7 +281,7 @@ const getCartesianChartOption = (
280281
nameLocation: styleConfig.yAxisAlign === 'right' ? 'end' : styleConfig.yAxisAlign === 'left' ? 'start' : 'center',
281282
nameRotate: isHorizontal ? 0 : 90,
282283
nameTextStyle: yAxisTitleStyle,
283-
boundaryGap: [0, '20%']
284+
boundaryGap: [0, '20%'],
284285
};
285286

286287
const lastValueIndexes = dimensions.map((_, dimIdx) => {
@@ -331,10 +332,14 @@ const getCartesianChartOption = (
331332
position: 'top',
332333
fontSize: 10,
333334
color: "#666",
335+
formatter: (params: any) => unitConversion(params.value, dataConfig).join('')
334336
};
337+
item.labelLayout = {
338+
hideOverlap: true
339+
}
335340
}
336341
if (isStacked) item.stack = 'total';
337-
if (isArea) item.areaStyle = {opacity: 0.1};
342+
if (isArea) item.areaStyle = { opacity: 0.1 };
338343
// if (isLineOrArea) item.smooth = true;
339344

340345
return item;

src/frontend/platform/src/pages/Dashboard/components/editor/ComponentWrapper.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ interface ComponentWrapperProps {
1717
component: DashboardComponent
1818
isPreviewMode: boolean
1919
dashboards: Dashboard[]
20+
/** When it is true, the dark selector can take effect, resolving the conflict between the system and canvas themes */
2021
isDark: boolean
2122
onDuplicate: (component: DashboardComponent) => void
2223
onCopyTo: (component: DashboardComponent, targetDashboardId: string) => void
@@ -133,7 +134,7 @@ export function ComponentWrapper({
133134
id={component.id}
134135
className={cn(`relative w-full h-full rounded-md overflow-visible transition-all border ${!isPreviewMode && isSelected ? 'component-select border border-primary' : ''
135136
}`,
136-
!componentData.style_config.bgColor && 'dark:bg-gray-900',
137+
!componentData.style_config.bgColor && isDark && 'dark:bg-gray-900',
137138
!componentData.style_config.bgColor && 'bg-background',
138139
!isPreviewMode && 'hover:border-primary hover:shadow-md'
139140
)}
@@ -259,8 +260,8 @@ export function ComponentWrapper({
259260
/>
260261
) : (
261262
<h3
262-
className={cn("text-sm font-medium truncate",
263-
"dark:text-gray-400"
263+
className={cn("text-sm font-medium truncate text-foreground",
264+
isDark && "dark:text-gray-400"
264265
)}
265266
style={{ textAlign: componentData.style_config?.titleAlign }}
266267
onDoubleClick={() => setIsEditing(true)}>

src/frontend/platform/src/pages/Dashboard/components/editor/EditorCanvas.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ export function EditorCanvas({ isLoading, isPreviewMode }: EditorCanvasProps) {
216216

217217
// loading
218218
if (isLoading || !currentDashboard) {
219-
return <div className="w-full h-full flex justify-center items-center z-10 bg-[rgba(255,255,255,0.6)] dark:bg-blur-shared">
219+
return <div className="w-full h-full flex justify-center items-center z-10">
220220
<LoadingIcon />
221221
</div>
222222
}
@@ -234,10 +234,7 @@ export function EditorCanvas({ isLoading, isPreviewMode }: EditorCanvasProps) {
234234
<div className="flex h-full">
235235
<div
236236
id="edit-charts-panne"
237-
className={cn("flex-1 relative overflow-auto no-scrollbar", theme)}
238-
style={{
239-
backgroundColor: theme === 'dark' ? '#1a1a1a' : '#f5f5f5',
240-
}}
237+
className={cn("flex-1 relative overflow-auto no-scrollbar", theme === 'dark' ? 'bg-[#1a1a1a] dark' : 'bg-[#f5f5f5] theme-force-light')}
241238
>
242239
<div
243240
ref={containerRef}

src/frontend/platform/src/pages/Dashboard/components/editor/EditorHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ export function EditorHeader({
216216
{title}
217217
</h1>
218218
)}
219-
<Badge variant="outline" className="break-keep font-normal bg-gray-100">{getSaveStatus()}</Badge>
219+
<Badge variant="outline" className="break-keep font-normal bg-gray-100 dark:bg-black">{getSaveStatus()}</Badge>
220220
</div>
221221

222222
{/* Middle section */}

src/frontend/platform/src/pages/Dashboard/components/editor/index.css

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,80 @@
1+
.theme-force-light {
2+
--background-login: #fff;
3+
--text-color: rgba(17, 17, 17, 0.3);
4+
--background-main: rgba(244, 245, 248, 1);
5+
--background-main-content: rgba(255, 255, 255, 1);
6+
--background-tip: white;
7+
--background-tip-darkhover: #0055e3;
8+
--background-prompt: hsla(0, 0%, 100%, 1);
9+
--background-new: hsla(240, 14%, 99%, 1);
10+
--nav-hover: white;
11+
--header-icon: white;
12+
--text-answer: #111;
13+
--text-prompt: hsla(0, 0%, 18%, 1);
14+
--search-input: hsla(220, 100%, 99%, 1);
15+
--background: 0 0% 100%;
16+
/* hsl(0 0% 100%) */
17+
--foreground: 222.2 47.4% 11.2%;
18+
/* hsl(222 47% 11%) */
19+
--muted: 210 40% 98%;
20+
/* hsl(210 40% 98%) */
21+
--muted-foreground: 215.4 16.3% 46.9%;
22+
/* hsl(215 16% 46%) */
23+
--popover: 0 0% 100%;
24+
/* hsl(0 0% 100%) */
25+
--popover-foreground: 222.2 47.4% 11.2%;
26+
/* hsl(222 47% 11%) */
27+
--card: 0 0% 100%;
28+
/* hsl(0 0% 100%) */
29+
--card-foreground: 222.2 47.4% 11.2%;
30+
--white: white;
31+
/* hsl(222 47% 11%) */
32+
--border: 214.3 21.8% 91.4%;
33+
/* hsl(214 32% 91%) */
34+
--input: 223 48% 44%;
35+
/* hsl(214 32% 91%) */
36+
--primary: 220 98% 45%;
37+
/* hsl(222 27% 18%) */
38+
--primary-foreground: 210 40% 98%;
39+
/* hsl(210 40% 98%) */
40+
--secondary: 210 40% 96.1%;
41+
/* hsl(210 40% 96%) */
42+
--secondary-foreground: 222.2 47.4% 11.2%;
43+
/* hsl(222 47% 11%) */
44+
--accent: 210 30% 96.1%;
45+
/* hsl(210 30% 96%) */
46+
--accent-foreground: 222.2 47.4% 11.2%;
47+
/* hsl(222 47% 11%) */
48+
--destructive: 0 100% 50%;
49+
/* hsl(0 100% 50%) */
50+
--destructive-foreground: 210 40% 98%;
51+
--black-button: 0 0% 7%;
52+
/* hsl(215 20% 65%) */
53+
--ring: 223, 48%, 44%, 0.35;
54+
--radius: .58rem;
55+
--round-btn-shadow: #00000063;
56+
--error-background: #fef2f2;
57+
--error-foreground: #991b1b;
58+
--success-background: #f0fdf4;
59+
--success-foreground: #14532d;
60+
--info-background: #f0f4fd;
61+
--info-foreground: #141653;
62+
--high-indigo: #4338ca;
63+
--medium-indigo: #6366f1;
64+
--chat-bot-icon: #afe6ef;
65+
--chat-user-icon: #aface9;
66+
/* Colors that are shared in dark and light mode */
67+
--blur-shared: #151923de;
68+
--build-trigger: #dc735b;
69+
--chat-trigger: #5c8be1;
70+
--chat-trigger-disabled: #b4c3da;
71+
--status-red: #ef4444;
72+
--status-yellow: #eab308;
73+
--status-green: #4ade80;
74+
--status-blue: #2563eb;
75+
--connection: #555;
76+
}
77+
178
.react-grid-item>.react-resizable-handle {
279
width: 10px;
380
height: 10px;

0 commit comments

Comments
 (0)