2020-03-01 14:39:03 -05:00
|
|
|
import React from "react";
|
|
|
|
import { menu, palette } from "../components/icons";
|
|
|
|
import { ToolButton } from "../components/ToolButton";
|
|
|
|
import { t } from "../i18n";
|
|
|
|
import { showSelectedShapeActions } from "../element";
|
2020-03-07 10:20:38 -05:00
|
|
|
import { register } from "./register";
|
2020-03-01 14:39:03 -05:00
|
|
|
|
2020-03-07 10:20:38 -05:00
|
|
|
export const actionToggleCanvasMenu = register({
|
2020-03-01 14:39:03 -05:00
|
|
|
name: "toggleCanvasMenu",
|
|
|
|
perform: (_, appState) => ({
|
|
|
|
appState: {
|
|
|
|
...appState,
|
|
|
|
openMenu: appState.openMenu === "canvas" ? null : "canvas",
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
PanelComponent: ({ appState, updateData }) => (
|
|
|
|
<ToolButton
|
|
|
|
type="button"
|
|
|
|
icon={menu}
|
|
|
|
aria-label={t("buttons.menu")}
|
|
|
|
onClick={updateData}
|
|
|
|
selected={appState.openMenu === "canvas"}
|
|
|
|
/>
|
|
|
|
),
|
2020-03-07 10:20:38 -05:00
|
|
|
});
|
2020-03-01 14:39:03 -05:00
|
|
|
|
2020-03-07 10:20:38 -05:00
|
|
|
export const actionToggleEditMenu = register({
|
2020-03-01 14:39:03 -05:00
|
|
|
name: "toggleEditMenu",
|
|
|
|
perform: (_elements, appState) => ({
|
|
|
|
appState: {
|
|
|
|
...appState,
|
|
|
|
openMenu: appState.openMenu === "shape" ? null : "shape",
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
PanelComponent: ({ elements, appState, updateData }) => (
|
|
|
|
<ToolButton
|
|
|
|
visible={showSelectedShapeActions(appState, elements)}
|
|
|
|
type="button"
|
|
|
|
icon={palette}
|
|
|
|
aria-label={t("buttons.edit")}
|
|
|
|
onClick={updateData}
|
|
|
|
selected={appState.openMenu === "shape"}
|
|
|
|
/>
|
|
|
|
),
|
2020-03-07 10:20:38 -05:00
|
|
|
});
|