From b71ffff08b25a40d81a905fef7af039eb2671226 Mon Sep 17 00:00:00 2001 From: luna Date: Tue, 7 Jan 2025 20:17:28 +1030 Subject: [PATCH] fix: add sticky header to posts --- src/components/PostCard.tsx | 2 +- src/components/Timeline.tsx | 2 +- src/i18n/lang/en.ts | 1 + src/routes/__root.tsx | 2 +- src/routes/profile/$handle/index.lazy.tsx | 58 ++++++++++--------- .../profile/$handle/post.$postId.lazy.tsx | 12 ++-- 6 files changed, 43 insertions(+), 34 deletions(-) diff --git a/src/components/PostCard.tsx b/src/components/PostCard.tsx index 05428fd..97dccac 100644 --- a/src/components/PostCard.tsx +++ b/src/components/PostCard.tsx @@ -79,7 +79,7 @@ export function PostCard({ post, context, className, onClick }: PostCardProps) { params={{ handle: post.author.handle, postId: post.uri.split('/').pop()! }} className="absolute inset-0" /> -
+
diff --git a/src/components/Timeline.tsx b/src/components/Timeline.tsx index 36fcb0a..71a6958 100644 --- a/src/components/Timeline.tsx +++ b/src/components/Timeline.tsx @@ -117,7 +117,7 @@ export function Timeline({ columnNumber = 1 }: { columnNumber: number }) { endReached={() => fetchNextPage()} components={{ List: forwardRef(function List(props, ref) { - return
; + return
; }), }} itemContent={(index: number) => ( diff --git a/src/i18n/lang/en.ts b/src/i18n/lang/en.ts index 73a21cb..0ae6441 100644 --- a/src/i18n/lang/en.ts +++ b/src/i18n/lang/en.ts @@ -16,6 +16,7 @@ export const en = { blueskyHandle: 'bluesky handle e.g. @alice.bsky.social', following: 'following', followers: 'followers', + post: 'post', posts: 'posts', replies: 'replies', reposts: 'reposts', diff --git a/src/routes/__root.tsx b/src/routes/__root.tsx index e42de5d..6a7db00 100644 --- a/src/routes/__root.tsx +++ b/src/routes/__root.tsx @@ -95,7 +95,7 @@ function Root() {
-
+
diff --git a/src/routes/profile/$handle/index.lazy.tsx b/src/routes/profile/$handle/index.lazy.tsx index 229ec41..f53e307 100644 --- a/src/routes/profile/$handle/index.lazy.tsx +++ b/src/routes/profile/$handle/index.lazy.tsx @@ -29,7 +29,7 @@ export const Route = createLazyFileRoute('/profile/$handle/')({ }); const List = forwardRef(function List(props: HtmlHTMLAttributes, ref: Ref) { - return
; + return
; }); function All() { @@ -146,7 +146,9 @@ function Media() { const filteredPosts = feed // Filter to only media - ?.filter(({ post }) => (post.record as BSkyPost['record']).embed?.$type === 'app.bsky.embed.images'); + // TODO: fix this + // eslint-disable-next-line @typescript-eslint/no-explicit-any + ?.filter(({ post }) => (post.record as any).embed?.$type === 'app.bsky.embed.images'); return ( -
- -
- -
-
-

{profile?.displayName || profile.handle}

- - {profile.viewer?.following && profile.viewer?.followedBy && 'Mutuals'} - - {handle !== session?.handle && } -
- - {!experiments.zenMode && ( +
+
+ +
+ +
- - - +

{profile?.displayName || profile.handle}

+ + {profile.viewer?.following && profile.viewer?.followedBy && 'Mutuals'} + + {handle !== session?.handle && }
- )} - + + {!experiments.zenMode && ( +
+ + + +
+ )} + - {profile.viewer?.blockingByList && ( -
- {t('profile:blockedBy', { name: profile.viewer.blockingByList.name })} -
- )} + {profile.viewer?.blockingByList && ( +
+ {t('profile:blockedBy', { name: profile.viewer.blockingByList.name })} +
+ )} - + +
{!profile.viewer?.blockingByList && ( diff --git a/src/routes/profile/$handle/post.$postId.lazy.tsx b/src/routes/profile/$handle/post.$postId.lazy.tsx index 68b25d9..8a39925 100644 --- a/src/routes/profile/$handle/post.$postId.lazy.tsx +++ b/src/routes/profile/$handle/post.$postId.lazy.tsx @@ -8,13 +8,14 @@ import { Helmet } from 'react-helmet'; import { Loading } from '@/components/ui/loading'; import { Virtuoso } from 'react-virtuoso'; import { forwardRef, HtmlHTMLAttributes, Ref } from 'react'; +import { StickyHeader } from '@/components/sticky-header'; export const Route = createLazyFileRoute('/profile/$handle/post/$postId')({ component: Post, }); const List = forwardRef(function List(props: HtmlHTMLAttributes, ref: Ref) { - return
; + return
; }); function Post() { @@ -37,12 +38,15 @@ function Post() { -
+ +

{t('post')}

+
+
*]: since we're targeting the window scroll div // and the div is inside of the Virtuoso component - className="[&>*]:flex [&>*]:flex-col [&>*]:gap-2" + className="[&>*]:flex [&>*]:flex-col" totalCount={replies.length} itemContent={(index) => { const reply = replies?.[index]; @@ -50,7 +54,7 @@ function Post() { return reply.post && ; }} components={{ - Header: () => , + Header: () => , List, }} />