-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselect_input_echo.js
More file actions
62 lines (57 loc) · 1.51 KB
/
select_input_echo.js
File metadata and controls
62 lines (57 loc) · 1.51 KB
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
let value = '';
const options = [
{ label: 'Rust', value: 'rust' },
{ label: 'JavaScript', value: 'javascript' },
{ label: 'TypeScript', value: 'typescript' }
];
function getSelectedLabel(nextValue) {
const option = options.find((item) => item.value === nextValue);
return option ? option.label : 'Nothing selected';
}
function handleChange(nextValue) {
value = nextValue;
App.requestRender();
}
function AppLayout() {
return View({
style: {
direction: 'column',
padding: 20,
spacing: 12
},
children: [
Text({
text: 'SelectInput Example',
style: {
fontSize: 24,
color: '#111111'
}
}),
SelectInput({
value,
placeholder: 'Choose a language',
options,
onChange: handleChange,
style: {
width: 320,
padding: 10,
borderWidth: 1,
borderRadius: 8,
borderColor: '#C7CDD4'
}
}),
Text({
text: `Selected label: ${getSelectedLabel(value)}`,
style: {
fontSize: 18,
color: '#333333'
}
})
]
});
}
App.run({
title: 'SelectInput Example',
windowSize: { width: 520, height: 260 },
render: AppLayout
});