refactor LeftNav

This commit is contained in:
Eric Bailey
2023-10-19 11:58:24 -04:00
parent f0e32ba1db
commit 2078995daf
+44 -55
View File
@@ -1,7 +1,6 @@
import React from 'react' import React from 'react'
import {observer} from 'mobx-react-lite' import {observer} from 'mobx-react-lite'
import {StyleSheet, TouchableOpacity, View} from 'react-native' import {StyleSheet, TouchableOpacity, View} from 'react-native'
import {PressableWithHover} from 'view/com/util/PressableWithHover'
import { import {
useLinkProps, useLinkProps,
useNavigation, useNavigation,
@@ -11,7 +10,6 @@ import {
FontAwesomeIcon, FontAwesomeIcon,
FontAwesomeIconStyle, FontAwesomeIconStyle,
} from '@fortawesome/react-native-fontawesome' } from '@fortawesome/react-native-fontawesome'
import {Text} from 'view/com/util/text/Text'
import {UserAvatar} from 'view/com/util/UserAvatar' import {UserAvatar} from 'view/com/util/UserAvatar'
import {Link} from 'view/com/util/Link' import {Link} from 'view/com/util/Link'
import {LoadingPlaceholder} from 'view/com/util/LoadingPlaceholder' import {LoadingPlaceholder} from 'view/com/util/LoadingPlaceholder'
@@ -38,6 +36,7 @@ import {getCurrentRoute, isTab, isStateAtTabRoot} from 'lib/routes/helpers'
import {NavigationProp, CommonNavigatorParams} from 'lib/routes/types' import {NavigationProp, CommonNavigatorParams} from 'lib/routes/types'
import {router} from '../../../routes' import {router} from '../../../routes'
import {makeProfileLink} from 'lib/routes/links' import {makeProfileLink} from 'lib/routes/links'
import {Box, Text, Pressable, useTheme} from 'view/nova'
const ProfileCard = observer(function ProfileCardImpl() { const ProfileCard = observer(function ProfileCardImpl() {
const store = useStores() const store = useStores()
@@ -110,6 +109,7 @@ const NavItem = observer(function NavItemImpl({
iconFilled, iconFilled,
label, label,
}: NavItemProps) { }: NavItemProps) {
const { theme } = useTheme()
const pal = usePalette('default') const pal = usePalette('default')
const store = useStores() const store = useStores()
const {isDesktop, isTablet} = useWebMediaQueries() const {isDesktop, isTablet} = useWebMediaQueries()
@@ -143,40 +143,62 @@ const NavItem = observer(function NavItemImpl({
) )
return ( return (
<PressableWithHover <Pressable
style={styles.navItemWrapper} fdr
hoverStyle={pal.viewLight} aic
pa={12}
radius={8}
gap={10}
style={state => ({
// TODO
backgroundColor: state.hovered ? theme.config.tokens.color.l2 : 'transparent',
})}
// @ts-ignore the function signature differs on web -prf // @ts-ignore the function signature differs on web -prf
onPress={onPressWrapped} onPress={onPressWrapped}
// @ts-ignore web only -prf // @ts-ignore web only -prf
href={href} href={href}
// @ts-ignore web only -prf
dataSet={{noUnderline: 1}} dataSet={{noUnderline: 1}}
accessibilityRole="tab" accessibilityRole="tab"
accessibilityLabel={label} accessibilityLabel={label}
accessibilityHint=""> accessibilityHint="">
<View <Box
style={[ aic
styles.navItemIconWrapper, jcc
isTablet && styles.navItemIconWrapperTablet, w={28}
]}> h={28}
mt={2}
z={1}
gtMobile={{
w: 40,
h: 40,
}}
gtTablet={{
w: 28,
h: 28,
}}>
{isCurrent ? iconFilled : icon} {isCurrent ? iconFilled : icon}
{typeof count === 'string' && count ? ( {typeof count === 'string' && count ? (
<Text <Text
type="button" abs
style={[ top={0}
styles.navItemCount, left={15}
isTablet && styles.navItemCountTablet, bg={colors.blue3}
]}> c={colors.white}
fs='s'
fw={'bold'}
px={4}
radius={6}>
{count} {count}
</Text> </Text>
) : null} ) : null}
</View> </Box>
{isDesktop && ( {isDesktop && (
<Text type="title" style={[isCurrent ? s.bold : s.normal, pal.text]}> <Text fs='xl' fw={isCurrent ? 'bold' : 'normal'}>
{label} {label}
</Text> </Text>
)} )}
</PressableWithHover> </Pressable>
) )
}) })
@@ -230,7 +252,10 @@ function ComposeBtn() {
style={styles.newPostBtnLabel} style={styles.newPostBtnLabel}
/> />
</View> </View>
<Text type="button" style={styles.newPostBtnLabel}> <Text
c={colors.white}
fs='m'
fw={'bold'}>
New Post New Post
</Text> </Text>
</TouchableOpacity> </TouchableOpacity>
@@ -418,42 +443,6 @@ const styles = StyleSheet.create({
height: 30, height: 30,
}, },
navItemWrapper: {
flexDirection: 'row',
alignItems: 'center',
paddingHorizontal: 12,
padding: 12,
borderRadius: 8,
gap: 10,
},
navItemIconWrapper: {
alignItems: 'center',
justifyContent: 'center',
width: 28,
height: 28,
marginTop: 2,
zIndex: 1,
},
navItemIconWrapperTablet: {
width: 40,
height: 40,
},
navItemCount: {
position: 'absolute',
top: 0,
left: 15,
backgroundColor: colors.blue3,
color: colors.white,
fontSize: 12,
fontWeight: 'bold',
paddingHorizontal: 4,
borderRadius: 6,
},
navItemCountTablet: {
left: 18,
fontSize: 14,
},
newPostBtn: { newPostBtn: {
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', alignItems: 'center',