-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
114 lines (103 loc) · 3.47 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import React from "react"
import "../styles/ui.scss"
function App() {
const [words, setWords] = React.useState(2)
const [separator, setSeparator] = React.useState("-")
const [letters, setLetters] = React.useState(undefined)
const [ubuntu, setUbuntu] = React.useState(true)
const onGenerate = () => {
parent.postMessage({ pluginMessage: { type: "generate-petnames", words, separator, letters, ubuntu } }, "*")
}
const onCancel = () => {
parent.postMessage({ pluginMessage: { type: "cancel" } }, "*")
}
return (
<div
style={{
paddingLeft: "24px",
paddingRight: "24px",
paddingBottom: "24px",
}}
>
<header
style={{
display: "flex",
alignItems: "flex-end",
}}
>
<img
src={require("./canonical.svg")}
alt="Canonical Logo"
style={{
maxWidth: "32px",
marginRight: "8px",
}}
/>
<h2
style={{
margin: "0",
verticalAlign: "bottom",
}}
>
Petname generator
</h2>
</header>
<div
style={{
margin: "24px 0",
}}
>
<div>
<h4>Amount of words</h4>
<select name="words" id="words" defaultValue="2" onChange={(e) => setWords(Number(e.target.value))}>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</div>
<div>
<h4>Separator</h4>
<input
type="text"
id="separator"
name="separator"
onChange={(e) => setSeparator(e.target.value)}
minLength={0}
maxLength={1}
placeholder="-"
/>
</div>
<div>
<h4>Word length</h4>
<input type="number" id="letters" name="letters" onChange={(e) => setLetters(e.target.value)} />
</div>
<div>
<h4>Ubuntu style?</h4>
<input
type="checkbox"
id="ubuntu"
name="ubuntu"
defaultChecked
onChange={(e) => setUbuntu(e.target.checked)}
/>
</div>
</div>
<footer
style={{
width: "100%",
display: "flex",
justifyContent: "flex-end",
}}
>
<div>
<button onClick={onCancel}>Cancel</button>
<button className="p-button--positive" id="generate" onClick={onGenerate}>
Generate
</button>
</div>
</footer>
</div>
)
}
export default App