Skip to content

Commit fe47540

Browse files
[feat] Add theme-aware colors to minimap (#4598)
1 parent efb08bf commit fe47540

File tree

2 files changed

+30
-14
lines changed

2 files changed

+30
-14
lines changed

src/composables/useMinimap.ts

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { app } from '@/scripts/app'
99
import { useCanvasStore } from '@/stores/graphStore'
1010
import { useSettingStore } from '@/stores/settingStore'
1111
import { useWorkflowStore } from '@/stores/workflowStore'
12+
import { useColorPaletteStore } from '@/stores/workspace/colorPaletteStore'
1213

1314
interface GraphCallbacks {
1415
onNodeAdded?: (node: LGraphNode) => void
@@ -19,6 +20,7 @@ interface GraphCallbacks {
1920
export function useMinimap() {
2021
const settingStore = useSettingStore()
2122
const canvasStore = useCanvasStore()
23+
const colorPaletteStore = useColorPaletteStore()
2224
const workflowStore = useWorkflowStore()
2325

2426
const containerRef = ref<HTMLDivElement>()
@@ -55,12 +57,18 @@ export function useMinimap() {
5557

5658
const width = 250
5759
const height = 200
58-
const nodeColor = '#0B8CE999'
59-
const linkColor = '#F99614'
60-
const slotColor = '#F99614'
61-
const viewportColor = '#FFF'
62-
const backgroundColor = '#15161C'
63-
const borderColor = '#333'
60+
61+
// Theme-aware colors for canvas drawing
62+
const isLightTheme = computed(
63+
() => colorPaletteStore.completedActivePalette.light_theme
64+
)
65+
const nodeColor = computed(
66+
() => (isLightTheme.value ? '#3DA8E099' : '#0B8CE999') // lighter blue for light theme
67+
)
68+
const linkColor = computed(
69+
() => (isLightTheme.value ? '#FFB347' : '#F99614') // lighter orange for light theme
70+
)
71+
const slotColor = computed(() => linkColor.value)
6472

6573
const containerRect = ref({
6674
left: 0,
@@ -113,17 +121,17 @@ export function useMinimap() {
113121
const containerStyles = computed(() => ({
114122
width: `${width}px`,
115123
height: `${height}px`,
116-
backgroundColor: backgroundColor,
117-
border: `1px solid ${borderColor}`,
124+
backgroundColor: isLightTheme.value ? '#FAF9F5' : '#15161C',
125+
border: `1px solid ${isLightTheme.value ? '#ccc' : '#333'}`,
118126
borderRadius: '8px'
119127
}))
120128

121129
const viewportStyles = computed(() => ({
122130
transform: `translate(${viewportTransform.value.x}px, ${viewportTransform.value.y}px)`,
123131
width: `${viewportTransform.value.width}px`,
124132
height: `${viewportTransform.value.height}px`,
125-
border: `2px solid ${viewportColor}`,
126-
backgroundColor: `${viewportColor}33`,
133+
border: `2px solid ${isLightTheme.value ? '#E0E0E0' : '#FFF'}`,
134+
backgroundColor: `#FFF33`,
127135
willChange: 'transform',
128136
backfaceVisibility: 'hidden' as const,
129137
perspective: '1000px',
@@ -206,7 +214,7 @@ export function useMinimap() {
206214
const h = node.size[1] * scale.value
207215

208216
// Render solid node blocks
209-
ctx.fillStyle = nodeColor
217+
ctx.fillStyle = nodeColor.value
210218
ctx.fillRect(x, y, w, h)
211219
}
212220
}
@@ -219,7 +227,7 @@ export function useMinimap() {
219227
const g = graph.value
220228
if (!g) return
221229

222-
ctx.strokeStyle = linkColor
230+
ctx.strokeStyle = linkColor.value
223231
ctx.lineWidth = 1.4
224232

225233
const slotRadius = 3.7 * Math.max(scale.value, 0.5) // Larger slots that scale
@@ -268,7 +276,7 @@ export function useMinimap() {
268276
}
269277

270278
// Render connection slots on top
271-
ctx.fillStyle = slotColor
279+
ctx.fillStyle = slotColor.value
272280
for (const conn of connections) {
273281
// Output slot
274282
ctx.beginPath()

tests-ui/tests/composables/useMinimap.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ vi.mock('@/stores/settingStore', () => ({
112112
useSettingStore: vi.fn(() => defaultSettingStore)
113113
}))
114114

115+
vi.mock('@/stores/workspace/colorPaletteStore', () => ({
116+
useColorPaletteStore: vi.fn(() => ({
117+
completedActivePalette: {
118+
light_theme: false
119+
}
120+
}))
121+
}))
122+
115123
vi.mock('@/scripts/api', () => ({
116124
api: {
117125
addEventListener: vi.fn(),
@@ -753,7 +761,7 @@ describe('useMinimap', () => {
753761
})
754762

755763
describe('container styles', () => {
756-
it('should provide correct container styles', () => {
764+
it('should provide correct container styles for dark theme', () => {
757765
const minimap = useMinimap()
758766
const styles = minimap.containerStyles.value
759767

0 commit comments

Comments
 (0)