Formatting tweak

This commit is contained in:
Bradlee Speice 2024-12-11 17:31:34 -05:00
parent f643996128
commit 192286a86a

View File

@ -1,6 +1,5 @@
import React, {useEffect, useState, createContext, useRef} from "react"; import React, {useEffect, useState, createContext, useRef} from "react";
import {useColorMode} from "@docusaurus/theme-common"; import {useColorMode} from "@docusaurus/theme-common";
import BrowserOnly from "@docusaurus/BrowserOnly";
type PainterProps = { type PainterProps = {
width: number; width: number;
@ -76,13 +75,18 @@ export const Canvas: React.FC<CanvasProps> = ({style, children}) => {
} }
}, [painter]); }, [painter]);
const filter = useColorMode().colorMode === 'dark' ? 'invert(1)' : ''; const canvasProps = {
ref: canvasRef,
width,
height,
style: {filter: useColorMode().colorMode === 'dark' ? 'invert(1)' : ''}
}
return ( return (
<> <>
<center> <center>
<div ref={sizingRef} style={style}> <div ref={sizingRef} style={style}>
{width > 0 ? <canvas ref={canvasRef} width={width} height={height} style={{filter}}/> : null} {width > 0 ? <canvas {...canvasProps}/> : null}
</div> </div>
</center> </center>
<PainterContext.Provider value={{width, height, setPainter}}> <PainterContext.Provider value={{width, height, setPainter}}>