2020-01-12 02:22:03 +04:00
|
|
|
import React from "react";
|
|
|
|
import { Action } from "./types";
|
|
|
|
import { ColorPicker } from "../components/ColorPicker";
|
2020-01-11 20:34:21 -08:00
|
|
|
import { getDefaultAppState } from "../appState";
|
2020-01-15 20:42:02 +05:00
|
|
|
import { trash } from "../components/icons";
|
2020-01-25 14:52:03 -03:00
|
|
|
import { ToolButton } from "../components/ToolButton";
|
2020-01-31 21:06:06 +00:00
|
|
|
import { t } from "../i18n";
|
2020-01-12 02:22:03 +04:00
|
|
|
|
|
|
|
export const actionChangeViewBackgroundColor: Action = {
|
|
|
|
name: "changeViewBackgroundColor",
|
|
|
|
perform: (elements, appState, value) => {
|
|
|
|
return { appState: { ...appState, viewBackgroundColor: value } };
|
|
|
|
},
|
2020-01-31 21:06:06 +00:00
|
|
|
PanelComponent: ({ appState, updateData }) => {
|
2020-01-15 20:42:02 +05:00
|
|
|
return (
|
|
|
|
<div style={{ position: "relative" }}>
|
|
|
|
<ColorPicker
|
2020-01-25 19:37:58 -03:00
|
|
|
label={t("labels.canvasBackground")}
|
2020-01-15 20:42:02 +05:00
|
|
|
type="canvasBackground"
|
|
|
|
color={appState.viewBackgroundColor}
|
|
|
|
onChange={color => updateData(color)}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
2020-01-24 12:04:54 +02:00
|
|
|
},
|
2020-01-12 02:22:03 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
export const actionClearCanvas: Action = {
|
|
|
|
name: "clearCanvas",
|
2020-01-15 20:42:02 +05:00
|
|
|
perform: () => {
|
2020-01-12 02:22:03 +04:00
|
|
|
return {
|
|
|
|
elements: [],
|
2020-01-24 12:04:54 +02:00
|
|
|
appState: getDefaultAppState(),
|
2020-01-12 02:22:03 +04:00
|
|
|
};
|
|
|
|
},
|
2020-01-31 21:06:06 +00:00
|
|
|
PanelComponent: ({ updateData }) => (
|
2020-01-25 14:52:03 -03:00
|
|
|
<ToolButton
|
2020-01-12 02:22:03 +04:00
|
|
|
type="button"
|
2020-01-15 20:42:02 +05:00
|
|
|
icon={trash}
|
2020-01-21 01:14:10 +02:00
|
|
|
title={t("buttons.clearReset")}
|
|
|
|
aria-label={t("buttons.clearReset")}
|
2020-01-12 02:22:03 +04:00
|
|
|
onClick={() => {
|
2020-01-21 01:14:10 +02:00
|
|
|
if (window.confirm(t("alerts.clearReset"))) {
|
2020-01-17 11:25:05 +01:00
|
|
|
// TODO: Defined globally, since file handles aren't yet serializable.
|
|
|
|
// Once `FileSystemFileHandle` can be serialized, make this
|
|
|
|
// part of `AppState`.
|
|
|
|
(window as any).handle = null;
|
2020-01-12 02:22:03 +04:00
|
|
|
updateData(null);
|
|
|
|
}
|
|
|
|
}}
|
2020-01-15 20:42:02 +05:00
|
|
|
/>
|
2020-01-24 12:04:54 +02:00
|
|
|
),
|
2020-01-12 02:22:03 +04:00
|
|
|
};
|