fix: grid color in dark mode (#10600)
This commit is contained in:
@@ -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 { isElementLink } from "@excalidraw/element";
|
||||||
import { createPlaceholderEmbeddableLabel } from "@excalidraw/element";
|
import { createPlaceholderEmbeddableLabel } from "@excalidraw/element";
|
||||||
import { getBoundTextElement } from "@excalidraw/element";
|
import { getBoundTextElement } from "@excalidraw/element";
|
||||||
@@ -38,8 +43,14 @@ import type {
|
|||||||
import type { StaticCanvasAppState, Zoom } from "../types";
|
import type { StaticCanvasAppState, Zoom } from "../types";
|
||||||
|
|
||||||
const GridLineColor = {
|
const GridLineColor = {
|
||||||
Bold: "#dddddd",
|
[THEME.LIGHT]: {
|
||||||
Regular: "#e5e5e5",
|
bold: "#dddddd",
|
||||||
|
regular: "#e5e5e5",
|
||||||
|
},
|
||||||
|
[THEME.DARK]: {
|
||||||
|
bold: applyDarkModeFilter("#dddddd"),
|
||||||
|
regular: applyDarkModeFilter("#e5e5e5"),
|
||||||
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
const strokeGrid = (
|
const strokeGrid = (
|
||||||
@@ -51,6 +62,7 @@ const strokeGrid = (
|
|||||||
scrollX: number,
|
scrollX: number,
|
||||||
scrollY: number,
|
scrollY: number,
|
||||||
zoom: Zoom,
|
zoom: Zoom,
|
||||||
|
theme: StaticCanvasRenderConfig["theme"],
|
||||||
width: number,
|
width: number,
|
||||||
height: number,
|
height: number,
|
||||||
) => {
|
) => {
|
||||||
@@ -86,7 +98,9 @@ const strokeGrid = (
|
|||||||
|
|
||||||
context.beginPath();
|
context.beginPath();
|
||||||
context.setLineDash(isBold ? [] : lineDash);
|
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.moveTo(x, offsetY - gridSize);
|
||||||
context.lineTo(x, Math.ceil(offsetY + height + gridSize * 2));
|
context.lineTo(x, Math.ceil(offsetY + height + gridSize * 2));
|
||||||
context.stroke();
|
context.stroke();
|
||||||
@@ -105,7 +119,9 @@ const strokeGrid = (
|
|||||||
|
|
||||||
context.beginPath();
|
context.beginPath();
|
||||||
context.setLineDash(isBold ? [] : lineDash);
|
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.moveTo(offsetX - gridSize, y);
|
||||||
context.lineTo(Math.ceil(offsetX + width + gridSize * 2), y);
|
context.lineTo(Math.ceil(offsetX + width + gridSize * 2), y);
|
||||||
context.stroke();
|
context.stroke();
|
||||||
@@ -252,6 +268,7 @@ const _renderStaticScene = ({
|
|||||||
appState.scrollX,
|
appState.scrollX,
|
||||||
appState.scrollY,
|
appState.scrollY,
|
||||||
appState.zoom,
|
appState.zoom,
|
||||||
|
renderConfig.theme,
|
||||||
normalizedWidth / appState.zoom.value,
|
normalizedWidth / appState.zoom.value,
|
||||||
normalizedHeight / appState.zoom.value,
|
normalizedHeight / appState.zoom.value,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user