mirror of
https://github.com/trafficlunar/blockmatic.git
synced 2026-06-28 06:34:13 +00:00
feat: part 2 of redesign of open image dialog
This commit is contained in:
parent
9833f8a63c
commit
6996c9a310
6 changed files with 73 additions and 24 deletions
|
|
@ -3,8 +3,10 @@ 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 {
|
||||
|
|
@ -16,6 +18,11 @@ 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, setImage, setImageDimensions }}>{children}</ImageContext.Provider>;
|
||||
return (
|
||||
<ImageContext.Provider value={{ image, imageDimensions, usableBlocks, setImage, setImageDimensions, setUsableBlocks }}>
|
||||
{children}
|
||||
</ImageContext.Provider>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue