-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create Tooltip component (#3441)
- Loading branch information
Showing
17 changed files
with
1,169 additions
and
471 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
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,91 @@ | ||
import * as React from 'react'; | ||
import { Platform, StyleSheet } from 'react-native'; | ||
|
||
import type { StackNavigationProp } from '@react-navigation/stack'; | ||
import { | ||
Appbar, | ||
Banner, | ||
FAB, | ||
List, | ||
ToggleButton, | ||
Tooltip, | ||
} from 'react-native-paper'; | ||
|
||
import ScreenWrapper from '../ScreenWrapper'; | ||
|
||
type Props = { | ||
navigation: StackNavigationProp<{}>; | ||
}; | ||
|
||
const MORE_ICON = Platform.OS === 'ios' ? 'dots-horizontal' : 'dots-vertical'; | ||
|
||
const TooltipExample = ({ navigation }: Props) => { | ||
React.useLayoutEffect(() => { | ||
navigation.setOptions({ | ||
header: () => ( | ||
<Appbar.Header> | ||
<Tooltip title="Go back"> | ||
<Appbar.BackAction onPress={() => navigation.goBack()} /> | ||
</Tooltip> | ||
<Appbar.Content title="Tooltips" /> | ||
<Tooltip title="Print ⌘ + P"> | ||
<Appbar.Action icon="printer" onPress={() => {}} /> | ||
</Tooltip> | ||
<Tooltip title="Search"> | ||
<Appbar.Action icon="magnify" onPress={() => {}} /> | ||
</Tooltip> | ||
<Tooltip title="More options"> | ||
<Appbar.Action icon={MORE_ICON} onPress={() => {}} /> | ||
</Tooltip> | ||
</Appbar.Header> | ||
), | ||
}); | ||
}); | ||
|
||
const renderFAB = () => { | ||
return ( | ||
<FAB size="medium" icon="plus" onPress={() => {}} style={[styles.fab]} /> | ||
); | ||
}; | ||
|
||
return ( | ||
<> | ||
<ScreenWrapper> | ||
<Banner visible> | ||
A tooltip is displayed upon tapping and holding a screen element or | ||
component. Continuously display the tooltip as long as the user | ||
long-presses the element. | ||
</Banner> | ||
<List.Section title="Toggle Buttons"> | ||
<ToggleButton.Row | ||
value="bold" | ||
style={styles.toggleButtonRow} | ||
onValueChange={() => {}} | ||
> | ||
<ToggleButton icon="format-bold" value="bold" /> | ||
<Tooltip title="Align center"> | ||
<ToggleButton icon="format-align-center" value="align-center" /> | ||
</Tooltip> | ||
</ToggleButton.Row> | ||
</List.Section> | ||
</ScreenWrapper> | ||
<Tooltip title="Press Me">{renderFAB()}</Tooltip> | ||
</> | ||
); | ||
}; | ||
|
||
TooltipExample.title = 'Tooltip'; | ||
|
||
export default TooltipExample; | ||
|
||
const styles = StyleSheet.create({ | ||
fab: { | ||
position: 'absolute', | ||
margin: 16, | ||
right: 0, | ||
bottom: 0, | ||
}, | ||
toggleButtonRow: { | ||
paddingHorizontal: 16, | ||
}, | ||
}); |
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
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.