Skip to content

Commit d723cd0

Browse files
committed
feat: profile sticky header
1 parent c2e25ac commit d723cd0

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

src/components/navigation/navbar/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useAuth } from '../../../lib/bluesky/hooks/use-auth';
33
import { useBlueskyStore } from '../../../lib/bluesky/store';
44
import { CreatePost } from '../../create-post';
55
import { cn } from '@/lib/utils';
6-
import { useScollVisible } from '@/hooks/use-scroll-visible';
6+
import { useScrollVisible } from '@/hooks/use-scroll-visible';
77
import { Avatar } from '../../ui/avatar';
88
import { useProfile } from '@/lib/bluesky/hooks/use-profile';
99
import { HomeLink } from './home-link';
@@ -13,16 +13,19 @@ import { NotificationsLink } from './notifications-link';
1313
import { SettingsLink } from './settings-link';
1414
import { ProfileLink } from './profile-link';
1515
import { LoginButton } from './login-button';
16+
import { useRef } from 'react';
1617

1718
export const Navbar = () => {
1819
const { isAuthenticated } = useAuth();
1920
const location = useLocation();
20-
const isVisible = useScollVisible();
21+
const ref = useRef<HTMLDivElement>(null);
22+
const isVisible = useScrollVisible(ref);
2123
const handle = useBlueskyStore((state) => state.session?.handle);
2224
const { data: profile } = useProfile({ handle });
2325

2426
return (
2527
<div
28+
ref={ref}
2629
className={cn(
2730
'bg-background text-foreground sticky',
2831
// base

src/components/sticky-header.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ArrowLeftIcon } from 'lucide-react';
22
import { Button } from './ui/button';
33
import { cn } from '@/lib/utils';
4-
import { useScollVisible } from '@/hooks/use-scroll-visible';
4+
import { useScrollVisible } from '@/hooks/use-scroll-visible';
55

66
export const StickyHeader = ({
77
children,
@@ -12,7 +12,7 @@ export const StickyHeader = ({
1212
backButton?: boolean;
1313
className?: string;
1414
}) => {
15-
const isVisible = useScollVisible();
15+
const isVisible = useScrollVisible();
1616

1717
return (
1818
<div

src/hooks/use-scroll-visible.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useState, useEffect } from 'react';
22

3-
export const useScollVisible = () => {
3+
export const useScrollVisible = () => {
44
const [isVisible, setIsVisible] = useState(true);
55
const [lastScrollY, setLastScrollY] = useState(0);
66

src/routes/profile/$handle/index.lazy.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { Handle } from '@/components/ui/handle';
2424
import { Avatar } from '@/components/ui/avatar';
2525
import { Banner } from '@/components/ui/banner';
2626
import { ErrorBoundary } from '@/components/error-boundary';
27+
import { StickyHeader } from '@/components/sticky-header';
2728

2829
export const Route = createLazyFileRoute('/profile/$handle/')({
2930
component: Profile,
@@ -235,7 +236,7 @@ function Profile() {
235236
setSelectedTab(selectedId);
236237
}}
237238
>
238-
<div>
239+
<StickyHeader backButton={false} className="border-none p-0">
239240
<TabList label="Profile tabs">
240241
{[
241242
{
@@ -254,7 +255,7 @@ function Profile() {
254255
<Tab name={name} id={id} selectedTab={selectedTab} key={id} />
255256
))}
256257
</TabList>
257-
</div>
258+
</StickyHeader>
258259
<Ariakit.TabPanel tabId="all">
259260
<All />
260261
</Ariakit.TabPanel>

0 commit comments

Comments
 (0)