diff --git a/.gitignore b/.gitignore index f171f6f93..46e15b10f 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ yarn.lock # Editors .vscode/ +.DS_Store \ No newline at end of file diff --git a/src/components/ButtonSelect.tsx b/src/components/ButtonSelect.tsx new file mode 100644 index 000000000..ec9b55f07 --- /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 000000000..65dfc78b5 --- /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 ( -
-
- {someElementIsSelected() && ( + {someElementIsSelected(elements) && (

Selection

@@ -1479,15 +367,19 @@ class App extends React.Component<{}, AppState> {
Stroke Color
element.strokeColor)} + color={getSelectedAttribute( + elements, + element => element.strokeColor + )} onChange={color => this.changeStrokeColor(color)} /> - {hasBackground() && ( + {hasBackground(elements) && ( <>
Background Color
element.backgroundColor )} onChange={color => this.changeBackgroundColor(color)} @@ -1499,7 +391,10 @@ class App extends React.Component<{}, AppState> { { value: "hachure", text: "Hachure" }, { value: "cross-hatch", text: "Cross-hatch" } ]} - value={getSelectedAttribute(element => element.fillStyle)} + value={getSelectedAttribute( + elements, + element => element.fillStyle + )} onChange={value => { this.changeProperty(element => { element.fillStyle = value; @@ -1509,7 +404,7 @@ class App extends React.Component<{}, AppState> { )} - {hasStroke() && ( + {hasStroke(elements) && ( <>
Stroke Width
{ { value: 2, text: "Bold" }, { value: 4, text: "Extra Bold" } ]} - value={getSelectedAttribute(element => element.strokeWidth)} + value={getSelectedAttribute( + elements, + element => element.strokeWidth + )} onChange={value => { this.changeProperty(element => { element.strokeWidth = value; @@ -1533,7 +431,10 @@ class App extends React.Component<{}, AppState> { { value: 1, text: "Artist" }, { value: 3, text: "Cartoonist" } ]} - value={getSelectedAttribute(element => element.roughness)} + value={getSelectedAttribute( + elements, + element => element.roughness + )} onChange={value => this.changeProperty(element => { element.roughness = value; @@ -1550,7 +451,7 @@ class App extends React.Component<{}, AppState> { max="100" onChange={this.changeOpacity} value={ - getSelectedAttribute(element => element.opacity) || + getSelectedAttribute(elements, element => element.opacity) || 0 /* Put the opacity at 0 if there are two conflicting ones */ } /> @@ -1586,7 +487,7 @@ class App extends React.Component<{}, AppState> {
Image