mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fixup! Extract available shapes to one place
This commit is contained in:
parent
5843b6a890
commit
19d5c7e730
1 changed files with 14 additions and 26 deletions
|
@ -590,29 +590,6 @@ class App extends React.Component<{}, AppState> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private renderOption({
|
|
||||||
type,
|
|
||||||
children
|
|
||||||
}: {
|
|
||||||
type: string;
|
|
||||||
children: React.ReactNode;
|
|
||||||
}) {
|
|
||||||
return (
|
|
||||||
<label>
|
|
||||||
<input
|
|
||||||
type="radio"
|
|
||||||
checked={this.state.elementType === type}
|
|
||||||
onChange={() => {
|
|
||||||
this.setState({ elementType: type });
|
|
||||||
clearSelection();
|
|
||||||
this.forceUpdate();
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<span>{children}</span>
|
|
||||||
</label>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
@ -657,9 +634,20 @@ class App extends React.Component<{}, AppState> {
|
||||||
>
|
>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Shapes</legend>
|
<legend>Shapes</legend>
|
||||||
{SHAPES.map(shape =>
|
{SHAPES.map(({ value, label }) => (
|
||||||
this.renderOption({ type: shape.value, children: shape.label })
|
<label>
|
||||||
)}
|
<input
|
||||||
|
type="radio"
|
||||||
|
checked={this.state.elementType === value}
|
||||||
|
onChange={() => {
|
||||||
|
this.setState({ elementType: value });
|
||||||
|
clearSelection();
|
||||||
|
this.forceUpdate();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<span>{label}</span>
|
||||||
|
</label>
|
||||||
|
))}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<canvas
|
<canvas
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue