From c158187f20e9eb60c7b0dd5256f0030594883867 Mon Sep 17 00:00:00 2001 From: David Luzar <5153846+dwelle@users.noreply.github.com> Date: Sun, 4 Jan 2026 17:51:53 +0100 Subject: [PATCH] fix: grid color in dark mode (#10600) --- packages/excalidraw/renderer/staticScene.ts | 27 +++++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/packages/excalidraw/renderer/staticScene.ts b/packages/excalidraw/renderer/staticScene.ts index 866eb3da11..78534eb5a5 100644 --- a/packages/excalidraw/renderer/staticScene.ts +++ b/packages/excalidraw/renderer/staticScene.ts @@ -1,4 +1,9 @@ -import { FRAME_STYLE, throttleRAF } from "@excalidraw/common"; +import { + applyDarkModeFilter, + FRAME_STYLE, + THEME, + throttleRAF, +} from "@excalidraw/common"; import { isElementLink } from "@excalidraw/element"; import { createPlaceholderEmbeddableLabel } from "@excalidraw/element"; import { getBoundTextElement } from "@excalidraw/element"; @@ -38,8 +43,14 @@ import type { import type { StaticCanvasAppState, Zoom } from "../types"; const GridLineColor = { - Bold: "#dddddd", - Regular: "#e5e5e5", + [THEME.LIGHT]: { + bold: "#dddddd", + regular: "#e5e5e5", + }, + [THEME.DARK]: { + bold: applyDarkModeFilter("#dddddd"), + regular: applyDarkModeFilter("#e5e5e5"), + }, } as const; const strokeGrid = ( @@ -51,6 +62,7 @@ const strokeGrid = ( scrollX: number, scrollY: number, zoom: Zoom, + theme: StaticCanvasRenderConfig["theme"], width: number, height: number, ) => { @@ -86,7 +98,9 @@ const strokeGrid = ( context.beginPath(); context.setLineDash(isBold ? [] : lineDash); - context.strokeStyle = isBold ? GridLineColor.Bold : GridLineColor.Regular; + context.strokeStyle = isBold + ? GridLineColor[theme].bold + : GridLineColor[theme].regular; context.moveTo(x, offsetY - gridSize); context.lineTo(x, Math.ceil(offsetY + height + gridSize * 2)); context.stroke(); @@ -105,7 +119,9 @@ const strokeGrid = ( context.beginPath(); context.setLineDash(isBold ? [] : lineDash); - context.strokeStyle = isBold ? GridLineColor.Bold : GridLineColor.Regular; + context.strokeStyle = isBold + ? GridLineColor[theme].bold + : GridLineColor[theme].regular; context.moveTo(offsetX - gridSize, y); context.lineTo(Math.ceil(offsetX + width + gridSize * 2), y); context.stroke(); @@ -252,6 +268,7 @@ const _renderStaticScene = ({ appState.scrollX, appState.scrollY, appState.zoom, + renderConfig.theme, normalizedWidth / appState.zoom.value, normalizedHeight / appState.zoom.value, );