-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* featute(tooltip): first proposal * feat(tooltip): add documentation * fix(tooltip): improve props * fix(tooltip-doc): alphabetical order * feat(website): add tooltip component * fix(review): improve code * feat(tooltip): first tests * Run prettier on markdown * fix(helpers): remove flow * fix(tooltip): update snaps
- Loading branch information
1 parent
c18df20
commit eaac261
Showing
12 changed files
with
1,001 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,158 @@ | ||
--- | ||
id: tooltip | ||
title: Tooltip | ||
--- | ||
|
||
Easy to use and customisable tooltip. | ||
|
||
<img alt="tooltip example gif" width='290' src='/react-native-elements/img/tooltipExample.gif'> | ||
|
||
### Usage | ||
|
||
```js | ||
import { Tooltip, Text } from 'react-native-elements'; | ||
|
||
... | ||
|
||
<Tooltip popover={<Text>Info here</Text>}> | ||
<Text>Press me</Text> | ||
</Tooltip> | ||
``` | ||
|
||
### Props | ||
|
||
* [`backgroundColor`](#backgroundcolor) | ||
* [`containerStyle`](#containerStyle) | ||
* [`height`](#height) | ||
* [`highlightColor`](#highlightColor) | ||
* [`onClose`](#onClose) | ||
* [`onOpen`](#onOpen) | ||
* [`pointerColor`](#pointerColor) | ||
* [`popover`](#popover) | ||
* [`toggleOnPress`](#toggleOnPress) | ||
* [`width`](#width) | ||
* [`withOverlay`](#withOverlay) | ||
* [`withPointer`](#withPointer) | ||
|
||
--- | ||
|
||
# Reference | ||
|
||
### `backgroundColor` | ||
|
||
sets backgroundColor of the tooltip and pointer. | ||
|
||
| Type | Default | | ||
| :----: | :-----: | | ||
| string | #617080 | | ||
|
||
--- | ||
|
||
### `containerStyle` | ||
|
||
Passes style object to tooltip container | ||
|
||
| Type | Default | | ||
| :------------: | :---------------: | | ||
| object (style) | inherited styling | | ||
|
||
--- | ||
|
||
### `height` | ||
|
||
Tooltip container height. Necessary in order to render the container in the | ||
correct place. Pass height according to the size of the content rendered inside | ||
the container. | ||
|
||
| Type | Default | | ||
| :----: | :-----: | | ||
| number | 40 | | ||
|
||
--- | ||
|
||
### `highlightColor` | ||
|
||
Color to highlight the item the tooltip is surrounding. | ||
|
||
| Type | Default | | ||
| :----: | :---------: | | ||
| string | transparent | | ||
|
||
--- | ||
|
||
### `onClose` | ||
|
||
function which gets called on closing the tooltip. | ||
|
||
| Type | Default | | ||
| :------: | :------: | | ||
| function | () => {} | | ||
|
||
--- | ||
|
||
### `onOpen` | ||
|
||
function which gets called on opening the tooltip. | ||
|
||
| Type | Default | | ||
| :------: | :------: | | ||
| function | () => {} | | ||
|
||
--- | ||
|
||
### `pointerColor` | ||
|
||
Color of tooltip pointer, it defaults to the | ||
[`backgroundColor`](#backgroundcolor) if none is passed . | ||
|
||
| Type | Default | | ||
| :----: | :-----------------------------------: | | ||
| string | [`backgroundColor`](#backgroundcolor) | | ||
|
||
--- | ||
|
||
### `popover` | ||
|
||
Component to be rendered as the display container. | ||
|
||
| Type | Default | | ||
| :-----------: | :-----: | | ||
| React.Element | null | | ||
|
||
--- | ||
|
||
### `toggleOnPress` | ||
|
||
Flag to determine to toggle or not the tooltip on press. | ||
|
||
| Type | Default | | ||
| :-----: | :-----: | | ||
| boolean | true | | ||
|
||
--- | ||
|
||
### `width` | ||
|
||
Tooltip container width. Necessary in order to render the container in the | ||
correct place. Pass height according to the size of the content rendered inside | ||
the container. | ||
|
||
| Type | Default | | ||
| :----: | :-----: | | ||
| number | 150 | | ||
|
||
### `withOverlay` | ||
|
||
Flag to determine whether or not dislay overlay shadow when tooltip is open. | ||
|
||
| Type | Default | | ||
| :-----: | :-----: | | ||
| boolean | true | | ||
|
||
### `withPointer` | ||
|
||
Flag to determine whether or not dislay pointer. | ||
|
||
| Type | Default | | ||
| :-----: | :-----: | | ||
| boolean | true | |
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,6 +1,20 @@ | ||
import { Platform, Dimensions } from 'react-native'; | ||
import renderNode from './renderNode'; | ||
import getIconType from './getIconType'; | ||
import normalizeText from './normalizeText'; | ||
import nodeType from './nodeType'; | ||
|
||
export { renderNode, getIconType, normalizeText, nodeType }; | ||
const Screen = Dimensions.get('window'); | ||
const ScreenWidth = Screen.width; | ||
const ScreenHeight = Screen.height; | ||
const isIOS = Platform.OS === 'ios'; | ||
|
||
export { | ||
renderNode, | ||
getIconType, | ||
normalizeText, | ||
nodeType, | ||
ScreenWidth, | ||
ScreenHeight, | ||
isIOS, | ||
}; |
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.