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 {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import React from 'react'
import {View} from 'react-native'
// import {msg} from '@lingui/macro'
// import {useLingui} from '@lingui/react'
import {useNavigation, useNavigationState} from '@react-navigation/native'
import {usePalette} from '#/lib/hooks/usePalette'
import {getCurrentRoute} from '#/lib/routes/helpers'
import {NavigationProp} from '#/lib/routes/types'
import {emitSoftReset} from '#/state/events'
import {usePinnedFeedsInfos} from '#/state/queries/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() {
const pal = usePalette('default')
const {_} = useLingui()
const t = useTheme()
// const {_} = useLingui()
const {data: pinnedFeedInfos} = usePinnedFeedsInfos()
const selectedFeed = useSelectedFeed()
const setSelectedFeed = useSetSelectedFeed()
@@ -24,19 +25,30 @@ export function DesktopFeeds() {
}
return getCurrentRoute(state)
})
if (!pinnedFeedInfos) {
return null
}
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 => {
const feed = feedInfo.feedDescriptor
const current = route.name === 'Home' && feed === selectedFeed
return (
<FeedItem
key={feed}
href={'/?' + new URLSearchParams([['feed', feed]])}
title={feedInfo.displayName}
current={route.name === 'Home' && feed === selectedFeed}
<InlineLinkText
key={feedInfo.uri}
to={'/?' + new URLSearchParams([['feed', feed]])}
label={feedInfo.displayName}
onPress={() => {
setSelectedFeed(feed)
navigation.navigate('Home')
@@ -44,56 +56,25 @@ export function DesktopFeeds() {
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"
href="/feeds"
text={_(msg`More feeds`)}
style={[pal.link]}
/>
</View>
{/*
<InlineLinkText
to="/feeds"
label={_(msg`More feeds`)}
style={[a.text_lg]}>
{_(msg`More feeds`)}
</InlineLinkText>
*/}
</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 {useLingui} from '@lingui/react'
import {FEEDBACK_FORM_URL, HELP_DESK_URL} from '#/lib/constants'
import {usePalette} from '#/lib/hooks/usePalette'
import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries'
import {s} from '#/lib/styles'
import {useKawaiiMode} from '#/state/preferences/kawaii'
import {useSession} from '#/state/session'
import {TextLink} from '#/view/com/util/Link'
import {Text} from '#/view/com/util/text/Text'
import {atoms as a} from '#/alf'
import {DesktopFeeds} from '#/view/shell/desktop/Feeds'
import {DesktopSearch} from '#/view/shell/desktop/Search'
import {atoms as a, useTheme, web} from '#/alf'
import {InlineLinkText} from '#/components/Link'
import {ProgressGuideList} from '#/components/ProgressGuide/List'
import {DesktopFeeds} from './Feeds'
import {DesktopSearch} from './Search'
import {Text} from '#/components/Typography'
export function DesktopRightNav({routeName}: {routeName: string}) {
const pal = usePalette('default')
const t = useTheme()
const {_} = useLingui()
const {hasSession, currentAccount} = useSession()
@@ -28,117 +27,81 @@ export function DesktopRightNav({routeName}: {routeName: string}) {
}
return (
<View style={[styles.rightNav, pal.view]}>
<View style={{paddingVertical: 20}}>
{routeName === 'Search' ? (
<View style={{marginBottom: 18}}>
<DesktopFeeds />
</View>
) : (
<>
<View
style={[
web({
position: 'fixed',
left: 'calc(50vw + 300px + 20px)',
width: 300,
maxHeight: '100%',
overflowY: 'auto',
}),
]}>
<View style={[a.py_xl]}>
{routeName !== 'Search' && (
<View style={[a.pb_lg]}>
<DesktopSearch />
{hasSession && (
<>
<ProgressGuideList style={[{marginTop: 22, marginBottom: 8}]} />
<View style={[pal.border, styles.desktopFeedsContainer]}>
<DesktopFeeds />
</View>
</>
)}
</View>
)}
{hasSession && (
<>
<ProgressGuideList style={[a.mt_xl, a.mb_sm]} />
<View
style={[
a.pb_lg,
a.mb_lg,
a.border_b,
t.atoms.border_contrast_low,
]}>
<DesktopFeeds />
</View>
</>
)}
<View
style={[
styles.message,
{
paddingTop: hasSession ? 0 : 18,
},
]}>
<View style={[{flexWrap: 'wrap'}, s.flexRow, a.gap_xs]}>
{hasSession && (
<>
<TextLink
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>
<Text style={[a.leading_snug, t.atoms.text_contrast_low]}>
{hasSession && (
<>
<InlineLinkText
to={FEEDBACK_FORM_URL({
email: currentAccount?.email,
handle: currentAccount?.handle,
})}
label={_(msg`Feedback`)}>
{_(msg`Feedback`)}
</InlineLinkText>
{' • '}
</>
)}
</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>
)
}
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,
},
})