-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IOPID-2426] Tooltip component (#351)
## Short description This PR adds the `Tooltip` component ## List of changes proposed in this pull request - Created `Tooltip` component - Added `Tooltips` screen in the Example app to show the `Tooltip` behaviors ## Demo |iOS|Android| |----|-------| |<video src="https://github.com/user-attachments/assets/1060426b-0ec6-4340-b029-6fcdf07cfe10"></video>|<video src="https://github.com/user-attachments/assets/8a76daf8-687c-498e-a54d-ca161fb4a5d0"></video>| |A11Y iOS|A11Y Android| |----|-------| |<video src="https://github.com/user-attachments/assets/a03ee6be-5575-4634-a18a-35079ffa9f08"></video>|<video src="https://github.com/user-attachments/assets/2043f05a-6543-42f5-be14-cb091362e87f"></video>| >[!Important] > The `left` and `right` positions are calculated after the component is rendered. This implementation causes a minor glitch where the Tooltip repositions itself to achieve a centered alignment relative to the enclosing element. > To avoid this behavior, the opacity value of the component depends on the parameters returned by the `onLayout` prop. Once the `tooltipLayout` is defined, the opacity is set to a value of 1. ## How to test Run the example app and test the `Tooltip` different implementations --------- Co-authored-by: Damiano Plebani <[email protected]> Co-authored-by: Alice Di Rico <[email protected]>
- Loading branch information
1 parent
30a5b9d
commit acab735
Showing
12 changed files
with
847 additions
and
101 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
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,89 @@ | ||
import React, { useState } from 'react'; | ||
import { ButtonSolid, IOVisualCostants, Tooltip, VSpacer } from '@pagopa/io-app-design-system'; | ||
import { View } from 'react-native'; | ||
import { Screen } from '../components/Screen'; | ||
|
||
const Tooltips = () => { | ||
const [isTopVisible, setIsTopVisible] = useState(false); | ||
const [isBottomVisible, setIsBottomVisible] = useState(false); | ||
const [isRightVisible, setIsRightVisible] = useState(false); | ||
const [isLeftVisible, setIsLeftVisible] = useState(false); | ||
const [isTopLeftVisible, setIsTopLefttVisible] = useState(false); | ||
const [isBottomRightVisible, setIsBottomRighttVisible] = useState(false); | ||
|
||
return ( | ||
<Screen> | ||
<View style={{ paddingVertical: IOVisualCostants.appMarginDefault }}> | ||
<Tooltip | ||
placement='bottom' | ||
title='Bottom Tooltip' | ||
content='Some bottom tooltip content' | ||
isVisible={isBottomVisible} | ||
onClose={() => setIsBottomVisible(false)} | ||
closeIconAccessibilityLabel='' | ||
> | ||
<ButtonSolid fullWidth label='Bottom' onPress={() => setIsBottomVisible(true)} /> | ||
</Tooltip> | ||
<VSpacer /> | ||
|
||
<Tooltip | ||
isVisible={isTopVisible} | ||
title='Top Tooltip' | ||
content='Some top tooltip content' | ||
onClose={() => setIsTopVisible(false)} | ||
closeIconAccessibilityLabel='' | ||
> | ||
<ButtonSolid fullWidth label='Top' onPress={() => setIsTopVisible(true)} /> | ||
</Tooltip> | ||
<VSpacer /> | ||
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}> | ||
<Tooltip | ||
placement='right' | ||
isVisible={isRightVisible} | ||
title='Right Tooltip' | ||
content='Some right tooltip content' | ||
onClose={() => setIsRightVisible(false)} | ||
closeIconAccessibilityLabel='' | ||
> | ||
<ButtonSolid fullWidth label='Right' onPress={() => setIsRightVisible(true)} /> | ||
</Tooltip> | ||
<Tooltip | ||
placement='left' | ||
isVisible={isLeftVisible} | ||
title='Left Tooltip' | ||
content='Some left tooltip content' | ||
onClose={() => setIsLeftVisible(false)} | ||
closeIconAccessibilityLabel='' | ||
> | ||
<ButtonSolid fullWidth label='Left' onPress={() => setIsLeftVisible(true)} /> | ||
</Tooltip> | ||
</View> | ||
<VSpacer /> | ||
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}> | ||
<Tooltip | ||
placement='top' | ||
isVisible={isTopLeftVisible} | ||
title='Top Tooltip' | ||
content='Some top tooltip content' | ||
onClose={() => setIsTopLefttVisible(false)} | ||
closeIconAccessibilityLabel='' | ||
> | ||
<ButtonSolid fullWidth label='Top' onPress={() => setIsTopLefttVisible(true)} /> | ||
</Tooltip> | ||
<Tooltip | ||
placement='bottom' | ||
isVisible={isBottomRightVisible} | ||
title='Bottom Tooltip' | ||
content='Some bottom tooltip content' | ||
onClose={() => setIsBottomRighttVisible(false)} | ||
closeIconAccessibilityLabel='' | ||
> | ||
<ButtonSolid fullWidth label='Bottom' onPress={() => setIsBottomRighttVisible(true)} /> | ||
</Tooltip> | ||
</View> | ||
</View> | ||
</Screen> | ||
); | ||
}; | ||
|
||
export default Tooltips; |
Oops, something went wrong.