Sync panel props to editing element (#470)

* ensure panel props are sync to editing elem

* ensure we don't create empty-text elements (fixes #468)

* remove dead code

Co-authored-by: Christopher Chedeau <vjeuxx@gmail.com>
This commit is contained in:
David Luzar 2020-01-21 00:16:22 +01:00 committed by Christopher Chedeau
parent ff7a340d2f
commit 2340dddaad
7 changed files with 159 additions and 100 deletions

View file

@ -12,7 +12,7 @@ const Picker = function({
onChange
}: {
colors: string[];
color: string | undefined;
color: string | null;
onChange: (color: string) => void;
}) {
return (
@ -55,7 +55,7 @@ function ColorInput({
color,
onChange
}: {
color: string | undefined;
color: string | null;
onChange: (color: string) => void;
}) {
const colorRegex = /^([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8}|transparent)$/;
@ -93,7 +93,7 @@ export function ColorPicker({
onChange
}: {
type: "canvasBackground" | "elementBackground" | "elementStroke";
color: string | undefined;
color: string | null;
onChange: (color: string) => void;
}) {
const [isActive, setActive] = React.useState(false);
@ -119,7 +119,7 @@ export function ColorPicker({
<Popover onCloseRequest={() => setActive(false)}>
<Picker
colors={colors[type]}
color={color || undefined}
color={color || null}
onChange={changedColor => {
onChange(changedColor);
}}