-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathuseFocus.res
More file actions
36 lines (32 loc) · 753 Bytes
/
useFocus.res
File metadata and controls
36 lines (32 loc) · 753 Bytes
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
open Ink
module Item = {
@react.component
let make = (~label) => {
let {isFocused} = useFocus()
<Text>
{React.string(label)}
{switch isFocused {
| true => <Text color=#green> {React.string(" (focused)")} </Text>
| false => React.null
}}
</Text>
}
}
module Focus = {
@react.component
let make = () => {
<Box flexDirection=#column padding={1}>
<Box marginBottom={1}>
<Text>
{React.string(
"Press Tab to focus next element, Shift+Tab to focus previous element, Esc to reset focus.",
)}
</Text>
</Box>
<Item label="First" />
<Item label="Second" />
<Item label="Third" />
</Box>
}
}
let _ = render(<Focus />, ())