-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: added
<AutofocusContainer />
comp docs (#310)
* Add AutofocusContainer doc * add components category * update hooks category * move AMAProvider into components * removed props from usage * updated warning
- Loading branch information
Showing
5 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
File renamed without changes.
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,59 @@ | ||
# AutofocusContainer | ||
|
||
It is a utility component that automatically calls the [useFocus](../hooks/useFocus) hook when it is mounted. | ||
|
||
## Usage | ||
|
||
```jsx | ||
import { AutofocusContainer } from 'react-native-ama'; | ||
|
||
<AutofocusContainer>{children}</AutofocusContainer>; | ||
``` | ||
|
||
## Example | ||
|
||
This component can be used to move the focus on dynamically shown components, for example: | ||
|
||
```jsx title="UseTimedAction.screen.tsx" | ||
<View style={styles.centeredView}> | ||
<CTAPressable title="Show timed content" onPress={handleOnPress} /> | ||
{showContent ? ( | ||
<AutofocusContainer> | ||
<Text>Great! You did it :)</Text> | ||
<Spacer height="big" /> | ||
<CTAPressable title="Show home screen" /> | ||
</AutofocusContainer> | ||
) : null} | ||
</View> | ||
``` | ||
|
||
In this example, we want to move the focus to the view rendered once the user taps on "Show timed content". | ||
|
||
## Accessibility | ||
|
||
- Once the focus is moved makes, the screen reader announces all the text present in that container | ||
|
||
## Props | ||
|
||
### `accessibilityLabel` | ||
|
||
The label to assign to the wrapping View container. | ||
|
||
### `wrapChildrenInAccessibleView` | ||
|
||
Weather or not the child should be wrapped in an accessible View. By default, this is the case. | ||
|
||
:::warning | ||
**Autofocus may not work as expected when this prop is false!** | ||
|
||
If `wrapChildrenInAccessibleView` is set to `false` the children of the AutofocusContainer will not be wrapped in an accessible view and **autofocus** will only works if the container contains accessible elements, like Text, Buttons, etc. | ||
|
||
::: | ||
|
||
| Type | Default | | ||
| ------- | ------- | | ||
| boolean | true | | ||
|
||
## Related guidelines | ||
|
||
- [Focus](/guidelines/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,5 @@ | ||
{ | ||
"label": "Components", | ||
"collapsible": true, | ||
"collapsed": false | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
{ | ||
"label": "Hooks" | ||
"label": "Hooks", | ||
"collapsible": true, | ||
"collapsed": false | ||
} |