-
-
Notifications
You must be signed in to change notification settings - Fork 612
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Vadim Demedes
authored
Jun 13, 2020
1 parent
125148a
commit 706fdb2
Showing
10 changed files
with
891 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
'use strict'; | ||
require('import-jsx')('./use-focus'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* eslint-disable react/prop-types */ | ||
'use strict'; | ||
const React = require('react'); | ||
const {render, Box, Text, Color, useFocus} = require('../..'); | ||
|
||
const Focus = () => ( | ||
<Box flexDirection="column" padding={1}> | ||
<Box marginBottom={1}> | ||
Press Tab to focus next element, Shift+Tab to focus previous element, Esc | ||
to reset focus. | ||
</Box> | ||
<Item label="First" /> | ||
<Item label="Second" /> | ||
<Item label="Third" /> | ||
</Box> | ||
); | ||
|
||
const Item = ({label}) => { | ||
const {isFocused} = useFocus(); | ||
return ( | ||
<Text> | ||
{label} {isFocused && <Color green>(focused)</Color>} | ||
</Text> | ||
); | ||
}; | ||
|
||
render(<Focus />); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.