Skip to content

Commit 7af6c38

Browse files
committed
Add controls to Playground - cancel, clear
1 parent 4dd7c11 commit 7af6c38

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

src/components/RunicPlayground/index.tsx

+27-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PlusIcon, ResetIcon } from "components/icons";
1+
import { CancelIcon, PlusIcon, ResetIcon, SpaceKeyIcon } from "components/icons";
22
import "./index.css";
33

44
import { RuneSVG } from "components/RuneSVG";
@@ -44,6 +44,11 @@ export class RunicPlayground extends Component<Props, State> {
4444
this.setState({ phoneticText: currentPhoneticText + phonemeString });
4545
};
4646

47+
addSpace = () => {
48+
const currentPhoneticText = this.state.phoneticText;
49+
this.setState({ phoneticText: currentPhoneticText + " " });
50+
};
51+
4752
resetRune = () => {
4853
const currentPhoneticText = this.state.phoneticText;
4954
this.setState({ phoneticText: currentPhoneticText });
@@ -97,14 +102,34 @@ export class RunicPlayground extends Component<Props, State> {
97102
</span>
98103
Add Phoneme
99104
</button>
105+
<button
106+
className="runic-playground__control-button"
107+
onClick={this.addSpace}
108+
>
109+
<span className="runic-playground__control-icon">
110+
<SpaceKeyIcon />
111+
</span>
112+
Spacebar
113+
</button>
114+
</div>
115+
<div className="runic-playground__controls">
100116
<button
101117
className="runic-playground__control-button"
102118
onClick={this.resetRune}
119+
>
120+
<span className="runic-playground__control-icon">
121+
<CancelIcon />
122+
</span>
123+
Cancel Rune
124+
</button>
125+
<button
126+
className="runic-playground__control-button"
127+
onClick={this.addPhoneme}
103128
>
104129
<span className="runic-playground__control-icon">
105130
<ResetIcon />
106131
</span>
107-
Reset Rune
132+
Clear Result
108133
</button>
109134
</div>
110135
<TextInput

src/components/icons.tsx

+16-1
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,28 @@ export const ResetIcon = (props: preact.JSX.HTMLAttributes) => (
209209
width="800px"
210210
height="800px"
211211
viewBox="0 0 24 24"
212-
fill="currentColor"
213212
xmlns="http://www.w3.org/2000/svg"
213+
fill="currentColor"
214+
{...props}
214215
>
215216
<path d="M12,2A10,10,0,1,0,22,12,10,10,0,0,0,12,2Zm0,18a8,8,0,0,1-8-8A7.92,7.92,0,0,1,5.69,7.1L16.9,18.31A7.92,7.92,0,0,1,12,20Zm6.31-3.1L7.1,5.69A7.92,7.92,0,0,1,12,4a8,8,0,0,1,8,8A7.92,7.92,0,0,1,18.31,16.9Z" />
216217
</svg>
217218
);
218219

220+
export const CancelIcon = (props: preact.JSX.HTMLAttributes) => (
221+
// @ts-ignore - HTML attributes are valid for SVG
222+
<svg
223+
width="800px"
224+
height="800px"
225+
viewBox="0 0 24 24"
226+
xmlns="http://www.w3.org/2000/svg"
227+
fill="currentColor"
228+
{...props}
229+
>
230+
<path d="M13.41,12l6.3-6.29a1,1,0,1,0-1.42-1.42L12,10.59,5.71,4.29A1,1,0,0,0,4.29,5.71L10.59,12l-6.3,6.29a1,1,0,0,0,0,1.42,1,1,0,0,0,1.42,0L12,13.41l6.29,6.3a1,1,0,0,0,1.42,0,1,1,0,0,0,0-1.42Z" />
231+
</svg>
232+
);
233+
219234
export const EnterKeyIcon = (props: preact.JSX.HTMLAttributes) => (
220235
// @ts-ignore - HTML attributes are valid for SVG
221236
<svg

0 commit comments

Comments
 (0)