-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
feat: Add temporary focus to enabled option in workspace initial page #38546
Merged
Merged
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
8c09ebe
add temp focus
allroundexperts bb2cce2
Merge branch 'main' into fix-38372
allroundexperts 086b648
handle comments
allroundexperts 66dedbb
add animations as design wanted
allroundexperts 811debf
apply diff
allroundexperts dbbf8be
merge with main
allroundexperts e4dec8f
prettier
allroundexperts 23309a5
prettier
allroundexperts 2c79caa
type fix
allroundexperts 352b7d3
add easing
allroundexperts 69fa80e
Merge branch 'main' into fix-38372
allroundexperts 7b79d44
revert back to useEffect approach
allroundexperts 75f38d7
lint fix
allroundexperts 128cfea
more lint fixes
allroundexperts 3ade711
menu item height prop
allroundexperts 752fedf
add missing doc comments
allroundexperts a8ce2c7
fix animations on native
allroundexperts 15c9f38
adjust the config for animation
allroundexperts 4d11b7f
prettier
allroundexperts 904ee16
Merge branch 'main' into fix-38372
allroundexperts 942d665
fix regression
allroundexperts c5e509b
lint
allroundexperts 64c2a45
handle comments
allroundexperts 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
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,36 @@ | ||
import type {ForwardedRef} from 'react'; | ||
import {forwardRef} from 'react'; | ||
import type {View} from 'react-native'; | ||
import {StyleSheet} from 'react-native'; | ||
import useAnimatedHighlightStyle from '@hooks/useAnimatedHighlightStyle'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import MenuItem from './MenuItem'; | ||
import type {MenuItemProps} from './MenuItem'; | ||
|
||
type Props = MenuItemProps & { | ||
highlighted?: boolean; | ||
mountiny marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
|
||
function HighlightableMenuItem({wrapperStyle, highlighted, ...restOfProps}: Props, ref: ForwardedRef<View>) { | ||
const styles = useThemeStyles(); | ||
|
||
const flattenedWrapperStyles = StyleSheet.flatten(wrapperStyle); | ||
const animatedHighlightStyle = useAnimatedHighlightStyle({ | ||
shouldHighlight: highlighted ?? false, | ||
height: flattenedWrapperStyles?.height ? Number(flattenedWrapperStyles.height) : styles.sectionMenuItem.height, | ||
borderRadius: flattenedWrapperStyles?.borderRadius ? Number(flattenedWrapperStyles.borderRadius) : styles.sectionMenuItem.borderRadius, | ||
}); | ||
|
||
return ( | ||
<MenuItem | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
{...restOfProps} | ||
wrapperStyle={animatedHighlightStyle} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you mean There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, my bad. Fixed. |
||
ref={ref} | ||
/> | ||
); | ||
} | ||
|
||
HighlightableMenuItem.displayName = 'HighlightableMenuItem'; | ||
|
||
export default forwardRef(HighlightableMenuItem); |
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,5 @@ | ||
const DELAY_FACTOR = 1.85; | ||
|
||
export default {}; | ||
|
||
export {DELAY_FACTOR}; |
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,6 @@ | ||
import {isMobile} from '@libs/Browser'; | ||
|
||
const DELAY_FACTOR = isMobile() ? 1 : 0.2; | ||
mountiny marked this conversation as resolved.
Show resolved
Hide resolved
|
||
export default {}; | ||
|
||
export {DELAY_FACTOR}; |
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,64 @@ | ||
import React from 'react'; | ||
import {InteractionManager} from 'react-native'; | ||
import {Easing, interpolate, interpolateColor, runOnJS, useAnimatedStyle, useSharedValue, withDelay, withSequence, withTiming} from 'react-native-reanimated'; | ||
import useTheme from '@hooks/useTheme'; | ||
import CONST from '@src/CONST'; | ||
import {DELAY_FACTOR} from './config'; | ||
|
||
type Props = { | ||
/** Border radius of the wrapper */ | ||
borderRadius: number; | ||
|
||
/** Height of the item that is to be faded */ | ||
height: number; | ||
|
||
/** Whether the item should be highlighted */ | ||
shouldHighlight: boolean; | ||
|
||
/** Duration of the highlight animation */ | ||
highlightDuration?: number; | ||
|
||
/** Delay before the highlight animation starts */ | ||
delay?: number; | ||
}; | ||
|
||
/** | ||
* Returns a highlight style that interpolates the colour, height and opacity giving a fading effect. | ||
*/ | ||
export default function useAnimatedHighlightStyle({ | ||
borderRadius, | ||
shouldHighlight, | ||
highlightDuration = CONST.ANIMATED_HIGHLIGHT_DURATION, | ||
delay = CONST.ANIMATED_HIGHLIGHT_DELAY, | ||
height, | ||
}: Props) { | ||
const actualDelay = delay * DELAY_FACTOR; | ||
const repeatableProgress = useSharedValue(0); | ||
const nonRepeatableProgress = useSharedValue(shouldHighlight ? 0 : 1); | ||
const theme = useTheme(); | ||
|
||
const highlightBackgroundStyle = useAnimatedStyle(() => ({ | ||
backgroundColor: interpolateColor(repeatableProgress.value, [0, 1], ['rgba(0, 0, 0, 0)', theme.border]), | ||
height: interpolate(nonRepeatableProgress.value, [0, 1], [0, height]), | ||
opacity: interpolate(nonRepeatableProgress.value, [0, 1], [0, 1]), | ||
borderRadius, | ||
})); | ||
|
||
React.useEffect(() => { | ||
if (!shouldHighlight) { | ||
return; | ||
} | ||
|
||
InteractionManager.runAfterInteractions(() => { | ||
runOnJS(() => { | ||
nonRepeatableProgress.value = withDelay(actualDelay, withTiming(1, {duration: highlightDuration, easing: Easing.inOut(Easing.ease)})); | ||
repeatableProgress.value = withSequence( | ||
withDelay(actualDelay, withTiming(1, {duration: highlightDuration, easing: Easing.inOut(Easing.ease)})), | ||
withDelay(actualDelay, withTiming(0, {duration: highlightDuration, easing: Easing.inOut(Easing.ease)})), | ||
); | ||
})(); | ||
}); | ||
}, [shouldHighlight, highlightDuration, actualDelay, repeatableProgress, nonRepeatableProgress]); | ||
|
||
return highlightBackgroundStyle; | ||
} |
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we missed adding
React
here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's weird that there is no lint / type error for this. I've added it anyways.