diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-05-04 01:20:23 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-04 01:20:23 -0500 |
commit | 49f9df635561f5de21c8d7318a94355249375bc1 (patch) | |
tree | 73d4cd403017fef77e7787867ae03b44af585dfc /src | |
parent | 2749b8e3713f853aed9f3449dd76d6bd50e81cc9 (diff) | |
download | voidsky-49f9df635561f5de21c8d7318a94355249375bc1.tar.zst |
[APP-633] Improve some behaviors around desktop leftnav (#581)
* Make leftnav elements act as anchor tags (bonus feature in this pr) * Add screen reset behavior to the desktop left nav * Move the leftnav link into the text
Diffstat (limited to 'src')
-rw-r--r-- | src/view/shell/desktop/LeftNav.tsx | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/view/shell/desktop/LeftNav.tsx b/src/view/shell/desktop/LeftNav.tsx index 17d078dc5..621c7926c 100644 --- a/src/view/shell/desktop/LeftNav.tsx +++ b/src/view/shell/desktop/LeftNav.tsx @@ -86,6 +86,7 @@ interface NavItemProps { const NavItem = observer( ({count, href, icon, iconFilled, label}: NavItemProps) => { const pal = usePalette('default') + const store = useStores() const [pathName] = React.useMemo(() => router.matchPath(href), [href]) const currentRouteName = useNavigationState(state => { if (!state) { @@ -96,12 +97,23 @@ const NavItem = observer( const isCurrent = isTab(currentRouteName, pathName) const {onPress} = useLinkProps({to: href}) + const onPressWrapped = React.useCallback( + (e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => { + e.preventDefault() + if (isCurrent) { + store.emitScreenSoftReset() + } else { + onPress() + } + }, + [onPress, isCurrent, store], + ) return ( <PressableWithHover style={styles.navItemWrapper} hoverStyle={pal.viewLight} - onPress={onPress} + onPress={onPressWrapped} accessibilityRole="tab" accessibilityLabel={label} accessibilityHint=""> @@ -113,7 +125,11 @@ const NavItem = observer( </Text> ) : null} </View> - <Text type="title" style={[isCurrent ? s.bold : s.normal, pal.text]}> + <Text + type="title" + style={[isCurrent ? s.bold : s.normal, pal.text]} + href={href} + dataSet={{noUnderline: 1}}> {label} </Text> </PressableWithHover> |