From 7ef83dc508484f0818e0b7eb4cc3f50d134a1de0 Mon Sep 17 00:00:00 2001 From: Steve Ruiz Date: Thu, 27 May 2021 18:59:40 +0100 Subject: [PATCH] Adds drawing --- components/panel.tsx | 32 ++--- components/style-panel/color-picker.tsx | 4 +- components/style-panel/style-panel.tsx | 7 +- components/toolbar.tsx | 7 + hooks/useKeyboardEvents.ts | 4 + lib/shape-utils/draw.tsx | 162 ++++++++++++++++++++++++ lib/shape-utils/index.tsx | 9 ++ state/commands/index.ts | 2 + state/commands/points.ts | 28 ++++ state/sessions/draw-session.ts | 57 +++++++++ state/sessions/index.ts | 16 ++- state/state.ts | 44 +++++++ types.ts | 8 ++ 13 files changed, 353 insertions(+), 27 deletions(-) create mode 100644 lib/shape-utils/draw.tsx create mode 100644 state/commands/points.ts create mode 100644 state/sessions/draw-session.ts diff --git a/components/panel.tsx b/components/panel.tsx index 3c74c9989..7078d3ce5 100644 --- a/components/panel.tsx +++ b/components/panel.tsx @@ -31,7 +31,7 @@ export const Layout = styled("div", { gridTemplateRows: "auto 1fr", gridAutoRows: "28px", height: "100%", - width: "100%", + width: "auto", minWidth: "100%", maxWidth: 560, overflow: "hidden", @@ -41,30 +41,32 @@ export const Layout = styled("div", { export const Header = styled("div", { pointerEvents: "all", - display: "grid", - gridTemplateColumns: "auto 1fr auto", + display: "flex", + width: "100%", alignItems: "center", - justifyContent: "center", + justifyContent: "space-between", borderBottom: "1px solid $border", - - "& button": { - gridColumn: "1", - gridRow: "1", - }, + position: "relative", "& h3": { - gridColumn: "1 / span 3", - gridRow: "1", + position: "absolute", + top: 0, + left: 0, + width: "100%", + height: "100%", textAlign: "center", - margin: "0", - padding: "0", + padding: 0, + margin: 0, + display: "flex", + justifyContent: "center", + alignItems: "center", fontSize: "13px", + pointerEvents: "none", + userSelect: "none", }, }) export const ButtonsGroup = styled("div", { - gridRow: "1", - gridColumn: "3", display: "flex", }) diff --git a/components/style-panel/color-picker.tsx b/components/style-panel/color-picker.tsx index 680663125..7d74e0d44 100644 --- a/components/style-panel/color-picker.tsx +++ b/components/style-panel/color-picker.tsx @@ -98,8 +98,8 @@ const CurrentColor = styled(DropdownMenu.Trigger, { content: "''", position: "absolute", top: 0, - left: 4, - right: 4, + left: 0, + right: 0, bottom: 0, pointerEvents: "none", zIndex: -1, diff --git a/components/style-panel/style-panel.tsx b/components/style-panel/style-panel.tsx index f7ed3ccca..52e64455f 100644 --- a/components/style-panel/style-panel.tsx +++ b/components/style-panel/style-panel.tsx @@ -73,9 +73,6 @@ function SelectedShapeStyles({}: {}) { return ( - state.send("TOGGLED_STYLE_PANEL_OPEN")}> - -

Style

+ state.send("TOGGLED_STYLE_PANEL_OPEN")}> + +
Select +