mirror of
https://github.com/trafficlunar/blockmatic.git
synced 2026-06-28 06:34:13 +00:00
refactor: remove image context
This commit is contained in:
parent
aa58b31269
commit
f4ca910d4c
5 changed files with 52 additions and 119 deletions
|
|
@ -1,28 +0,0 @@
|
|||
import { createContext, ReactNode, useState } from "react";
|
||||
|
||||
interface Context {
|
||||
image: HTMLImageElement | undefined;
|
||||
imageDimensions: Dimension;
|
||||
usableBlocks: string[];
|
||||
setImage: React.Dispatch<React.SetStateAction<HTMLImageElement | undefined>>;
|
||||
setImageDimensions: React.Dispatch<React.SetStateAction<Dimension>>;
|
||||
setUsableBlocks: React.Dispatch<React.SetStateAction<string[]>>;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
export const ImageContext = createContext<Context>({} as Context);
|
||||
|
||||
export const ImageProvider = ({ children }: Props) => {
|
||||
const [image, setImage] = useState<HTMLImageElement>();
|
||||
const [imageDimensions, setImageDimensions] = useState<Dimension>({ width: 0, height: 0 });
|
||||
const [usableBlocks, setUsableBlocks] = useState<string[]>([]);
|
||||
|
||||
return (
|
||||
<ImageContext.Provider value={{ image, imageDimensions, usableBlocks, setImage, setImageDimensions, setUsableBlocks }}>
|
||||
{children}
|
||||
</ImageContext.Provider>
|
||||
);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue