Skip to content

Commit b5c0338

Browse files
committed
refresh button
1 parent 1e5f8ec commit b5c0338

File tree

4 files changed

+51
-18
lines changed

4 files changed

+51
-18
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use client';
2+
3+
import Link from 'next/link';
4+
import { FC, ReactNode } from 'react';
5+
6+
type LinkWithStopPropagationProps = {
7+
children: ReactNode;
8+
href: string;
9+
};
10+
11+
export const LinkWithStopPropagation: FC<LinkWithStopPropagationProps> = ({ children, href }) => {
12+
return (
13+
<Link href={href} onClick={(event) => event.stopPropagation()}>
14+
{children}
15+
</Link>
16+
);
17+
};

app/by/[rankingType]/page.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import Link from 'next/link';
2-
31
import { Page } from '@/components/page/page';
42
import { RankDelta } from '@/components/rank-delta/rank-delta';
53
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
@@ -16,6 +14,7 @@ import { RankingsDocument, RankOrder } from '@/types/generated/graphql';
1614
import { getInitials } from '@/utils/get-initials';
1715

1816
import { ClickableRow } from './components/clickale-row';
17+
import { LinkWithStopPropagation } from './components/link-with-stop-propagation';
1918

2019
const ITEMS_PER_PAGE = 100;
2120

@@ -101,7 +100,7 @@ export default async function GlobalRanking({
101100
<AvatarFallback>{getInitials(user?.login)}</AvatarFallback>
102101
</Avatar>
103102
)}
104-
<Link href={`/profile/${user?.login}`}>{user?.login}</Link>
103+
<LinkWithStopPropagation href={`/profile/${user?.login}`}>{user?.login}</LinkWithStopPropagation>
105104
</TableCell>
106105
<TableCell className="hidden sm:table-cell break-all whitespace-normal">{user?.location}</TableCell>
107106
<TableCell className="text-right">{user?.[rankPropName]?.toLocaleString('en-US')}</TableCell>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
'use client';
2+
3+
import { RefreshCw } from 'lucide-react';
4+
import { useParams } from 'next/navigation';
5+
import { usePostHog } from 'posthog-js/react';
6+
import { toast } from 'sonner';
7+
8+
import { Button } from '@/components/ui/button';
9+
10+
export const RefreshButton = () => {
11+
const { login } = useParams();
12+
const posthog = usePostHog();
13+
14+
const handleRefresh = async () => {
15+
toast.info('🚧 This feature is still under construction!', {
16+
description:
17+
"I'm wrestling bugs, chugging coffee, and coding like a caffeinated squirrel to make it happen. Want to lend a hand or just say hi? Catch me on GitHub!",
18+
});
19+
20+
posthog.capture('landingPage.search', { login });
21+
};
22+
23+
return (
24+
<Button size="sm" className="flex-grow" onClick={handleRefresh}>
25+
Refresh
26+
<RefreshCw className="size-4" />
27+
</Button>
28+
);
29+
};

app/profile/[login]/page.tsx

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
import { formatDistanceToNow } from 'date-fns';
2-
import {
3-
BriefcaseBusiness,
4-
ExternalLink,
5-
Hourglass,
6-
Link2,
7-
Mail,
8-
MapPin,
9-
RefreshCw,
10-
Timer,
11-
UsersRound,
12-
} from 'lucide-react';
2+
import { BriefcaseBusiness, ExternalLink, Hourglass, Link2, Mail, MapPin, Timer, UsersRound } from 'lucide-react';
133
import type { Metadata } from 'next';
144
import Image from 'next/image';
155
import Link from 'next/link';
@@ -25,6 +15,7 @@ import { ProfileForMetadataDocument, UserDocument } from '@/types/generated/grap
2515
import { ProfileListItem } from './components/profile-list-item';
2616
import { ProfileTimeline } from './components/profile-timeline';
2717
import { RanksOverview } from './components/ranks-overview';
18+
import { RefreshButton } from './components/refresh-button';
2819
import { RepositoriesOverview } from './components/repositories-overiview';
2920
import { getSocialIcon } from './utils/get-social-icon';
3021

@@ -71,10 +62,7 @@ export default async function Profile({ params }: { params: Promise<{ login: str
7162
</div>
7263
</div>
7364
<div className="flex flex-row md:flex-col gap-4">
74-
<Button size="sm" className="flex-grow">
75-
Refresh
76-
<RefreshCw className="size-4" />
77-
</Button>
65+
<RefreshButton />
7866
<Button size="sm" variant="secondary" className="flex-grow" asChild>
7967
<Link href={`https://github.com/${user.login}`} target="_blank" rel="noopener noreferrer">
8068
Open GitHub

0 commit comments

Comments
 (0)