[feat] Add theme-aware colors to minimap (#4598)

This commit is contained in:
Christian Byrne
2025-07-30 12:41:02 -07:00
committed by GitHub
parent efb08bf2ba
commit fe475403b0
2 changed files with 30 additions and 14 deletions

View File

@@ -9,6 +9,7 @@ import { app } from '@/scripts/app'
import { useCanvasStore } from '@/stores/graphStore' import { useCanvasStore } from '@/stores/graphStore'
import { useSettingStore } from '@/stores/settingStore' import { useSettingStore } from '@/stores/settingStore'
import { useWorkflowStore } from '@/stores/workflowStore' import { useWorkflowStore } from '@/stores/workflowStore'
import { useColorPaletteStore } from '@/stores/workspace/colorPaletteStore'
interface GraphCallbacks { interface GraphCallbacks {
onNodeAdded?: (node: LGraphNode) => void onNodeAdded?: (node: LGraphNode) => void
@@ -19,6 +20,7 @@ interface GraphCallbacks {
export function useMinimap() { export function useMinimap() {
const settingStore = useSettingStore() const settingStore = useSettingStore()
const canvasStore = useCanvasStore() const canvasStore = useCanvasStore()
const colorPaletteStore = useColorPaletteStore()
const workflowStore = useWorkflowStore() const workflowStore = useWorkflowStore()
const containerRef = ref<HTMLDivElement>() const containerRef = ref<HTMLDivElement>()
@@ -55,12 +57,18 @@ export function useMinimap() {
const width = 250 const width = 250
const height = 200 const height = 200
const nodeColor = '#0B8CE999'
const linkColor = '#F99614' // Theme-aware colors for canvas drawing
const slotColor = '#F99614' const isLightTheme = computed(
const viewportColor = '#FFF' () => colorPaletteStore.completedActivePalette.light_theme
const backgroundColor = '#15161C' )
const borderColor = '#333' const nodeColor = computed(
() => (isLightTheme.value ? '#3DA8E099' : '#0B8CE999') // lighter blue for light theme
)
const linkColor = computed(
() => (isLightTheme.value ? '#FFB347' : '#F99614') // lighter orange for light theme
)
const slotColor = computed(() => linkColor.value)
const containerRect = ref({ const containerRect = ref({
left: 0, left: 0,
@@ -113,8 +121,8 @@ export function useMinimap() {
const containerStyles = computed(() => ({ const containerStyles = computed(() => ({
width: `${width}px`, width: `${width}px`,
height: `${height}px`, height: `${height}px`,
backgroundColor: backgroundColor, backgroundColor: isLightTheme.value ? '#FAF9F5' : '#15161C',
border: `1px solid ${borderColor}`, border: `1px solid ${isLightTheme.value ? '#ccc' : '#333'}`,
borderRadius: '8px' borderRadius: '8px'
})) }))
@@ -122,8 +130,8 @@ export function useMinimap() {
transform: `translate(${viewportTransform.value.x}px, ${viewportTransform.value.y}px)`, transform: `translate(${viewportTransform.value.x}px, ${viewportTransform.value.y}px)`,
width: `${viewportTransform.value.width}px`, width: `${viewportTransform.value.width}px`,
height: `${viewportTransform.value.height}px`, height: `${viewportTransform.value.height}px`,
border: `2px solid ${viewportColor}`, border: `2px solid ${isLightTheme.value ? '#E0E0E0' : '#FFF'}`,
backgroundColor: `${viewportColor}33`, backgroundColor: `#FFF33`,
willChange: 'transform', willChange: 'transform',
backfaceVisibility: 'hidden' as const, backfaceVisibility: 'hidden' as const,
perspective: '1000px', perspective: '1000px',
@@ -206,7 +214,7 @@ export function useMinimap() {
const h = node.size[1] * scale.value const h = node.size[1] * scale.value
// Render solid node blocks // Render solid node blocks
ctx.fillStyle = nodeColor ctx.fillStyle = nodeColor.value
ctx.fillRect(x, y, w, h) ctx.fillRect(x, y, w, h)
} }
} }
@@ -219,7 +227,7 @@ export function useMinimap() {
const g = graph.value const g = graph.value
if (!g) return if (!g) return
ctx.strokeStyle = linkColor ctx.strokeStyle = linkColor.value
ctx.lineWidth = 1.4 ctx.lineWidth = 1.4
const slotRadius = 3.7 * Math.max(scale.value, 0.5) // Larger slots that scale const slotRadius = 3.7 * Math.max(scale.value, 0.5) // Larger slots that scale
@@ -268,7 +276,7 @@ export function useMinimap() {
} }
// Render connection slots on top // Render connection slots on top
ctx.fillStyle = slotColor ctx.fillStyle = slotColor.value
for (const conn of connections) { for (const conn of connections) {
// Output slot // Output slot
ctx.beginPath() ctx.beginPath()

View File

@@ -112,6 +112,14 @@ vi.mock('@/stores/settingStore', () => ({
useSettingStore: vi.fn(() => defaultSettingStore) useSettingStore: vi.fn(() => defaultSettingStore)
})) }))
vi.mock('@/stores/workspace/colorPaletteStore', () => ({
useColorPaletteStore: vi.fn(() => ({
completedActivePalette: {
light_theme: false
}
}))
}))
vi.mock('@/scripts/api', () => ({ vi.mock('@/scripts/api', () => ({
api: { api: {
addEventListener: vi.fn(), addEventListener: vi.fn(),
@@ -753,7 +761,7 @@ describe('useMinimap', () => {
}) })
describe('container styles', () => { describe('container styles', () => {
it('should provide correct container styles', () => { it('should provide correct container styles for dark theme', () => {
const minimap = useMinimap() const minimap = useMinimap()
const styles = minimap.containerStyles.value const styles = minimap.containerStyles.value