Improve explore treatment a bit, add some polish to cards

This commit is contained in:
Eric Bailey
2024-12-11 16:37:26 -06:00
parent a74b42f798
commit 73aaeb2da3
3 changed files with 53 additions and 43 deletions
+1
View File
@@ -6,6 +6,7 @@ export function GradientFill({
gradient, gradient,
}: { }: {
gradient: gradient:
| typeof tokens.gradients.primary
| typeof tokens.gradients.sky | typeof tokens.gradients.sky
| typeof tokens.gradients.midnight | typeof tokens.gradients.midnight
| typeof tokens.gradients.sunrise | typeof tokens.gradients.sunrise
+27 -33
View File
@@ -2,42 +2,25 @@ import {View} from 'react-native'
import {msg} from '@lingui/macro' import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {atoms as a, useTheme} from '#/alf' import {atoms as a, useGutters, useTheme, ViewStyleProp} from '#/alf'
import {Link as InternalLink, LinkProps} from '#/components/Link' import {Link as InternalLink, LinkProps} from '#/components/Link'
import {Text} from '#/components/Typography' import {Text} from '#/components/Typography'
export function Grid({topics}: {topics: string[]}) { export function Topic({topic, style}: {topic: string} & ViewStyleProp) {
return (
<View style={[a.flex_row, a.flex_wrap, a.gap_sm, a.px_sm, a.py_sm]}>
{topics.map(topic => (
<Item key={topic} topic={topic} />
))}
</View>
)
}
export function Item({topic}: {topic: string}) {
return (
<Link topic={topic}>
<Card topic={topic} />
</Link>
)
}
export function Card({topic}: {topic: string}) {
const t = useTheme() const t = useTheme()
return ( return (
<View <View
style={[ style={[
a.flex_1, a.p_sm,
a.gap_xs,
a.px_md, a.px_md,
a.py_md, a.rounded_md,
a.border, a.border,
t.atoms.border_contrast_medium, t.atoms.border_contrast_medium,
a.rounded_md, style,
]}> ]}>
<Topic topic={topic} /> <Text style={[a.text_md, a.font_bold, a.leading_snug]} numberOfLines={1}>
{topic}
</Text>
</View> </View>
) )
} }
@@ -65,15 +48,26 @@ export function Link({
) )
} }
export function Topic({topic}: {topic: string}) { export function Grid({topics}: {topics: string[]}) {
const t = useTheme()
const gutters = useGutters([0, 'compact'])
return ( return (
<View style={[a.flex_1]}> <View style={[a.flex_row, a.flex_wrap, a.gap_sm, gutters]}>
<Text {topics.map(topic => (
emoji <Link key={topic} topic={topic}>
style={[a.text_md, a.font_bold, a.leading_snug, a.self_start]} {({hovered}) => (
numberOfLines={1}> <Topic
{topic} topic={topic}
</Text> style={[
hovered && [
t.atoms.border_contrast_high,
t.atoms.bg_contrast_25,
],
]}
/>
)}
</Link>
))}
</View> </View>
) )
} }
+25 -10
View File
@@ -25,9 +25,10 @@ import {
ProfileCardFeedLoadingPlaceholder, ProfileCardFeedLoadingPlaceholder,
} from '#/view/com/util/LoadingPlaceholder' } from '#/view/com/util/LoadingPlaceholder'
import {UserAvatar} from '#/view/com/util/UserAvatar' import {UserAvatar} from '#/view/com/util/UserAvatar'
import {atoms as a, useTheme, ViewStyleProp} from '#/alf' import {atoms as a, tokens,useTheme, ViewStyleProp} from '#/alf'
import {Button} from '#/components/Button' import {Button} from '#/components/Button'
import * as FeedCard from '#/components/FeedCard' import * as FeedCard from '#/components/FeedCard'
import {GradientFill} from '#/components/GradientFill'
import {ArrowBottom_Stroke2_Corner0_Rounded as ArrowBottom} from '#/components/icons/Arrow' import {ArrowBottom_Stroke2_Corner0_Rounded as ArrowBottom} from '#/components/icons/Arrow'
import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfo} from '#/components/icons/CircleInfo' import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfo} from '#/components/icons/CircleInfo'
import {Props as SVGIconProps} from '#/components/icons/common' import {Props as SVGIconProps} from '#/components/icons/common'
@@ -41,11 +42,13 @@ import {Text} from '#/components/Typography'
function SuggestedItemsHeader({ function SuggestedItemsHeader({
title, title,
titleChild,
description, description,
style, style,
icon: Icon, icon: Icon,
}: { }: {
title: string title: string
titleChild?: React.ReactNode
description: string description: string
icon: React.ComponentType<SVGIconProps> icon: React.ComponentType<SVGIconProps>
} & ViewStyleProp) { } & ViewStyleProp) {
@@ -69,6 +72,7 @@ function SuggestedItemsHeader({
style={{marginLeft: -2}} style={{marginLeft: -2}}
/> />
<Text style={[a.text_2xl, a.font_heavy, t.atoms.text]}>{title}</Text> <Text style={[a.text_2xl, a.font_heavy, t.atoms.text]}>{title}</Text>
{titleChild}
</View> </View>
<Text style={[t.atoms.text_contrast_high, a.leading_snug]}> <Text style={[t.atoms.text_contrast_high, a.leading_snug]}>
{description} {description}
@@ -341,13 +345,6 @@ export function Explore() {
const items = React.useMemo<ExploreScreenItems[]>(() => { const items = React.useMemo<ExploreScreenItems[]>(() => {
const i: ExploreScreenItems[] = [] const i: ExploreScreenItems[] = []
i.push({
type: 'header',
key: 'trending-topics-header',
title: _(msg`Trending (beta)`),
description: _(msg`What people are posting about now.`),
icon: Trending,
})
i.push({ i.push({
type: 'trendingTopics', type: 'trendingTopics',
key: `trending-topics`, key: `trending-topics`,
@@ -598,7 +595,25 @@ export function Explore() {
) )
} }
case 'trendingTopics': { case 'trendingTopics': {
return <TrendingTopics.Grid topics={item.topics} /> return (
<>
<SuggestedItemsHeader
title={_(msg`Trending`)}
description={_(msg`What people are posting about now.`)}
icon={Trending}
titleChild={
<View
style={[a.py_xs, a.px_sm, a.rounded_sm, a.overflow_hidden]}>
<GradientFill gradient={tokens.gradients.primary} />
<Text style={[a.text_md, a.font_heavy]}>BETA</Text>
</View>
}
/>
<View style={[a.pt_md, a.pb_lg]}>
<TrendingTopics.Grid topics={item.topics} />
</View>
</>
)
} }
case 'suggestedStarterPacks': { case 'suggestedStarterPacks': {
return ( return (
@@ -680,7 +695,7 @@ export function Explore() {
} }
} }
}, },
[t, moderationOpts], [_, t, moderationOpts],
) )
// note: actually not a screen, instead it's nested within // note: actually not a screen, instead it's nested within