Repository navigation
Feature: Tooltip for QAB #40066
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Feature: Tooltip for QAB #40066
Changes from all commits
Commits
Show all changes
62 commits
Select commit
Hold shift + click to select a range
35a5ce1
tooltip for qab
tienifr 766a444
Merge branch 'main' into feature/tooltip-for-qab
tienifr 5acd1c7
left align the tooltip
tienifr 850b665
show tooltip on native
tienifr d1b9af2
add Spanish copy
tienifr 4aa688e
fix typecheck
tienifr 5efedaa
Merge branch 'main' of https://github.com/tienifr/App into feature/to…
tienifr 77b2701
modify bold text on android
tienifr ea8719d
Merge branch 'main' of https://github.com/tienifr/App into feature/to…
tienifr 2fa14e6
update font size
tienifr 5c671c0
update color
tienifr e9f8545
Merge branch 'main' into feature/tooltip-for-qab
tienifr 7b3cfc4
fix lint
tienifr 7b21d6b
Merge branch 'main' of https://github.com/tienifr/App into feature/to…
tienifr ce51809
refactor basetooltip component
tienifr ee9b05c
fix lint
tienifr 3fff71e
remove redundatn files
tienifr 47ee590
fix typecheck
tienifr 9fb96b9
Merge branch 'main' of https://github.com/tienifr/App into feature/to…
tienifr 3222b20
refactor tooltip component tree to separate educationaltooltip and no…
tienifr 4fdcb0f
rename TooltipRenderedOnPageBody to BaseGenericTooltip
tienifr b560b24
Merge branch 'main' of https://github.com/tienifr/App into feature/to…
tienifr dac74ad
get the available ref
tienifr b10224b
Merge branch 'main' of https://github.com/tienifr/App into feature/to…
tienifr c6fe70b
Merge branch 'main' into feature/tooltip-for-qab
tienifr c4b0c41
Resolve minor comments
tienifr f5a42e9
Merge branch 'main' of https://github.com/tienifr/App into feature/to…
tienifr 9f1b0d7
Merge branch 'main' into feature/tooltip-for-qab
tienifr 6f7a13a
move get bounding rect to platform-specific files
tienifr 271510f
Merge branch 'main' into feature/tooltip-for-qab
tienifr e055182
fix android tooltip flickering
tienifr 55be439
Merge branch 'main' of https://github.com/tienifr/App into feature/to…
tienifr 6aad7d9
remove redundant type cast
tienifr e662a0c
Merge branch 'main' into feature/tooltip-for-qab
tienifr f16f974
Merge branch 'main' into feature/tooltip-for-qab
tienifr 76676da
fix lint
tienifr 4b2008d
Merge branch 'main' into feature/tooltip-for-qab
tienifr ed21534
Merge branch 'main' of https://github.com/tienifr/App into feature/to…
tienifr 5085fae
Merge branch 'main' of https://github.com/tienifr/App into feature/to…
tienifr 9e314cb
animate tooltip on Web
tienifr 7bbc2b0
Merge branch 'main' of https://github.com/tienifr/App into feature/to…
tienifr afc084a
fix lint
tienifr 584a98e
Merge branch 'main' of https://github.com/tienifr/App into feature/to…
tienifr 516c117
fix tooltip not unmount when children unmounts on mweb
tienifr d97caf8
render qab tooltip base on isFirstQuickAction
tienifr 79c35c4
Merge branch 'main' of https://github.com/tienifr/App into feature/to…
tienifr c7bd199
fix lint
tienifr d482636
Merge branch 'main' of https://github.com/tienifr/App into feature/to…
tienifr 0dc9cef
check for mobile browser to remove createPortal
tienifr e19dd31
Merge branch 'main' of https://github.com/tienifr/App into feature/to…
tienifr 2dfd7ae
Merge branch 'main' of https://github.com/tienifr/App into feature/to…
tienifr db11129
Merge branch 'main' of https://github.com/tienifr/App into feature/to…
tienifr f5f7316
resolve conflicts
tienifr baa8d0f
Merge branch 'main' of https://github.com/tienifr/App into feature/to…
tienifr b641092
Merge branch 'main' of https://github.com/tienifr/App into feature/to…
tienifr 8714827
Merge branch 'main' of https://github.com/tienifr/App into feature/to…
tienifr 28f8583
fix lint
tienifr bfab75d
Merge branch 'main' of https://github.com/tienifr/App into feature/to…
tienifr 1373c0c
hide tooltip during popover animation out
tienifr 84096b7
Merge branch 'main' of https://github.com/tienifr/App into feature/to…
tienifr eb35978
Merge branch 'main' of https://github.com/tienifr/App into feature/to…
tienifr 6ef72be
Merge branch 'main' of https://github.com/tienifr/App into feature/to…
tienifr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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
132 changes: 132 additions & 0 deletions
132
src/components/Tooltip/BaseGenericTooltip/index.native.tsx
This file contains hidden or 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,132 @@ | ||
| import React, {useEffect, useMemo, useRef, useState} from 'react'; | ||
| import {Animated, View} from 'react-native'; | ||
| // eslint-disable-next-line no-restricted-imports | ||
| import type {Text as RNText, View as RNView} from 'react-native'; | ||
| import Text from '@components/Text'; | ||
| import useStyleUtils from '@hooks/useStyleUtils'; | ||
| import type {BaseGenericTooltipProps} from './types'; | ||
|
|
||
| // Props will change frequently. | ||
| // On every tooltip hover, we update the position in state which will result in re-rendering. | ||
| // We also update the state on layout changes which will be triggered often. | ||
| // There will be n number of tooltip components in the page. | ||
| // It's good to memoize this one. | ||
| function BaseGenericTooltip({ | ||
| animation, | ||
| windowWidth, | ||
| xOffset, | ||
| yOffset, | ||
| targetWidth, | ||
| targetHeight, | ||
| shiftHorizontal = 0, | ||
| shiftVertical = 0, | ||
| text, | ||
| numberOfLines, | ||
| maxWidth = 0, | ||
| renderTooltipContent, | ||
| shouldForceRenderingBelow = false, | ||
| shouldForceRenderingLeft = false, | ||
| wrapperStyle = {}, | ||
| }: BaseGenericTooltipProps) { | ||
| // The width of tooltip's inner content. Has to be undefined in the beginning | ||
| // as a width of 0 will cause the content to be rendered of a width of 0, | ||
| // which prevents us from measuring it correctly. | ||
| const [contentMeasuredWidth, setContentMeasuredWidth] = useState<number>(); | ||
|
|
||
| // The height of tooltip's wrapper. | ||
|
tienifr marked this conversation as resolved.
Resolved
|
||
| const [wrapperMeasuredHeight, setWrapperMeasuredHeight] = useState<number>(); | ||
| const textContentRef = useRef<RNText>(null); | ||
| const viewContentRef = useRef<RNView>(null); | ||
| const rootWrapper = useRef<RNView>(null); | ||
|
|
||
| const StyleUtils = useStyleUtils(); | ||
|
|
||
| // Measure content width | ||
| useEffect(() => { | ||
| if (!textContentRef.current && !viewContentRef.current) { | ||
| return; | ||
| } | ||
| const contentRef = viewContentRef.current ?? textContentRef.current; | ||
| contentRef?.measure((x, y, width) => setContentMeasuredWidth(width)); | ||
| }, []); | ||
|
tienifr marked this conversation as resolved.
Resolved
|
||
|
|
||
| const {animationStyle, rootWrapperStyle, textStyle, pointerWrapperStyle, pointerStyle} = useMemo( | ||
| () => | ||
| StyleUtils.getTooltipStyles({ | ||
| tooltip: rootWrapper.current, | ||
| currentSize: animation, | ||
| windowWidth, | ||
| xOffset, | ||
| yOffset, | ||
| tooltipTargetWidth: targetWidth, | ||
| tooltipTargetHeight: targetHeight, | ||
| maxWidth, | ||
| tooltipContentWidth: contentMeasuredWidth, | ||
| tooltipWrapperHeight: wrapperMeasuredHeight, | ||
| manualShiftHorizontal: shiftHorizontal, | ||
| manualShiftVertical: shiftVertical, | ||
| shouldForceRenderingBelow, | ||
| shouldForceRenderingLeft, | ||
| wrapperStyle, | ||
| }), | ||
| [ | ||
| StyleUtils, | ||
| animation, | ||
| windowWidth, | ||
| xOffset, | ||
| yOffset, | ||
| targetWidth, | ||
| targetHeight, | ||
| maxWidth, | ||
| contentMeasuredWidth, | ||
| wrapperMeasuredHeight, | ||
| shiftHorizontal, | ||
| shiftVertical, | ||
| shouldForceRenderingBelow, | ||
| shouldForceRenderingLeft, | ||
| wrapperStyle, | ||
| ], | ||
| ); | ||
|
|
||
| let content; | ||
| if (renderTooltipContent) { | ||
| content = <View ref={viewContentRef}>{renderTooltipContent()}</View>; | ||
| } else { | ||
| content = ( | ||
| <Text | ||
| numberOfLines={numberOfLines} | ||
| style={textStyle} | ||
| > | ||
| <Text | ||
| style={textStyle} | ||
| ref={textContentRef} | ||
| > | ||
| {text} | ||
| </Text> | ||
| </Text> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <Animated.View | ||
| ref={rootWrapper} | ||
| style={[rootWrapperStyle, animationStyle]} | ||
| onLayout={(e) => { | ||
| const {height} = e.nativeEvent.layout; | ||
| if (height === wrapperMeasuredHeight) { | ||
| return; | ||
| } | ||
| setWrapperMeasuredHeight(height); | ||
| }} | ||
| > | ||
| {content} | ||
| <View style={pointerWrapperStyle}> | ||
| <View style={pointerStyle} /> | ||
| </View> | ||
| </Animated.View> | ||
| ); | ||
| } | ||
|
|
||
| BaseGenericTooltip.displayName = 'BaseGenericTooltip'; | ||
|
|
||
| export default React.memo(BaseGenericTooltip); | ||
This file contains hidden or 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 hidden or 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,33 @@ | ||
| import type {Animated} from 'react-native'; | ||
| import type TooltipProps from '@components/Tooltip/types'; | ||
|
|
||
| type BaseGenericTooltipProps = { | ||
| /** Window width */ | ||
| windowWidth: number; | ||
|
|
||
| /** Tooltip Animation value */ | ||
| animation: Animated.Value; | ||
|
|
||
| /** The distance between the left side of the wrapper view and the left side of the window */ | ||
| xOffset: number; | ||
|
|
||
| /** The distance between the top of the wrapper view and the top of the window */ | ||
| yOffset: number; | ||
|
|
||
| /** The width of the tooltip's target */ | ||
| targetWidth: number; | ||
|
|
||
| /** The height of the tooltip's target */ | ||
| targetHeight: number; | ||
|
|
||
| /** Any additional amount to manually adjust the horizontal position of the tooltip. | ||
| A positive value shifts the tooltip to the right, and a negative value shifts it to the left. */ | ||
| shiftHorizontal?: number; | ||
|
|
||
| /** Any additional amount to manually adjust the vertical position of the tooltip. | ||
| A positive value shifts the tooltip down, and a negative value shifts it up. */ | ||
| shiftVertical?: number; | ||
| } & Pick<TooltipProps, 'renderTooltipContent' | 'maxWidth' | 'numberOfLines' | 'text' | 'shouldForceRenderingBelow' | 'wrapperStyle' | 'shouldForceRenderingLeft'>; | ||
|
|
||
| // eslint-disable-next-line import/prefer-default-export | ||
| export type {BaseGenericTooltipProps}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.