import React from "react"; import { Action } from "./types"; import { ProjectName } from "../components/ProjectName"; import { saveAsJSON, loadFromJSON } from "../scene"; import { load, save } from "../components/icons"; import { ToolButton } from "../components/ToolButton"; import { t } from "../i18n"; import useIsMobile from "../is-mobile"; export const actionChangeProjectName: Action = { name: "changeProjectName", perform: (elements, appState, value) => { return { appState: { ...appState, name: value } }; }, PanelComponent: ({ appState, updateData }) => ( updateData(name)} /> ), }; export const actionChangeExportBackground: Action = { name: "changeExportBackground", perform: (elements, appState, value) => { return { appState: { ...appState, exportBackground: value } }; }, PanelComponent: ({ appState, updateData }) => ( ), }; export const actionSaveScene: Action = { name: "saveScene", perform: (elements, appState, value) => { saveAsJSON(elements, appState).catch(error => console.error(error)); return {}; }, PanelComponent: ({ updateData }) => ( updateData(null)} /> ), }; export const actionLoadScene: Action = { name: "loadScene", perform: ( elements, appState, { elements: loadedElements, appState: loadedAppState }, ) => { return { elements: loadedElements, appState: loadedAppState }; }, PanelComponent: ({ updateData }) => ( { loadFromJSON() .then(({ elements, appState }) => { updateData({ elements: elements, appState: appState }); }) .catch(error => console.error(error)); }} /> ), };