This repository was archived by the owner on Oct 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathInputsWrapper.js
245 lines (239 loc) · 5.01 KB
/
InputsWrapper.js
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
import React from "react";
import TextInput from "@yoast/components/src/inputs/TextInput";
import DurationInput from "@yoast/components/src/inputs/DurationInput";
import TextArea from "@yoast/components/src/inputs/TextArea";
import CheckboxGroup from "@yoast/components/src/checkbox/CheckboxGroup";
import RadioButtonGroup from "@yoast/components/src/radiobutton/RadioButtonGroup";
import { MultiSelect, Select } from "@yoast/components/src/select/Select";
import Toggle from "@yoast/components/src/toggle/Toggle";
import DataModel from "@yoast/components/src/data-model/DataModel";
/* eslint-disable require-jsdoc */
class DurationInputWrapper extends React.Component {
constructor( props ) {
super( props );
this.state = {
duration: props.duration,
};
this.onChange = this.onChange.bind( this );
}
onChange( value ) {
this.setState( {
duration: value,
} );
}
render() {
return (
<DurationInput
duration={ this.state.duration }
label="Duration"
id="duration-input"
onChange={ this.onChange }
/>
);
}
}
/**
* Function that displays all the reactified components that we currently have.
*
* @returns {*} A div with all reactified components.
*/
const InputsWrapper = () => {
return (
<div className="yoast">
<h2>Inputs</h2>
<TextInput
label="This is the input label"
value="This is the input value"
type="text"
id="input1"
/>
<TextInput
label="This input has a description"
description="Great description!"
type="text"
placeholder="The best placeholder ev4h"
id="input2"
/>
<TextInput
label="This is a number input"
description="The minimum number is 3 and the maximum is 6 (if you use arrow keys)."
type="number"
min={ 3 }
max={ 6 }
id="input3"
/>
<TextInput
label="This is a email input without description where the help links to google.com"
type="email"
linkTo="https://www.google.com"
id="input4"
/>
<TextInput
label="This is a password input"
type="password"
linkTo="https://www.google.com"
id="input5"
/>
<TextArea
label="This is a textarea"
placeholder="Ugly placeholder"
value="Wow, what happens now??"
description="The greatest textarea ever!!1!"
id="area1"
/>
<CheckboxGroup
label="Heya best checkboxes"
options={ [
{
label: "Fancy label",
id: "fancy-checkbox",
},
{
label: "option with id 1",
id: "horizontal-check-1",
},
] }
checked={ [ "fancy-checkbox" ] }
/>
<CheckboxGroup
label="Horizontal checkboxes"
vertical={ false }
options={ [
{
label: "Nice 1",
id: "id1",
},
{
label: "option with id 3",
id: "id3",
},
] }
checked={ [ "id1" ] }
onChange={ console.warn }
/>
<RadioButtonGroup
options={ [
{
value: "hey-value",
label: "Hey there!",
},
{
value: "hi-value",
label: "Hi there!",
},
] }
label="Horizontal radiobutton group"
groupName="group1"
selected="hey-value"
/>
<RadioButtonGroup
options={ [
{
value: "haha-value",
label: "Haha, that's funny!",
},
{
value: "hoho-value",
label: "Hohoho, I'm santa!",
},
] }
label="Vertical radiobutton group"
vertical={ true }
groupName="group2"
/>
<MultiSelect
label="This is a styled multiselect"
id="my-awesome-multiselect"
name="my-selection"
options={
[
{ name: "Option 1", value: "opt1" },
{ name: "Option 2", value: "opt2" },
{ name: "Option 3", value: "opt3" },
{ name: "Option 4", value: "opt4" },
]
}
selected={ [ "opt1", "opt3" ] }
/>
<Select
label="This is a styled select"
id="my-awesome-multiselect"
name="my-selection"
options={
[
{ name: "option 1", value: "opt1" },
{ name: "option 2", value: "opt2" },
{ name: "option 3", value: "opt3" },
{ name: "option 4", value: "opt4" },
]
}
selected={ "opt1" }
/>
<Toggle
label="React Toggle"
offText="off"
onText="on"
name="toggle"
id="weird-id-that-is-unique"
linkTo="https://yoast.com"
linkText="A helpful link!"
onChange={ console.warn }
/>
<DurationInputWrapper
duration={ 3723 }
/>
<hr />
<h2>DataModel</h2>
<DataModel
items={ [
{
width: 100,
name: "brand",
number: 66,
},
{
width: 77,
name: "strategie",
number: 66,
},
{
width: 45,
name: "tip",
number: 66,
},
{
width: 35,
name: "logo",
number: 66,
},
{
width: 30,
name: "name",
number: 66,
},
{
width: 20,
name: "SEO",
number: 66,
},
{
width: 10,
name: "people",
number: 66,
},
{
width: 5,
name: "image",
number: 66,
},
{
width: 1,
name: "post",
number: 66,
},
] }
/>
</div>
);
};
export default InputsWrapper;