From 054669cfef234f223013e99d24c9d6b799d8165e Mon Sep 17 00:00:00 2001 From: Gasim Gasimzada Date: Mon, 6 Jan 2020 21:29:44 +0400 Subject: [PATCH] Extract components and shapes into their respective modules (#212) --- src/components/ButtonSelect.tsx | 25 ++++++ src/components/ColorPicker.tsx | 52 +++++++++++ src/components/EditableText.tsx | 2 +- src/index.tsx | 151 ++------------------------------ src/shapes.tsx | 70 +++++++++++++++ 5 files changed, 153 insertions(+), 147 deletions(-) create mode 100644 src/components/ButtonSelect.tsx create mode 100644 src/components/ColorPicker.tsx create mode 100644 src/shapes.tsx diff --git a/src/components/ButtonSelect.tsx b/src/components/ButtonSelect.tsx new file mode 100644 index 00000000..ec9b55f0 --- /dev/null +++ b/src/components/ButtonSelect.tsx @@ -0,0 +1,25 @@ +import React from "react"; + +export function ButtonSelect({ + options, + value, + onChange +}: { + options: { value: T; text: string }[]; + value: T | null; + onChange: (value: T) => void; +}) { + return ( +
+ {options.map(option => ( + + ))} +
+ ); +} diff --git a/src/components/ColorPicker.tsx b/src/components/ColorPicker.tsx new file mode 100644 index 00000000..65dfc78b --- /dev/null +++ b/src/components/ColorPicker.tsx @@ -0,0 +1,52 @@ +import React from "react"; +import { TwitterPicker } from "react-color"; + +export function ColorPicker({ + color, + onChange +}: { + color: string | null; + onChange: (color: string) => void; +}) { + const [isActive, setActive] = React.useState(false); + return ( +
+ - ))} -
- ); -} - -function ColorPicker({ - color, - onChange -}: { - color: string | null; - onChange: (color: string) => void; -}) { - const [isActive, setActive] = React.useState(false); - return ( -
-