Clean up right nav

This commit is contained in:
Eric Bailey
2024-11-17 13:56:59 -06:00
parent bdc16e0a15
commit 4cc2690365
2 changed files with 119 additions and 175 deletions
+42 -61
View File
@@ -1,19 +1,20 @@
import {StyleSheet, View} from 'react-native' import React from 'react'
import {msg} from '@lingui/macro' import {View} from 'react-native'
import {useLingui} from '@lingui/react' // import {msg} from '@lingui/macro'
// import {useLingui} from '@lingui/react'
import {useNavigation, useNavigationState} from '@react-navigation/native' import {useNavigation, useNavigationState} from '@react-navigation/native'
import {usePalette} from '#/lib/hooks/usePalette'
import {getCurrentRoute} from '#/lib/routes/helpers' import {getCurrentRoute} from '#/lib/routes/helpers'
import {NavigationProp} from '#/lib/routes/types' import {NavigationProp} from '#/lib/routes/types'
import {emitSoftReset} from '#/state/events' import {emitSoftReset} from '#/state/events'
import {usePinnedFeedsInfos} from '#/state/queries/feed' import {usePinnedFeedsInfos} from '#/state/queries/feed'
import {useSelectedFeed, useSetSelectedFeed} from '#/state/shell/selected-feed' import {useSelectedFeed, useSetSelectedFeed} from '#/state/shell/selected-feed'
import {TextLink} from '#/view/com/util/Link' import {atoms as a, useTheme, web} from '#/alf'
import {InlineLinkText} from '#/components/Link'
export function DesktopFeeds() { export function DesktopFeeds() {
const pal = usePalette('default') const t = useTheme()
const {_} = useLingui() // const {_} = useLingui()
const {data: pinnedFeedInfos} = usePinnedFeedsInfos() const {data: pinnedFeedInfos} = usePinnedFeedsInfos()
const selectedFeed = useSelectedFeed() const selectedFeed = useSelectedFeed()
const setSelectedFeed = useSetSelectedFeed() const setSelectedFeed = useSetSelectedFeed()
@@ -24,19 +25,30 @@ export function DesktopFeeds() {
} }
return getCurrentRoute(state) return getCurrentRoute(state)
}) })
if (!pinnedFeedInfos) { if (!pinnedFeedInfos) {
return null return null
} }
return ( return (
<View style={[styles.container, pal.view]}> <View
style={[
a.flex_1,
a.gap_md,
web({
paddingVertical: 2, // fixes overflow?
overflowY: 'auto',
}),
]}>
{pinnedFeedInfos.map(feedInfo => { {pinnedFeedInfos.map(feedInfo => {
const feed = feedInfo.feedDescriptor const feed = feedInfo.feedDescriptor
const current = route.name === 'Home' && feed === selectedFeed
return ( return (
<FeedItem <InlineLinkText
key={feed} key={feedInfo.uri}
href={'/?' + new URLSearchParams([['feed', feed]])} to={'/?' + new URLSearchParams([['feed', feed]])}
title={feedInfo.displayName} label={feedInfo.displayName}
current={route.name === 'Home' && feed === selectedFeed}
onPress={() => { onPress={() => {
setSelectedFeed(feed) setSelectedFeed(feed)
navigation.navigate('Home') navigation.navigate('Home')
@@ -44,56 +56,25 @@ export function DesktopFeeds() {
emitSoftReset() emitSoftReset()
} }
}} }}
/> style={[
a.text_lg,
current
? [a.font_heavy, t.atoms.text]
: [t.atoms.text_contrast_medium],
]}>
{feedInfo.displayName}
</InlineLinkText>
) )
})} })}
<View style={{paddingTop: 8, paddingBottom: 6}}>
<TextLink {/*
type="lg" <InlineLinkText
href="/feeds" to="/feeds"
text={_(msg`More feeds`)} label={_(msg`More feeds`)}
style={[pal.link]} style={[a.text_lg]}>
/> {_(msg`More feeds`)}
</View> </InlineLinkText>
*/}
</View> </View>
) )
} }
function FeedItem({
title,
href,
current,
onPress,
}: {
title: string
href: string
current: boolean
onPress: () => void
}) {
const pal = usePalette('default')
return (
<View style={{paddingVertical: 6}}>
<TextLink
type="xl"
href={href}
text={title}
onPress={onPress}
style={[
current ? pal.text : pal.textLight,
{letterSpacing: 0.15, fontWeight: current ? '600' : '400'},
]}
/>
</View>
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
// @ts-ignore web only -prf
overflowY: 'auto',
width: 300,
paddingHorizontal: 12,
paddingVertical: 18,
},
})
+77 -114
View File
@@ -1,22 +1,21 @@
import {StyleSheet, View} from 'react-native' import React from 'react'
import {View} from 'react-native'
import {msg, Trans} from '@lingui/macro' import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {FEEDBACK_FORM_URL, HELP_DESK_URL} from '#/lib/constants' import {FEEDBACK_FORM_URL, HELP_DESK_URL} from '#/lib/constants'
import {usePalette} from '#/lib/hooks/usePalette'
import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries' import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries'
import {s} from '#/lib/styles'
import {useKawaiiMode} from '#/state/preferences/kawaii' import {useKawaiiMode} from '#/state/preferences/kawaii'
import {useSession} from '#/state/session' import {useSession} from '#/state/session'
import {TextLink} from '#/view/com/util/Link' import {DesktopFeeds} from '#/view/shell/desktop/Feeds'
import {Text} from '#/view/com/util/text/Text' import {DesktopSearch} from '#/view/shell/desktop/Search'
import {atoms as a} from '#/alf' import {atoms as a, useTheme, web} from '#/alf'
import {InlineLinkText} from '#/components/Link'
import {ProgressGuideList} from '#/components/ProgressGuide/List' import {ProgressGuideList} from '#/components/ProgressGuide/List'
import {DesktopFeeds} from './Feeds' import {Text} from '#/components/Typography'
import {DesktopSearch} from './Search'
export function DesktopRightNav({routeName}: {routeName: string}) { export function DesktopRightNav({routeName}: {routeName: string}) {
const pal = usePalette('default') const t = useTheme()
const {_} = useLingui() const {_} = useLingui()
const {hasSession, currentAccount} = useSession() const {hasSession, currentAccount} = useSession()
@@ -28,117 +27,81 @@ export function DesktopRightNav({routeName}: {routeName: string}) {
} }
return ( return (
<View style={[styles.rightNav, pal.view]}> <View
<View style={{paddingVertical: 20}}> style={[
{routeName === 'Search' ? ( web({
<View style={{marginBottom: 18}}> position: 'fixed',
<DesktopFeeds /> left: 'calc(50vw + 300px + 20px)',
</View> width: 300,
) : ( maxHeight: '100%',
<> overflowY: 'auto',
}),
]}>
<View style={[a.py_xl]}>
{routeName !== 'Search' && (
<View style={[a.pb_lg]}>
<DesktopSearch /> <DesktopSearch />
</View>
{hasSession && ( )}
<> {hasSession && (
<ProgressGuideList style={[{marginTop: 22, marginBottom: 8}]} /> <>
<View style={[pal.border, styles.desktopFeedsContainer]}> <ProgressGuideList style={[a.mt_xl, a.mb_sm]} />
<DesktopFeeds /> <View
</View> style={[
</> a.pb_lg,
)} a.mb_lg,
a.border_b,
t.atoms.border_contrast_low,
]}>
<DesktopFeeds />
</View>
</> </>
)} )}
<View <Text style={[a.leading_snug, t.atoms.text_contrast_low]}>
style={[ {hasSession && (
styles.message, <>
{ <InlineLinkText
paddingTop: hasSession ? 0 : 18, to={FEEDBACK_FORM_URL({
}, email: currentAccount?.email,
]}> handle: currentAccount?.handle,
<View style={[{flexWrap: 'wrap'}, s.flexRow, a.gap_xs]}> })}
{hasSession && ( label={_(msg`Feedback`)}>
<> {_(msg`Feedback`)}
<TextLink </InlineLinkText>
type="md" {' • '}
style={pal.link} </>
href={FEEDBACK_FORM_URL({
email: currentAccount?.email,
handle: currentAccount?.handle,
})}
text={_(msg`Feedback`)}
/>
<Text type="md" style={pal.textLight}>
&middot;
</Text>
</>
)}
<TextLink
type="md"
style={pal.link}
href="https://bsky.social/about/support/privacy-policy"
text={_(msg`Privacy`)}
/>
<Text type="md" style={pal.textLight}>
&middot;
</Text>
<TextLink
type="md"
style={pal.link}
href="https://bsky.social/about/support/tos"
text={_(msg`Terms`)}
/>
<Text type="md" style={pal.textLight}>
&middot;
</Text>
<TextLink
type="md"
style={pal.link}
href={HELP_DESK_URL}
text={_(msg`Help`)}
/>
</View>
{kawaii && (
<Text type="md" style={[pal.textLight, {marginTop: 12}]}>
<Trans>
Logo by{' '}
<TextLink
type="md"
href="/profile/sawaratsuki.bsky.social"
text="@sawaratsuki.bsky.social"
style={pal.link}
/>
</Trans>
</Text>
)} )}
</View> <InlineLinkText
to="https://bsky.social/about/support/privacy-policy"
label={_(msg`Privacy`)}>
{_(msg`Privacy`)}
</InlineLinkText>
{' • '}
<InlineLinkText
to="https://bsky.social/about/support/tos"
label={_(msg`Terms`)}>
{_(msg`Terms`)}
</InlineLinkText>
{' • '}
<InlineLinkText label={_(msg`Help`)} to={HELP_DESK_URL}>
{_(msg`Help`)}
</InlineLinkText>
</Text>
{kawaii && (
<Text style={[t.atoms.text_contrast_medium, {marginTop: 12}]}>
<Trans>
Logo by{' '}
<InlineLinkText
label={_(msg`Logo by @sawaratsuki.bsky.social`)}
to="/profile/sawaratsuki.bsky.social">
@sawaratsuki.bsky.social
</InlineLinkText>
</Trans>
</Text>
)}
</View> </View>
</View> </View>
) )
} }
const styles = StyleSheet.create({
rightNav: {
// @ts-ignore web only
position: 'fixed',
// @ts-ignore web only
left: 'calc(50vw + 300px + 20px)',
width: 300,
maxHeight: '100%',
overflowY: 'auto',
},
message: {
paddingVertical: 18,
paddingHorizontal: 12,
},
messageLine: {
marginBottom: 10,
},
desktopFeedsContainer: {
borderTopWidth: StyleSheet.hairlineWidth,
borderBottomWidth: StyleSheet.hairlineWidth,
marginTop: 18,
marginBottom: 18,
},
})