Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 43 additions & 4 deletions components/Leaderboard/LeaderboardCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,41 @@ export function LeaderboardCard({
return "";
};

const getGitHubSearchUrl = (activityName: string, username: string) => {
if (!username || !/^[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/.test(username)) {
return null;
}

const baseUrl = "https://github.com/search";
const encodedUsername = encodeURIComponent(username);

switch (activityName) {
case "PR merged":
return `${baseUrl}?q=is%3Apr+author%3A${encodedUsername}+is%3Amerged`;
case "PR opened":
return `${baseUrl}?q=is%3Apr+author%3A${encodedUsername}+is%3Aopen`;
case "Issue opened":
return `${baseUrl}?q=is%3Aissue+author%3A${encodedUsername}+is%3Aopen`;
case "Issue closed":
return `${baseUrl}?q=is%3Aissue+author%3A${encodedUsername}+is%3Aclosed`;
case "Issue assigned":
return `${baseUrl}?q=is%3Aissue+assignee%3A${encodedUsername}`;
case "Issue labeled":
return `${baseUrl}?q=is%3Aissue+labeler%3A${encodedUsername}`;
Comment thread
kiransatdive marked this conversation as resolved.
case "Review submitted":
return `${baseUrl}?q=is%3Apr+reviewer%3A${encodedUsername}`;
default:
return null;
}
};

const openGitHubSearch = (activityName: string, username: string) => {
const url = getGitHubSearchUrl(activityName, username);
if (url) {
window.open(url, '_blank', 'noopener,noreferrer');
}
};
Comment thread
kiransatdive marked this conversation as resolved.

const styles = getRankStyles(rank);

if (variant === "list") {
Expand Down Expand Up @@ -251,8 +286,9 @@ export function LeaderboardCard({
return (
<div
key={activityName}
onClick={() => openGitHubSearch(activityName, entry.username)}
className={cn(
"relative text-xs px-3 py-2 rounded-md border-l-2 transition-all hover:shadow-sm flex items-center justify-between gap-2",
"relative text-xs px-3 py-2 rounded-md border-l-2 transition-all hover:shadow-sm flex items-center justify-between gap-2 cursor-pointer",
style.bgColor,
style.borderColor
)}
Comment thread
kiransatdive marked this conversation as resolved.
Expand Down Expand Up @@ -339,8 +375,9 @@ export function LeaderboardCard({
return (
<div
key={activityName}
onClick={() => openGitHubSearch(activityName, entry.username)}
className={cn(
"relative text-xs px-3 py-1.5 rounded-md border-l-2 transition-all hover:shadow-sm",
"relative text-xs px-3 py-1.5 rounded-md border-l-2 transition-all hover:shadow-sm cursor-pointer",
style.bgColor,
style.borderColor
)}
Expand Down Expand Up @@ -480,8 +517,9 @@ export function LeaderboardCard({
return (
<div
key={activityName}
onClick={() => openGitHubSearch(activityName, entry.username)}
className={cn(
"relative text-xs px-2 py-1.5 rounded-md border-l-2 transition-all hover:shadow-sm flex items-center justify-between gap-1",
"relative text-xs px-2 py-1.5 rounded-md border-l-2 transition-all hover:shadow-sm flex items-center justify-between gap-1 cursor-pointer",
style.bgColor,
style.borderColor
)}
Expand Down Expand Up @@ -575,8 +613,9 @@ export function LeaderboardCard({
return (
<div
key={activityName}
onClick={() => openGitHubSearch(activityName, entry.username)}
className={cn(
"relative text-xs px-3 py-2 rounded-md border-l-2 transition-all hover:shadow-sm flex items-center justify-between gap-2",
"relative text-xs px-3 py-2 rounded-md border-l-2 transition-all hover:shadow-sm flex items-center justify-between gap-2 cursor-pointer",
style.bgColor,
style.borderColor
)}
Expand Down
4 changes: 2 additions & 2 deletions components/Leaderboard/LeaderboardView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ export default function LeaderboardView({
variant="ghost"
size="sm"
onClick={clearFilters}
className="h-9 hover:bg-[#50B78B]/20 cursor-pointer"
className="h-9 hover:bg-[#50B78B]/20 hover:text-[#50B78B] hover:shadow-[0_0_8px_rgba(80,183,139,0.3)] active:bg-[#50B78B]/30 active:text-[#50B78B] active:shadow-[0_0_12px_rgba(80,183,139,0.5)] transition-all duration-200 cursor-pointer"
>
<X className="h-4 w-4 mr-1" />
Clear
Expand Down Expand Up @@ -836,7 +836,7 @@ export default function LeaderboardView({
<Button
variant="outline"
onClick={clearFilters}
className="border-[#50B78B]/30 hover:bg-[#50B78B]/20 hover:text-[#50B78B]"
className="border-[#50B78B]/30 hover:bg-[#50B78B]/20 hover:text-[#50B78B] hover:shadow-[0_0_8px_rgba(80,183,139,0.3)] active:bg-[#50B78B]/30 active:text-[#50B78B] active:border-[#50B78B]/50 active:shadow-[0_0_12px_rgba(80,183,139,0.5)] transition-all duration-200"
>
<X className="h-4 w-4 mr-2" />
Clear Filters
Expand Down
2 changes: 1 addition & 1 deletion components/home-dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ function RepoCard({ repo }: { repo: RepoStats }) {

<div className="flex flex-col items-end gap-1.5 shrink-0">
<div className="flex items-center gap-1 text-xs font-semibold text-zinc-500 dark:text-zinc-400">
<GitFork className="h-3.5 w-3.5 text-[#7C3AED]" />
<GitFork className="h-3.5 w-3.5" />
{repo.forks}
</div>
<div className="flex items-center gap-1 text-xs font-semibold text-zinc-500 dark:text-zinc-400">
Expand Down
33 changes: 32 additions & 1 deletion components/people/ContributorCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,33 @@ const getActivityIcon = (activity: string) => {
return null;
};

const getGitHubSearchUrl = (activityName: string, username: string) => {
if (!username || !/^[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/.test(username)) {
return null;
}

const baseUrl = "https://github.com/search";
const encodedUsername = encodeURIComponent(username);

switch (activityName) {
case "PR merged":
return `${baseUrl}?q=is%3Apr+author%3A${encodedUsername}+is%3Amerged`;
case "PR opened":
return `${baseUrl}?q=is%3Apr+author%3A${encodedUsername}+is%3Aopen`;
case "Issue opened":
return `${baseUrl}?q=is%3Aissue+author%3A${encodedUsername}+is%3Aopen`;
default:
return null;
}
};

const openGitHubSearch = (activityName: string, username: string) => {
const url = getGitHubSearchUrl(activityName, username);
if (url) {
window.open(url, '_blank', 'noopener,noreferrer');
}
};

export function ContributorCard({

contributor,
Expand Down Expand Up @@ -121,7 +148,11 @@ export function ContributorCard({
{topActivities.map(([activity, data]) => (
<div
key={activity}
className="flex items-center gap-1 px-2 py-1 rounded-full bg-muted text-xs"
onClick={(e) => {
e.stopPropagation();
openGitHubSearch(activity, contributor.username);
}}
className="flex items-center gap-1 px-2 py-1 rounded-full bg-muted text-xs cursor-pointer hover:bg-muted/80 transition-colors"
>
{getActivityIcon(activity)}
<span className="font-medium">{data.count}</span>
Expand Down