mirror of
https://github.com/trafficlunar/blockmatic.git
synced 2026-06-28 06:34:13 +00:00
feat: tool radius
This commit is contained in:
parent
933b287f9a
commit
7803275267
8 changed files with 103 additions and 32 deletions
|
|
@ -6,15 +6,18 @@ interface Props {
|
|||
|
||||
export const ToolContext = createContext({
|
||||
tool: "hand" as Tool,
|
||||
radius: 1,
|
||||
selectedBlock: "stone",
|
||||
cssCursor: "pointer",
|
||||
setTool: (tool: Tool) => {},
|
||||
setSelectedBlock: (block: string) => {},
|
||||
setCssCursor: (cursor: string) => {},
|
||||
setTool: ((tool: Tool) => {}) as React.Dispatch<React.SetStateAction<Tool>>,
|
||||
setRadius: ((value: number) => {}) as React.Dispatch<React.SetStateAction<number>>,
|
||||
setSelectedBlock: ((block: string) => {}) as React.Dispatch<React.SetStateAction<string>>,
|
||||
setCssCursor: ((cursor: string) => {}) as React.Dispatch<React.SetStateAction<string>>,
|
||||
});
|
||||
|
||||
export const ToolProvider = ({ children }: Props) => {
|
||||
const [tool, setTool] = useState<Tool>("hand");
|
||||
const [radius, setRadius] = useState(1);
|
||||
const [selectedBlock, setSelectedBlock] = useState("stone");
|
||||
const [cssCursor, setCssCursor] = useState("pointer");
|
||||
|
||||
|
|
@ -33,5 +36,9 @@ export const ToolProvider = ({ children }: Props) => {
|
|||
}
|
||||
}, [tool]);
|
||||
|
||||
return <ToolContext.Provider value={{ tool, selectedBlock, cssCursor, setTool, setSelectedBlock, setCssCursor }}>{children}</ToolContext.Provider>;
|
||||
return (
|
||||
<ToolContext.Provider value={{ tool, radius, selectedBlock, cssCursor, setTool, setRadius, setSelectedBlock, setCssCursor }}>
|
||||
{children}
|
||||
</ToolContext.Provider>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue