@tactics/toddle-styleguide 0.0.7 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/App.d.ts +2 -0
- package/App.tsx +44 -1
- package/babel.config.js +1 -1
- package/index.d.ts +2 -0
- package/index.tsx +2 -0
- package/jest.config.js +22 -21
- package/package.json +11 -1
- package/src/components/atoms/calendar/__snapshots__/calendar.test.js.snap +16 -30
- package/src/components/atoms/calendar/calendar.component.d.ts +3 -2
- package/src/components/atoms/calendar/calendar.component.tsx +14 -6
- package/src/components/atoms/calendar/calendar.preview.tsx +4 -5
- package/src/components/atoms/calendar/calendar.test.js +3 -2
- package/src/components/atoms/date-input/__snapshots__/date-input.test.js.snap +101 -0
- package/src/components/atoms/date-input/date-input.component.d.ts +7 -0
- package/src/components/atoms/date-input/date-input.component.tsx +24 -0
- package/src/components/atoms/date-input/date-input.preview.d.ts +1 -0
- package/src/components/atoms/date-input/date-input.preview.tsx +60 -0
- package/src/components/atoms/date-input/date-input.styles.d.ts +24 -0
- package/src/components/atoms/date-input/date-input.styles.js +27 -0
- package/src/components/atoms/date-input/date-input.test.js +19 -0
- package/src/components/atoms/day-select/components/day/day.component.d.ts +8 -0
- package/src/components/atoms/day-select/components/day/day.component.tsx +42 -0
- package/src/components/atoms/day-select/components/day/day.styles.d.ts +37 -0
- package/src/components/atoms/day-select/components/day/day.styles.js +41 -0
- package/src/components/atoms/day-select/day-select-component.d.ts +8 -0
- package/src/components/atoms/day-select/day-select-component.tsx +90 -0
- package/src/components/atoms/day-select/day-select.preview.d.ts +1 -0
- package/src/components/atoms/day-select/day-select.preview.tsx +18 -0
- package/src/components/atoms/day-select/day-select.styles.d.ts +10 -0
- package/src/components/atoms/day-select/day-select.styles.js +14 -0
- package/src/components/atoms/filter-range/__snapshots__/filter-range.test.js.snap +184 -0
- package/src/components/atoms/filter-range/filter-range.component.d.ts +10 -0
- package/src/components/atoms/filter-range/filter-range.component.tsx +66 -0
- package/src/components/atoms/filter-range/filter-range.preview.d.ts +1 -0
- package/src/components/atoms/filter-range/filter-range.preview.tsx +48 -0
- package/src/components/atoms/filter-range/filter-range.styles.d.ts +32 -0
- package/src/components/atoms/filter-range/filter-range.styles.js +35 -0
- package/src/components/atoms/filter-range/filter-range.test.js +20 -0
- package/src/components/atoms/popover/components/modal/modal.styles.js +1 -0
- package/src/components/atoms/popover/popover.preview.d.ts +1 -0
- package/src/components/atoms/popover/popover.preview.tsx +96 -93
- package/src/components/atoms/select-picker/__snapshots__/select-picker.test.js.snap +353 -0
- package/src/components/atoms/select-picker/select-picker.component.d.ts +11 -0
- package/src/components/atoms/select-picker/select-picker.component.tsx +70 -0
- package/src/components/atoms/select-picker/select-picker.preview.d.ts +1 -0
- package/src/components/atoms/select-picker/select-picker.preview.tsx +63 -0
- package/src/components/atoms/select-picker/select-picker.styles.d.ts +33 -0
- package/src/components/atoms/select-picker/select-picker.styles.js +38 -0
- package/src/components/atoms/select-picker/select-picker.test.js +31 -0
- package/src/theme/scale/index.d.ts +10 -10
- package/src/util/date.d.ts +3 -0
- package/src/util/date.tsx +9 -0
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Select Picker test renders a picker with placeholder text 1`] = `
|
|
4
|
+
<View
|
|
5
|
+
style={
|
|
6
|
+
{
|
|
7
|
+
"alignItems": "center",
|
|
8
|
+
"backgroundColor": "#FFFFFF",
|
|
9
|
+
"borderColor": "#E5E8EB",
|
|
10
|
+
"borderRadius": 8,
|
|
11
|
+
"borderStyle": "solid",
|
|
12
|
+
"borderWidth": 1,
|
|
13
|
+
"flexDirection": "row",
|
|
14
|
+
"height": 48,
|
|
15
|
+
"justifyContent": "center",
|
|
16
|
+
"paddingBottom": 8,
|
|
17
|
+
"paddingLeft": 16,
|
|
18
|
+
"paddingRight": 16,
|
|
19
|
+
"paddingTop": 8,
|
|
20
|
+
"width": "100%",
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
>
|
|
24
|
+
<View
|
|
25
|
+
style={
|
|
26
|
+
{
|
|
27
|
+
"alignItems": "center",
|
|
28
|
+
"height": "100%",
|
|
29
|
+
"justifyContent": "center",
|
|
30
|
+
"width": "100%",
|
|
31
|
+
"zIndex": 1,
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
>
|
|
35
|
+
<View
|
|
36
|
+
style={
|
|
37
|
+
[
|
|
38
|
+
{
|
|
39
|
+
"alignSelf": "stretch",
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"flex": 1,
|
|
43
|
+
"justifyContent": "center",
|
|
44
|
+
},
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
>
|
|
48
|
+
<View
|
|
49
|
+
accessible={true}
|
|
50
|
+
collapsable={false}
|
|
51
|
+
focusable={true}
|
|
52
|
+
onClick={[Function]}
|
|
53
|
+
onResponderGrant={[Function]}
|
|
54
|
+
onResponderMove={[Function]}
|
|
55
|
+
onResponderRelease={[Function]}
|
|
56
|
+
onResponderTerminate={[Function]}
|
|
57
|
+
onResponderTerminationRequest={[Function]}
|
|
58
|
+
onStartShouldSetResponder={[Function]}
|
|
59
|
+
style={
|
|
60
|
+
{
|
|
61
|
+
"opacity": 1,
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
testID="ios_touchable_wrapper"
|
|
65
|
+
>
|
|
66
|
+
<View
|
|
67
|
+
pointerEvents="box-only"
|
|
68
|
+
style={
|
|
69
|
+
{
|
|
70
|
+
"height": "100%",
|
|
71
|
+
"justifyContent": "flex-start",
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
>
|
|
75
|
+
<TextInput
|
|
76
|
+
editable={false}
|
|
77
|
+
style={
|
|
78
|
+
[
|
|
79
|
+
{
|
|
80
|
+
"alignItems": "center",
|
|
81
|
+
"color": "#9AA5B1",
|
|
82
|
+
"fontFamily": "SourceSansPro",
|
|
83
|
+
"fontSize": 16,
|
|
84
|
+
"justifyContent": "center",
|
|
85
|
+
"lineHeight": 22.4,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"color": "#c7c7cd",
|
|
89
|
+
},
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
testID="text_input"
|
|
93
|
+
value="Choose..."
|
|
94
|
+
/>
|
|
95
|
+
</View>
|
|
96
|
+
</View>
|
|
97
|
+
<Modal
|
|
98
|
+
hardwareAccelerated={false}
|
|
99
|
+
onOrientationChange={[Function]}
|
|
100
|
+
supportedOrientations={
|
|
101
|
+
[
|
|
102
|
+
"portrait",
|
|
103
|
+
"landscape",
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
testID="ios_modal"
|
|
107
|
+
transparent={true}
|
|
108
|
+
visible={false}
|
|
109
|
+
/>
|
|
110
|
+
</View>
|
|
111
|
+
</View>
|
|
112
|
+
<View
|
|
113
|
+
style={
|
|
114
|
+
{
|
|
115
|
+
"alignItems": "center",
|
|
116
|
+
"height": "100%",
|
|
117
|
+
"justifyContent": "center",
|
|
118
|
+
"position": "absolute",
|
|
119
|
+
"right": 16,
|
|
120
|
+
"width": "10%",
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
>
|
|
124
|
+
<RNSVGSvgView
|
|
125
|
+
align="xMidYMid"
|
|
126
|
+
bbHeight="28"
|
|
127
|
+
bbWidth="28"
|
|
128
|
+
fill="none"
|
|
129
|
+
focusable={false}
|
|
130
|
+
height="28"
|
|
131
|
+
meetOrSlice={0}
|
|
132
|
+
minX={0}
|
|
133
|
+
minY={0}
|
|
134
|
+
style={
|
|
135
|
+
[
|
|
136
|
+
{
|
|
137
|
+
"backgroundColor": "transparent",
|
|
138
|
+
"borderWidth": 0,
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"flex": 0,
|
|
142
|
+
"height": 28,
|
|
143
|
+
"width": 28,
|
|
144
|
+
},
|
|
145
|
+
]
|
|
146
|
+
}
|
|
147
|
+
vbHeight={27}
|
|
148
|
+
vbWidth={26}
|
|
149
|
+
width="28"
|
|
150
|
+
>
|
|
151
|
+
<RNSVGGroup
|
|
152
|
+
fill={null}
|
|
153
|
+
propList={
|
|
154
|
+
[
|
|
155
|
+
"fill",
|
|
156
|
+
]
|
|
157
|
+
}
|
|
158
|
+
>
|
|
159
|
+
<RNSVGPath
|
|
160
|
+
d="M8.66663 10.125L13 5.625L17.3333 10.125M17.3333 16.875L13 21.375L8.66663 16.875"
|
|
161
|
+
propList={
|
|
162
|
+
[
|
|
163
|
+
"stroke",
|
|
164
|
+
"strokeWidth",
|
|
165
|
+
"strokeLinecap",
|
|
166
|
+
"strokeLinejoin",
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
stroke={4280232243}
|
|
170
|
+
strokeLinecap={1}
|
|
171
|
+
strokeLinejoin={1}
|
|
172
|
+
strokeWidth="2"
|
|
173
|
+
/>
|
|
174
|
+
</RNSVGGroup>
|
|
175
|
+
</RNSVGSvgView>
|
|
176
|
+
</View>
|
|
177
|
+
</View>
|
|
178
|
+
`;
|
|
179
|
+
|
|
180
|
+
exports[`Select Picker test renders a picker without placeholder text 1`] = `
|
|
181
|
+
<View
|
|
182
|
+
style={
|
|
183
|
+
{
|
|
184
|
+
"alignItems": "center",
|
|
185
|
+
"backgroundColor": "#FFFFFF",
|
|
186
|
+
"borderColor": "#E5E8EB",
|
|
187
|
+
"borderRadius": 8,
|
|
188
|
+
"borderStyle": "solid",
|
|
189
|
+
"borderWidth": 1,
|
|
190
|
+
"flexDirection": "row",
|
|
191
|
+
"height": 48,
|
|
192
|
+
"justifyContent": "center",
|
|
193
|
+
"paddingBottom": 8,
|
|
194
|
+
"paddingLeft": 16,
|
|
195
|
+
"paddingRight": 16,
|
|
196
|
+
"paddingTop": 8,
|
|
197
|
+
"width": "100%",
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
>
|
|
201
|
+
<View
|
|
202
|
+
style={
|
|
203
|
+
{
|
|
204
|
+
"alignItems": "center",
|
|
205
|
+
"height": "100%",
|
|
206
|
+
"justifyContent": "center",
|
|
207
|
+
"width": "100%",
|
|
208
|
+
"zIndex": 1,
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
>
|
|
212
|
+
<View
|
|
213
|
+
style={
|
|
214
|
+
[
|
|
215
|
+
{
|
|
216
|
+
"alignSelf": "stretch",
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
"flex": 1,
|
|
220
|
+
"justifyContent": "center",
|
|
221
|
+
},
|
|
222
|
+
]
|
|
223
|
+
}
|
|
224
|
+
>
|
|
225
|
+
<View
|
|
226
|
+
accessible={true}
|
|
227
|
+
collapsable={false}
|
|
228
|
+
focusable={true}
|
|
229
|
+
onClick={[Function]}
|
|
230
|
+
onResponderGrant={[Function]}
|
|
231
|
+
onResponderMove={[Function]}
|
|
232
|
+
onResponderRelease={[Function]}
|
|
233
|
+
onResponderTerminate={[Function]}
|
|
234
|
+
onResponderTerminationRequest={[Function]}
|
|
235
|
+
onStartShouldSetResponder={[Function]}
|
|
236
|
+
style={
|
|
237
|
+
{
|
|
238
|
+
"opacity": 1,
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
testID="ios_touchable_wrapper"
|
|
242
|
+
>
|
|
243
|
+
<View
|
|
244
|
+
pointerEvents="box-only"
|
|
245
|
+
style={
|
|
246
|
+
{
|
|
247
|
+
"height": "100%",
|
|
248
|
+
"justifyContent": "flex-start",
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
>
|
|
252
|
+
<TextInput
|
|
253
|
+
editable={false}
|
|
254
|
+
style={
|
|
255
|
+
[
|
|
256
|
+
{
|
|
257
|
+
"alignItems": "center",
|
|
258
|
+
"color": "#9AA5B1",
|
|
259
|
+
"fontFamily": "SourceSansPro",
|
|
260
|
+
"fontSize": 16,
|
|
261
|
+
"justifyContent": "center",
|
|
262
|
+
"lineHeight": 22.4,
|
|
263
|
+
},
|
|
264
|
+
{},
|
|
265
|
+
]
|
|
266
|
+
}
|
|
267
|
+
testID="text_input"
|
|
268
|
+
value="an option"
|
|
269
|
+
/>
|
|
270
|
+
</View>
|
|
271
|
+
</View>
|
|
272
|
+
<Modal
|
|
273
|
+
hardwareAccelerated={false}
|
|
274
|
+
onOrientationChange={[Function]}
|
|
275
|
+
supportedOrientations={
|
|
276
|
+
[
|
|
277
|
+
"portrait",
|
|
278
|
+
"landscape",
|
|
279
|
+
]
|
|
280
|
+
}
|
|
281
|
+
testID="ios_modal"
|
|
282
|
+
transparent={true}
|
|
283
|
+
visible={false}
|
|
284
|
+
/>
|
|
285
|
+
</View>
|
|
286
|
+
</View>
|
|
287
|
+
<View
|
|
288
|
+
style={
|
|
289
|
+
{
|
|
290
|
+
"alignItems": "center",
|
|
291
|
+
"height": "100%",
|
|
292
|
+
"justifyContent": "center",
|
|
293
|
+
"position": "absolute",
|
|
294
|
+
"right": 16,
|
|
295
|
+
"width": "10%",
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
>
|
|
299
|
+
<RNSVGSvgView
|
|
300
|
+
align="xMidYMid"
|
|
301
|
+
bbHeight="28"
|
|
302
|
+
bbWidth="28"
|
|
303
|
+
fill="none"
|
|
304
|
+
focusable={false}
|
|
305
|
+
height="28"
|
|
306
|
+
meetOrSlice={0}
|
|
307
|
+
minX={0}
|
|
308
|
+
minY={0}
|
|
309
|
+
style={
|
|
310
|
+
[
|
|
311
|
+
{
|
|
312
|
+
"backgroundColor": "transparent",
|
|
313
|
+
"borderWidth": 0,
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
"flex": 0,
|
|
317
|
+
"height": 28,
|
|
318
|
+
"width": 28,
|
|
319
|
+
},
|
|
320
|
+
]
|
|
321
|
+
}
|
|
322
|
+
vbHeight={27}
|
|
323
|
+
vbWidth={26}
|
|
324
|
+
width="28"
|
|
325
|
+
>
|
|
326
|
+
<RNSVGGroup
|
|
327
|
+
fill={null}
|
|
328
|
+
propList={
|
|
329
|
+
[
|
|
330
|
+
"fill",
|
|
331
|
+
]
|
|
332
|
+
}
|
|
333
|
+
>
|
|
334
|
+
<RNSVGPath
|
|
335
|
+
d="M8.66663 10.125L13 5.625L17.3333 10.125M17.3333 16.875L13 21.375L8.66663 16.875"
|
|
336
|
+
propList={
|
|
337
|
+
[
|
|
338
|
+
"stroke",
|
|
339
|
+
"strokeWidth",
|
|
340
|
+
"strokeLinecap",
|
|
341
|
+
"strokeLinejoin",
|
|
342
|
+
]
|
|
343
|
+
}
|
|
344
|
+
stroke={4280232243}
|
|
345
|
+
strokeLinecap={1}
|
|
346
|
+
strokeLinejoin={1}
|
|
347
|
+
strokeWidth="2"
|
|
348
|
+
/>
|
|
349
|
+
</RNSVGGroup>
|
|
350
|
+
</RNSVGSvgView>
|
|
351
|
+
</View>
|
|
352
|
+
</View>
|
|
353
|
+
`;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare type PickerProps = {
|
|
2
|
+
placeholder?: string;
|
|
3
|
+
data: {
|
|
4
|
+
value: number | string;
|
|
5
|
+
label: string;
|
|
6
|
+
}[];
|
|
7
|
+
onChange: (item: string) => void;
|
|
8
|
+
defaultValue: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const SelectPicker: ({ placeholder, data, onChange, defaultValue, }: PickerProps) => JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import React, {useContext} from 'react';
|
|
2
|
+
import {View} from 'react-native';
|
|
3
|
+
import {ThemeCtx} from '../../../context/theme.context';
|
|
4
|
+
import {Stylesheet} from './select-picker.styles';
|
|
5
|
+
import {Icon} from '../../../icons';
|
|
6
|
+
|
|
7
|
+
import RNPickerSelect from 'react-native-picker-select';
|
|
8
|
+
import {Font} from '../../../theme/font';
|
|
9
|
+
|
|
10
|
+
type PickerProps = {
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
data: {
|
|
13
|
+
value: number | string;
|
|
14
|
+
label: string;
|
|
15
|
+
}[];
|
|
16
|
+
onChange: (item: string) => void;
|
|
17
|
+
defaultValue: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const SelectPicker = ({
|
|
21
|
+
placeholder,
|
|
22
|
+
data,
|
|
23
|
+
onChange,
|
|
24
|
+
defaultValue,
|
|
25
|
+
}: PickerProps) => {
|
|
26
|
+
const context = useContext(ThemeCtx);
|
|
27
|
+
const styles = Stylesheet(context);
|
|
28
|
+
|
|
29
|
+
const placeholderText = (placeholder: string | undefined) => {
|
|
30
|
+
if (placeholder) {
|
|
31
|
+
return {label: placeholder, value: null, color: context.colors.ui.grey};
|
|
32
|
+
} else {
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<View style={styles.container}>
|
|
39
|
+
<View style={styles.pickerContainer}>
|
|
40
|
+
<RNPickerSelect
|
|
41
|
+
placeholder={placeholderText(placeholder)}
|
|
42
|
+
onValueChange={onChange}
|
|
43
|
+
items={data}
|
|
44
|
+
value={defaultValue}
|
|
45
|
+
useNativeAndroidPickerStyle={false}
|
|
46
|
+
style={{
|
|
47
|
+
inputIOS: {
|
|
48
|
+
...Font.medium,
|
|
49
|
+
color: context.colors.ui.grey,
|
|
50
|
+
justifyContent: 'center',
|
|
51
|
+
alignItems: 'center',
|
|
52
|
+
},
|
|
53
|
+
inputIOSContainer: {
|
|
54
|
+
height: '100%',
|
|
55
|
+
justifyContent: 'flex-start',
|
|
56
|
+
},
|
|
57
|
+
viewContainer: {flex: 1, justifyContent: 'center'},
|
|
58
|
+
inputAndroid: {
|
|
59
|
+
...Font.medium,
|
|
60
|
+
color: context.colors.ui.grey,
|
|
61
|
+
},
|
|
62
|
+
}}
|
|
63
|
+
/>
|
|
64
|
+
</View>
|
|
65
|
+
<View style={styles.iconContainer}>
|
|
66
|
+
<Icon.Outline.Selector color={context.colors.ui.black} />
|
|
67
|
+
</View>
|
|
68
|
+
</View>
|
|
69
|
+
);
|
|
70
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SelectPickerPreview: ({}: {}) => JSX.Element;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React, {useState} from 'react';
|
|
2
|
+
import {SelectPicker} from './select-picker.component';
|
|
3
|
+
import {Text, useWindowDimensions} from 'react-native';
|
|
4
|
+
const {View} = require('react-native');
|
|
5
|
+
|
|
6
|
+
export const SelectPickerPreview = ({}: {}) => {
|
|
7
|
+
const full = useWindowDimensions();
|
|
8
|
+
const width = full.width;
|
|
9
|
+
|
|
10
|
+
const languages = [
|
|
11
|
+
{value: 'Dutch', label: 'Nederlands'},
|
|
12
|
+
{value: 'French', label: 'Français'},
|
|
13
|
+
{value: 'German', label: 'Deutsch'},
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
const colas = [
|
|
17
|
+
{value: 'Coca-Cola', label: 'Coca-Cola'},
|
|
18
|
+
{value: 'Pepsi', label: 'Pepsi'},
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
const [selectedLanguage, setSelectedLanguage] = useState('');
|
|
22
|
+
const [selectedCola, setSelectedCola] = useState('Coca-Cola');
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<View
|
|
26
|
+
style={{
|
|
27
|
+
flex: 1,
|
|
28
|
+
alignItems: 'center',
|
|
29
|
+
justifyContent: 'center',
|
|
30
|
+
}}
|
|
31
|
+
>
|
|
32
|
+
<View
|
|
33
|
+
style={{
|
|
34
|
+
width: width - 100,
|
|
35
|
+
}}
|
|
36
|
+
>
|
|
37
|
+
<Text>
|
|
38
|
+
{selectedLanguage
|
|
39
|
+
? `My native language is ${selectedLanguage}!`
|
|
40
|
+
: 'Please select your native language!'}
|
|
41
|
+
</Text>
|
|
42
|
+
<SelectPicker
|
|
43
|
+
key={1}
|
|
44
|
+
data={languages}
|
|
45
|
+
defaultValue={selectedLanguage}
|
|
46
|
+
onChange={setSelectedLanguage}
|
|
47
|
+
/>
|
|
48
|
+
<Text>
|
|
49
|
+
{selectedCola
|
|
50
|
+
? `${selectedCola} wins the Cola battle for me!`
|
|
51
|
+
: 'Please select your favorite!'}
|
|
52
|
+
</Text>
|
|
53
|
+
<SelectPicker
|
|
54
|
+
key={2}
|
|
55
|
+
placeholder={'Choose your cola!'}
|
|
56
|
+
data={colas}
|
|
57
|
+
defaultValue={selectedCola}
|
|
58
|
+
onChange={setSelectedCola}
|
|
59
|
+
/>
|
|
60
|
+
</View>
|
|
61
|
+
</View>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export function Stylesheet(Context: any): {
|
|
2
|
+
container: {
|
|
3
|
+
flexDirection: 'row';
|
|
4
|
+
justifyContent: 'center';
|
|
5
|
+
alignItems: 'center';
|
|
6
|
+
width: string;
|
|
7
|
+
height: number;
|
|
8
|
+
backgroundColor: any;
|
|
9
|
+
paddingTop: number;
|
|
10
|
+
paddingRight: number;
|
|
11
|
+
paddingBottom: number;
|
|
12
|
+
paddingLeft: number;
|
|
13
|
+
borderWidth: number;
|
|
14
|
+
borderStyle: 'solid';
|
|
15
|
+
borderColor: any;
|
|
16
|
+
borderRadius: number;
|
|
17
|
+
};
|
|
18
|
+
pickerContainer: {
|
|
19
|
+
width: string;
|
|
20
|
+
height: string;
|
|
21
|
+
justifyContent: 'center';
|
|
22
|
+
alignItems: 'center';
|
|
23
|
+
zIndex: number;
|
|
24
|
+
};
|
|
25
|
+
iconContainer: {
|
|
26
|
+
width: string;
|
|
27
|
+
height: string;
|
|
28
|
+
right: number;
|
|
29
|
+
justifyContent: 'center';
|
|
30
|
+
alignItems: 'center';
|
|
31
|
+
position: 'absolute';
|
|
32
|
+
};
|
|
33
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {StyleSheet} from 'react-native';
|
|
2
|
+
import {Font} from '../../../theme/font';
|
|
3
|
+
import {Scale} from '../../../theme/scale';
|
|
4
|
+
|
|
5
|
+
export const Stylesheet = (Context) =>
|
|
6
|
+
StyleSheet.create({
|
|
7
|
+
container: {
|
|
8
|
+
flexDirection: 'row',
|
|
9
|
+
justifyContent: 'center',
|
|
10
|
+
alignItems: 'center',
|
|
11
|
+
width: '100%',
|
|
12
|
+
height: Scale.xxl,
|
|
13
|
+
backgroundColor: Context.colors.ui.white,
|
|
14
|
+
paddingTop: Scale.xs,
|
|
15
|
+
paddingRight: Scale.m,
|
|
16
|
+
paddingBottom: Scale.xs,
|
|
17
|
+
paddingLeft: Scale.m,
|
|
18
|
+
borderWidth: 1,
|
|
19
|
+
borderStyle: 'solid',
|
|
20
|
+
borderColor: Context.colors.ui.lightgrey,
|
|
21
|
+
borderRadius: 8,
|
|
22
|
+
},
|
|
23
|
+
pickerContainer: {
|
|
24
|
+
width: '100%',
|
|
25
|
+
height: '100%',
|
|
26
|
+
justifyContent: 'center',
|
|
27
|
+
alignItems: 'center',
|
|
28
|
+
zIndex: 1,
|
|
29
|
+
},
|
|
30
|
+
iconContainer: {
|
|
31
|
+
width: '10%',
|
|
32
|
+
height: '100%',
|
|
33
|
+
right: 16,
|
|
34
|
+
justifyContent: 'center',
|
|
35
|
+
alignItems: 'center',
|
|
36
|
+
position: 'absolute',
|
|
37
|
+
},
|
|
38
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import render from 'react-test-renderer';
|
|
3
|
+
import {SelectPicker} from './select-picker.component';
|
|
4
|
+
|
|
5
|
+
describe('Select Picker test', () => {
|
|
6
|
+
it('renders a picker with placeholder text', function () {
|
|
7
|
+
const tree = render
|
|
8
|
+
.create(
|
|
9
|
+
<SelectPicker
|
|
10
|
+
data={[{value: 1, label: 'an option'}]}
|
|
11
|
+
defaultValue={'an option'}
|
|
12
|
+
onChange={() => console.log('changed')}
|
|
13
|
+
placeholder={'Choose...'}
|
|
14
|
+
/>
|
|
15
|
+
)
|
|
16
|
+
.toJSON();
|
|
17
|
+
expect(tree).toMatchSnapshot();
|
|
18
|
+
});
|
|
19
|
+
it('renders a picker without placeholder text', function () {
|
|
20
|
+
const tree = render
|
|
21
|
+
.create(
|
|
22
|
+
<SelectPicker
|
|
23
|
+
data={[{value: 1, label: 'an option'}]}
|
|
24
|
+
defaultValue={'an option'}
|
|
25
|
+
onChange={() => console.log('changed')}
|
|
26
|
+
/>
|
|
27
|
+
)
|
|
28
|
+
.toJSON();
|
|
29
|
+
expect(tree).toMatchSnapshot();
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export declare const Scale: {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
xxxs: number;
|
|
3
|
+
xxs: number;
|
|
4
|
+
xs: number;
|
|
5
|
+
s: number;
|
|
6
|
+
m: number;
|
|
7
|
+
l: number;
|
|
8
|
+
xl: number;
|
|
9
|
+
xxl: number;
|
|
10
|
+
xxxl: number;
|
|
11
|
+
xxxxl: number;
|
|
12
12
|
};
|