pass theme as context

This commit is contained in:
Vinzenz Schroeter 2024-05-06 14:06:53 +02:00
parent ba56edf588
commit 8f497cae85
5 changed files with 37 additions and 41 deletions

View file

@ -1,5 +1,5 @@
import {hslToString, Theme} from '../theme.ts';
import {useEffect, useRef} from 'react';
import {hslToString, ThemeContext} from '../theme.ts';
import {useContext, useEffect, useRef} from 'react';
import './PixelGridCanvas.css';
const pixelsPerRow = 352;
@ -104,10 +104,10 @@ function drawPixelsToCanvas(
context.putImageData(imageData, 0, 0);
}
export default function PixelGridCanvas({pixels, theme}: {
export default function PixelGridCanvas({pixels}: {
readonly pixels: Uint8ClampedArray;
readonly theme: Theme;
}) {
const theme = useContext(ThemeContext);
const canvasRef = useRef<HTMLCanvasElement>(null);
useEffect(() => {