refactor: move setting blocks to welcomeBlocksData to canvas context

This commit is contained in:
trafficlunar 2025-01-21 20:38:11 +00:00
parent 17dc511053
commit 53f81040be
3 changed files with 4 additions and 7 deletions

View file

@ -1,5 +1,7 @@
import React, { createContext, ReactNode, useMemo, useState } from "react";
import welcomeBlocksData from "@/data/welcome.json";
interface Context {
stageSize: Dimension;
canvasSize: BoundingBox;
@ -21,8 +23,8 @@ interface Props {
export const CanvasContext = createContext<Context>({} as Context);
export const CanvasProvider = ({ children }: Props) => {
const [stageSize, setStageSize] = useState({ width: 0, height: 0 } as Dimension);
const [blocks, setBlocks] = useState<Block[]>([]);
const [stageSize, setStageSize] = useState<Dimension>({ width: 0, height: 0 });
const [blocks, setBlocks] = useState<Block[]>(welcomeBlocksData);
const [coords, setCoords] = useState<Position>({ x: 0, y: 0 });
const [scale, setScale] = useState(1);
const [version, setVersion] = useState(1214);