Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: stats layout and add tooltips #101

Merged
Show file tree
Hide file tree
Changes from all 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
124 changes: 73 additions & 51 deletions src/components/RepositoryContributionsCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Contributions, Repository } from "@/types/github";
import { Contributions, PullRequestNode, Repository } from "@/types/github";
import Image from "next/image";
import Link from "next/link";
import { FaCodeMerge } from "react-icons/fa6";
Expand All @@ -13,58 +13,80 @@ export const RepositoryContributionsCard = ({
contributions: Contributions;
}) => {
return (
<div className="card bg-base-100">
<div className="card-body">
<h2 className="card-title flex justify-between">
<div className="flex justify-center items-center gap-2">
<Image
src={repository.owner.avatarUrl}
alt={repository.owner.login}
width={40}
height={40}
className="rounded-full"
/>
<Link
href={`https://github.com/${repository.owner.login}/${repository.name}`}
rel="noopener noreferrer"
target="_blank"
className="hover:underline"
aria-label={`${repository.name}`}
>
{repository.owner.login}/{repository.name}
</Link>
</div>
<div className="tooltip tooltip-left" data-tip="Total contributions">
<div className="rounded outline outline-1 cursor-default px-2">
{totalCount}
</div>
</div>
</h2>
<div className="max-h-[22rem] hide-scrollbar overflow-auto flex flex-col gap-1">
{nodes?.map(({ pullRequest: { state, title, id, url } }: any) => (
<div key={id} className="flex items-center justify-between gap-2">
<a href={url} target="_blank" className="truncate" title={title}>
{title}
</a>
<span
className={`h-fit rounded p-1 ${
state === "MERGED"
? "bg-purple-500"
: state === "CLOSED"
? "bg-red-500"
: "bg-green-500"
}`}
<div className="card bg-base-100 overflow-visible">
<div className="sm:w-auto card bg-base-100 repository-card">
<div className="card-body">
<div className="card-title flex items-center justify-between">
<div className="flex items-center space-x-2 flex-grow">
<Image
src={repository.owner.avatarUrl}
alt={repository.owner.login}
width={40}
height={40}
className="rounded-full"
/>
<div
className="grid grid-flow-col gap-2 flex-grow tooltip text-left"
data-tip={`${repository.owner.login}/${repository.name}`}
>
{state === "MERGED" ? (
<FaCodeMerge size={18} />
) : state === "CLOSED" ? (
<IoIosCloseCircleOutline size={18} />
) : (
<GoIssueOpened size={18} />
)}
</span>
<Link
href={`https://github.com/${repository.owner.login}/${repository.name}`}
rel="noopener noreferrer"
target="_blank"
className="hover:underline truncate flex-grow"
aria-label={`${repository.name}`}
>
<h3 className="logged-user truncate">
{repository.owner.login}/{repository.name}
</h3>
</Link>
</div>
<div
className="tooltip tooltip-left"
data-tip="Total contributions"
>
<div className="rounded outline outline-1 cursor-default px-2">
{totalCount}
</div>
</div>
</div>
))}
</div>
<div className="max-h-[22rem] hide-scrollbar overflow-auto flex flex-col gap-1">
{nodes?.map(
({ pullRequest: { state, title, id, url } }: PullRequestNode) => (
<div
key={id}
className="flex items-center justify-between gap-2"
>
<a
href={url}
target="_blank"
className="truncate"
title={title}
>
{title}
</a>
<span
className={`h-fit rounded p-1 ${
state === "MERGED"
? "bg-purple-500"
: state === "CLOSED"
? "bg-red-500"
: "bg-green-500"
}`}
>
{state === "MERGED" ? (
<FaCodeMerge size={18} />
) : state === "CLOSED" ? (
<IoIosCloseCircleOutline size={18} />
) : (
<GoIssueOpened size={18} />
)}
</span>
</div>
)
)}
</div>
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/stats/[login].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export default function Stats() {
</li>
</ul>
</div>
<div className="w-full grid xl:grid-cols-3 gap-3 mb-3 md:grid-cols-2">
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 pb-4">
{filteredRepositories?.length > 0
? filteredRepositories?.map(
({ repository, contributions }, i) => (
Expand Down Expand Up @@ -251,7 +251,7 @@ export default function Stats() {
onChange={(e) => setSearchQuery(e.target.value)}
/>
</div>
<div className="flex sm:items-start items-center justify-center sm:justify-start">
<div className="flex sm:items-start items-center justify-center md:justify-start">
<input
type="checkbox"
name="hide-own-repo"
Expand Down
1 change: 1 addition & 0 deletions src/types/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export type PullRequest = {
id: string;
title: string;
state: "MERGED" | "CLOSED" | "OPEN";
url: string;
};

export type Repository = {
Expand Down
Loading