diff options
author | Samuel Newman <mozzius@protonmail.com> | 2025-04-03 03:21:15 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-02 17:21:15 -0700 |
commit | 87da619aaa92e0ec762e68c13b24e58a25da10a8 (patch) | |
tree | 4da902d3ca43a226f6da8e5c090ab33c2df3297a /src/components | |
parent | 8d1f97b5ffac5d86762f1d4e9384ff3097acbc52 (diff) | |
download | voidsky-87da619aaa92e0ec762e68c13b24e58a25da10a8.tar.zst |
[Explore] Base (#8053)
* migrate to #/screens * rm unneeded import * block drawer gesture on recent profiles * rm recommendations (#8056) * [Explore] Disable Trending videos (#8054) * remove giant header * disable * [Explore] Dynamic module ordering (#8066) * Dynamic module ordering * [Explore] New headers, metrics (#8067) * new sticky headers * improve spacing between modules * view metric on modules * update metrics names * [Explore] Suggested accounts module (#8072) * use modern profile card, update load more * add tab bar * tabbed suggested accounts * [Explore] Discover feeds module (#8073) * cap number of feeds to 3 * change feed pin button * Apply suggestions from code review Co-authored-by: surfdude29 <149612116+surfdude29@users.noreply.github.com> * restore statsig to log events * filter out followed profiles, make suer enough are loaded (#8090) * [Explore] Trending topics (#8055) * redesigned trending topics * rm borders on web * get post count / age / ranking from api * spacing tweaks * fetch more topics then slice * use api data for avis/category * rm top border * Integrate new SDK, part out components * Clean up * Use status field * Bump SDK * Send up interests and langs --------- Co-authored-by: Eric Bailey <git@esb.lol> * Clean up module spacing and borders (cherry picked from commit 63d19b6c2d67e226e0e14709b1047a1f88b3ce1c) (cherry picked from commit 62d7d394ab1dc31b40b9c2cf59075adbf94737a1) * Switch back border ordering (cherry picked from commit 34e3789f8b410132c1390df3c2bb8257630ebdd9) * [Explore] Starter Packs (#8095) * Temp WIP (cherry picked from commit 43b5d7b1e64b3adb1ed162262d0310e0bf026c18) * New SP card * Load state * Revert change * Cleanup * Interests and caching * Count total * Format * Caching * [Explore] Feed previews module (#8075) * wip new hook * get fetching working, maybe * get feed previews rendering! * fix header height * working pin button * extract out FeedLink * add loader * only make preview:header sticky * Fix headers * Header tweaks * Fix moderation filter * Fix threading --------- Co-authored-by: Eric Bailey <git@esb.lol> * Space it out * Fix query key * Mock new endpoint, filter saved feeds * Make sure we're pinning, lower cache time * add news category * Remove log * Improve suggested accounts load state * Integrate new app view endpoint * fragment * Update src/screens/Search/modules/ExploreTrendingTopics.tsx Co-authored-by: surfdude29 <149612116+surfdude29@users.noreply.github.com> * Update src/screens/Search/modules/ExploreTrendingTopics.tsx Co-authored-by: surfdude29 <149612116+surfdude29@users.noreply.github.com> * lint * maybe fix this --------- Co-authored-by: surfdude29 <149612116+surfdude29@users.noreply.github.com> Co-authored-by: Eric Bailey <git@esb.lol> Co-authored-by: Hailey <me@haileyok.com>
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/FeedCard.tsx | 68 | ||||
-rw-r--r-- | src/components/ProfileCard.tsx | 35 | ||||
-rw-r--r-- | src/components/ProgressGuide/FollowDialog.tsx | 15 | ||||
-rw-r--r-- | src/components/StarterPack/StarterPackCard.tsx | 31 | ||||
-rw-r--r-- | src/components/icons/Flame.tsx | 5 | ||||
-rw-r--r-- | src/components/icons/Trending.tsx (renamed from src/components/icons/Trending2.tsx) | 4 | ||||
-rw-r--r-- | src/components/icons/common.tsx | 6 | ||||
-rw-r--r-- | src/components/interstitials/Trending.tsx | 2 | ||||
-rw-r--r-- | src/components/interstitials/TrendingVideos.tsx | 2 |
9 files changed, 124 insertions, 44 deletions
diff --git a/src/components/FeedCard.tsx b/src/components/FeedCard.tsx index f20e517d4..665bbcba8 100644 --- a/src/components/FeedCard.tsx +++ b/src/components/FeedCard.tsx @@ -1,8 +1,8 @@ import React from 'react' -import {GestureResponderEvent, View} from 'react-native' +import {type GestureResponderEvent, View} from 'react-native' import { - AppBskyFeedDefs, - AppBskyGraphDefs, + type AppBskyFeedDefs, + type AppBskyGraphDefs, AtUri, RichText as RichTextApi, } from '@atproto/api' @@ -23,15 +23,20 @@ import * as Toast from '#/view/com/util/Toast' import {UserAvatar} from '#/view/com/util/UserAvatar' import {useTheme} from '#/alf' import {atoms as a} from '#/alf' -import {Button, ButtonIcon} from '#/components/Button' -import {PlusLarge_Stroke2_Corner0_Rounded as Plus} from '#/components/icons/Plus' -import {Trash_Stroke2_Corner0_Rounded as Trash} from '#/components/icons/Trash' -import {Link as InternalLink, LinkProps} from '#/components/Link' +import { + Button, + ButtonIcon, + type ButtonProps, + ButtonText, +} from '#/components/Button' +import {Pin_Stroke2_Corner0_Rounded as PinIcon} from '#/components/icons/Pin' +import {Link as InternalLink, type LinkProps} from '#/components/Link' import {Loader} from '#/components/Loader' import * as Prompt from '#/components/Prompt' -import {RichText, RichTextProps} from '#/components/RichText' +import {RichText, type RichTextProps} from '#/components/RichText' import {Text} from '#/components/Typography' -import * as bsky from '#/types/bsky' +import type * as bsky from '#/types/bsky' +import {Trash_Stroke2_Corner0_Rounded as TrashIcon} from './icons/Trash' type Props = { view: AppBskyFeedDefs.GeneratorView @@ -81,11 +86,11 @@ export function Link({ } export function Outer({children}: {children: React.ReactNode}) { - return <View style={[a.w_full, a.gap_md]}>{children}</View> + return <View style={[a.w_full, a.gap_sm]}>{children}</View> } export function Header({children}: {children: React.ReactNode}) { - return <View style={[a.flex_row, a.align_center, a.gap_md]}>{children}</View> + return <View style={[a.flex_row, a.align_center, a.gap_sm]}>{children}</View> } export type AvatarProps = {src: string | undefined; size?: number} @@ -220,22 +225,27 @@ export function Likes({count}: {count: number}) { export function SaveButton({ view, pin, + ...props }: { view: AppBskyFeedDefs.GeneratorView | AppBskyGraphDefs.ListView pin?: boolean -}) { + text?: boolean +} & Partial<ButtonProps>) { const {hasSession} = useSession() if (!hasSession) return null - return <SaveButtonInner view={view} pin={pin} /> + return <SaveButtonInner view={view} pin={pin} {...props} /> } function SaveButtonInner({ view, pin, + text = true, + ...buttonProps }: { view: AppBskyFeedDefs.GeneratorView | AppBskyGraphDefs.ListView pin?: boolean -}) { + text?: boolean +} & Partial<ButtonProps>) { const {_} = useLingui() const {data: preferences} = usePreferencesQuery() const {isPending: isAddSavedFeedPending, mutateAsync: saveFeeds} = @@ -294,14 +304,32 @@ function SaveButtonInner({ disabled={isPending} label={_(msg`Add this feed to your feeds`)} size="small" - variant="ghost" - color="secondary" - shape="square" - onPress={savedFeedConfig ? onPrompRemoveFeed : toggleSave}> + variant="solid" + color={savedFeedConfig ? 'secondary' : 'primary'} + onPress={savedFeedConfig ? onPrompRemoveFeed : toggleSave} + {...buttonProps}> {savedFeedConfig ? ( - <ButtonIcon size="md" icon={isPending ? Loader : Trash} /> + <> + {isPending ? ( + <ButtonIcon size="md" icon={Loader} /> + ) : ( + !text && <ButtonIcon size="md" icon={TrashIcon} /> + )} + {text && ( + <ButtonText> + <Trans>Unpin Feed</Trans> + </ButtonText> + )} + </> ) : ( - <ButtonIcon size="md" icon={isPending ? Loader : Plus} /> + <> + <ButtonIcon size="md" icon={isPending ? Loader : PinIcon} /> + {text && ( + <ButtonText> + <Trans>Pin Feed</Trans> + </ButtonText> + )} + </> )} </Button> diff --git a/src/components/ProfileCard.tsx b/src/components/ProfileCard.tsx index b56112dcf..a37432500 100644 --- a/src/components/ProfileCard.tsx +++ b/src/components/ProfileCard.tsx @@ -1,14 +1,14 @@ import React from 'react' -import {GestureResponderEvent, View} from 'react-native' +import {type GestureResponderEvent, View} from 'react-native' import { moderateProfile, - ModerationOpts, + type ModerationOpts, RichText as RichTextApi, } from '@atproto/api' import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' -import {LogEvents} from '#/lib/statsig/statsig' +import {type LogEvents} from '#/lib/statsig/statsig' import {sanitizeDisplayName} from '#/lib/strings/display-names' import {sanitizeHandle} from '#/lib/strings/handles' import {useProfileShadow} from '#/state/cache/profile-shadow' @@ -18,13 +18,18 @@ import {ProfileCardPills} from '#/view/com/profile/ProfileCard' import * as Toast from '#/view/com/util/Toast' import {UserAvatar} from '#/view/com/util/UserAvatar' import {atoms as a, useTheme} from '#/alf' -import {Button, ButtonIcon, ButtonProps, ButtonText} from '#/components/Button' +import { + Button, + ButtonIcon, + type ButtonProps, + ButtonText, +} from '#/components/Button' import {Check_Stroke2_Corner0_Rounded as Check} from '#/components/icons/Check' import {PlusLarge_Stroke2_Corner0_Rounded as Plus} from '#/components/icons/Plus' -import {Link as InternalLink, LinkProps} from '#/components/Link' +import {Link as InternalLink, type LinkProps} from '#/components/Link' import {RichText} from '#/components/RichText' import {Text} from '#/components/Typography' -import * as bsky from '#/types/bsky' +import type * as bsky from '#/types/bsky' export function Default({ profile, @@ -133,7 +138,7 @@ export function Avatar({ return ( <UserAvatar - size={42} + size={40} avatar={profile.avatar} type={profile.associated?.labeler ? 'labeler' : 'user'} moderation={moderation.ui('avatar')} @@ -149,8 +154,8 @@ export function AvatarPlaceholder() { a.rounded_full, t.atoms.bg_contrast_50, { - width: 42, - height: 42, + width: 40, + height: 40, }, ]} /> @@ -261,7 +266,7 @@ export function DescriptionPlaceholder({ }) { const t = useTheme() return ( - <View style={[{gap: 8}]}> + <View style={[a.pt_2xs, {gap: 6}]}> {Array(numberOfLines) .fill(0) .map((_, i) => ( @@ -286,6 +291,7 @@ export type FollowButtonProps = { LogEvents['profile:unfollow']['logContext'] colorInverted?: boolean onFollow?: () => void + withIcon?: boolean } & Partial<ButtonProps> export function FollowButton(props: FollowButtonProps) { @@ -301,6 +307,7 @@ export function FollowButtonInner({ onPress: onPressProp, onFollow, colorInverted, + withIcon = true, ...rest }: FollowButtonProps) { const {_} = useLingui() @@ -386,7 +393,9 @@ export function FollowButtonInner({ color="secondary" {...rest} onPress={onPressUnfollow}> - <ButtonIcon icon={Check} position={isRound ? undefined : 'left'} /> + {withIcon && ( + <ButtonIcon icon={Check} position={isRound ? undefined : 'left'} /> + )} {isRound ? null : <ButtonText>{unfollowLabel}</ButtonText>} </Button> ) : ( @@ -397,7 +406,9 @@ export function FollowButtonInner({ color={colorInverted ? 'secondary_inverted' : 'primary'} {...rest} onPress={onPressFollow}> - <ButtonIcon icon={Plus} position={isRound ? undefined : 'left'} /> + {withIcon && ( + <ButtonIcon icon={Plus} position={isRound ? undefined : 'left'} /> + )} {isRound ? null : <ButtonText>{followLabel}</ButtonText>} </Button> )} diff --git a/src/components/ProgressGuide/FollowDialog.tsx b/src/components/ProgressGuide/FollowDialog.tsx index 006f86574..41c3d41d8 100644 --- a/src/components/ProgressGuide/FollowDialog.tsx +++ b/src/components/ProgressGuide/FollowDialog.tsx @@ -5,7 +5,7 @@ import Animated, { LinearTransition, ZoomInEasyDown, } from 'react-native-reanimated' -import {AppBskyActorDefs, ModerationOpts} from '@atproto/api' +import {type AppBskyActorDefs, type ModerationOpts} from '@atproto/api' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' @@ -19,8 +19,8 @@ import {useActorSearchPaginated} from '#/state/queries/actor-search' import {usePreferencesQuery} from '#/state/queries/preferences' import {useSuggestedFollowsByActorQuery} from '#/state/queries/suggested-follows' import {useSession} from '#/state/session' -import {Follow10ProgressGuide} from '#/state/shell/progress-guide' -import {ListMethods} from '#/view/com/util/List' +import {type Follow10ProgressGuide} from '#/state/shell/progress-guide' +import {type ListMethods} from '#/view/com/util/List' import { popularInterests, useInterestsDisplayNames, @@ -31,7 +31,7 @@ import { tokens, useBreakpoints, useTheme, - ViewStyleProp, + type ViewStyleProp, web, } from '#/alf' import {Button, ButtonIcon, ButtonText} from '#/components/Button' @@ -452,12 +452,14 @@ let Tabs = ({ selectedInterest, hasSearchText, interestsDisplayNames, + TabComponent = Tab, }: { onSelectTab: (tab: string) => void interests: string[] selectedInterest: string hasSearchText: boolean interestsDisplayNames: Record<string, string> + TabComponent?: React.ComponentType<React.ComponentProps<typeof Tab>> }): React.ReactNode => { const listRef = useRef<ScrollView>(null) const [scrollX, setScrollX] = useState(0) @@ -532,7 +534,7 @@ let Tabs = ({ {interests.map((interest, i) => { const active = interest === selectedInterest && !hasSearchText return ( - <Tab + <TabComponent key={interest} onSelectTab={handleSelectTab} active={active} @@ -547,6 +549,7 @@ let Tabs = ({ ) } Tabs = memo(Tabs) +export {Tabs} let Tab = ({ onSelectTab, @@ -822,7 +825,7 @@ function Empty({message}: {message: string}) { ) } -function boostInterests(boosts?: string[]) { +export function boostInterests(boosts?: string[]) { return (_a: string, _b: string) => { const indexA = boosts?.indexOf(_a) ?? -1 const indexB = boosts?.indexOf(_b) ?? -1 diff --git a/src/components/StarterPack/StarterPackCard.tsx b/src/components/StarterPack/StarterPackCard.tsx index b5760fd6d..88d075b78 100644 --- a/src/components/StarterPack/StarterPackCard.tsx +++ b/src/components/StarterPack/StarterPackCard.tsx @@ -13,7 +13,10 @@ import {precacheStarterPack} from '#/state/queries/starter-packs' import {useSession} from '#/state/session' import {atoms as a, useTheme} from '#/alf' import {StarterPack as StarterPackIcon} from '#/components/icons/StarterPack' -import {Link as BaseLink, LinkProps as BaseLinkProps} from '#/components/Link' +import { + Link as BaseLink, + type LinkProps as BaseLinkProps, +} from '#/components/Link' import {Text} from '#/components/Typography' import * as bsky from '#/types/bsky' @@ -104,6 +107,32 @@ export function Card({ ) } +export function useStarterPackLink({ + view, +}: { + view: bsky.starterPack.AnyStarterPackView +}) { + const {_} = useLingui() + const qc = useQueryClient() + const {rkey, handleOrDid} = React.useMemo(() => { + const rkey = new AtUri(view.uri).rkey + const {creator} = view + return {rkey, handleOrDid: creator.handle || creator.did} + }, [view]) + const precache = () => { + precacheResolvedUri(qc, view.creator.handle, view.creator.did) + precacheStarterPack(qc, view) + } + + return { + to: `/starter-pack/${handleOrDid}/${rkey}`, + label: AppBskyGraphStarterpack.isRecord(view.record) + ? _(msg`Navigate to ${view.record.name}`) + : _(msg`Navigate to starter pack`), + precache, + } +} + export function Link({ starterPack, children, diff --git a/src/components/icons/Flame.tsx b/src/components/icons/Flame.tsx new file mode 100644 index 000000000..42569b0de --- /dev/null +++ b/src/components/icons/Flame.tsx @@ -0,0 +1,5 @@ +import {createSinglePathSVG} from './TEMPLATE' + +export const Flame_Stroke2_Corner1_Rounded = createSinglePathSVG({ + path: 'M11.158 2.879c.584-.835 1.757-1.137 2.673-.507.951.654 2.597 1.92 4.013 3.694S20.5 10.194 20.5 13c0 4.997-3.752 9-8.5 9s-8.5-4.003-8.5-9c0-2.035.874-4.636 2.578-6.712.746-.91 2.034-.855 2.786-.133l2.294-3.276Zm-3.04 15.758C6.538 17.386 5.5 15.37 5.5 13c0-1.511.666-3.616 2.042-5.342.87.797 2.254.653 2.939-.325l2.286-3.265c.871.606 2.299 1.723 3.514 3.246C17.53 8.879 18.5 10.804 18.5 13c0 2.369-1.038 4.386-2.618 5.637q.117-.518.118-1.061c0-2.601-2.038-4.382-2.911-5.04a1.8 1.8 0 0 0-2.177 0C10.038 13.195 8 14.976 8 17.577q0 .543.118 1.061ZM12 14.222c-.825.648-2 1.859-2 3.354C10 19.043 11.016 20 12 20s2-.957 2-2.424c0-1.495-1.175-2.706-2-3.354Z', +}) diff --git a/src/components/icons/Trending2.tsx b/src/components/icons/Trending.tsx index 5fba4167b..bdc8539e0 100644 --- a/src/components/icons/Trending2.tsx +++ b/src/components/icons/Trending.tsx @@ -3,3 +3,7 @@ import {createSinglePathSVG} from './TEMPLATE' export const Trending2_Stroke2_Corner2_Rounded = createSinglePathSVG({ path: 'm18.192 5.004 1.864 5.31a1 1 0 0 0 1.887-.662L20.08 4.34c-.665-1.893-3.378-1.741-3.834.207l-3.381 14.449-2.985-9.605C9.3 7.531 6.684 7.506 6.07 9.355l-1.18 3.56-.969-2.312a1 1 0 0 0-1.844.772l.97 2.315c.715 1.71 3.159 1.613 3.741-.144l1.18-3.56 2.985 9.605c.607 1.952 3.392 1.848 3.857-.138l3.381-14.449Z', }) + +export const Trending3_Stroke2_Corner1_Rounded = createSinglePathSVG({ + path: 'M15 7a1 1 0 0 1 1-1h5a1 1 0 0 1 1 1v5a1 1 0 1 1-2 0V9.414L14.414 15a2 2 0 0 1-2.828 0L9 12.414l-5.293 5.293a1 1 0 0 1-1.414-1.414L7.586 11a2 2 0 0 1 2.828 0L13 13.586 18.586 8H16a1 1 0 0 1-1-1Z', +}) diff --git a/src/components/icons/common.tsx b/src/components/icons/common.tsx index 996ecb626..bc1e045a4 100644 --- a/src/components/icons/common.tsx +++ b/src/components/icons/common.tsx @@ -1,5 +1,5 @@ -import {StyleSheet, TextProps} from 'react-native' -import type {PathProps, SvgProps} from 'react-native-svg' +import {StyleSheet, type TextProps} from 'react-native' +import {type PathProps, type SvgProps} from 'react-native-svg' import {Defs, LinearGradient, Stop} from 'react-native-svg' import {nanoid} from 'nanoid/non-secure' @@ -19,7 +19,7 @@ export const sizes = { lg: 24, xl: 28, '2xl': 32, -} +} as const export function useCommonSVGProps(props: Props) { const t = useTheme() diff --git a/src/components/interstitials/Trending.tsx b/src/components/interstitials/Trending.tsx index 7412c6f0a..56c756c50 100644 --- a/src/components/interstitials/Trending.tsx +++ b/src/components/interstitials/Trending.tsx @@ -15,7 +15,7 @@ import {BlockDrawerGesture} from '#/view/shell/BlockDrawerGesture' import {atoms as a, useGutters, useTheme} from '#/alf' import {Button, ButtonIcon} from '#/components/Button' import {TimesLarge_Stroke2_Corner0_Rounded as X} from '#/components/icons/Times' -import {Trending2_Stroke2_Corner2_Rounded as Graph} from '#/components/icons/Trending2' +import {Trending2_Stroke2_Corner2_Rounded as Graph} from '#/components/icons/Trending' import * as Prompt from '#/components/Prompt' import {TrendingTopicLink} from '#/components/TrendingTopics' import {Text} from '#/components/Typography' diff --git a/src/components/interstitials/TrendingVideos.tsx b/src/components/interstitials/TrendingVideos.tsx index 126d6f417..fab738b9c 100644 --- a/src/components/interstitials/TrendingVideos.tsx +++ b/src/components/interstitials/TrendingVideos.tsx @@ -16,7 +16,7 @@ import {atoms as a, useGutters, useTheme} from '#/alf' import {Button, ButtonIcon} from '#/components/Button' import {ChevronRight_Stroke2_Corner0_Rounded as ChevronRight} from '#/components/icons/Chevron' import {TimesLarge_Stroke2_Corner0_Rounded as X} from '#/components/icons/Times' -import {Trending2_Stroke2_Corner2_Rounded as Graph} from '#/components/icons/Trending2' +import {Trending2_Stroke2_Corner2_Rounded as Graph} from '#/components/icons/Trending' import {Link} from '#/components/Link' import * as Prompt from '#/components/Prompt' import {Text} from '#/components/Typography' |