From 79b78df0783b9951c76024fe2abee0009e8a2ddc Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 9 Mar 2026 15:14:51 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20Refactor=20ProfileCard=20to=20us?= =?UTF-8?q?e=20smaller=20internal=20components?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com> --- src/components/ProfileCard.tsx | 283 +++++++++++++++++---------------- 1 file changed, 150 insertions(+), 133 deletions(-) diff --git a/src/components/ProfileCard.tsx b/src/components/ProfileCard.tsx index 4d9d41b..fc379e6 100644 --- a/src/components/ProfileCard.tsx +++ b/src/components/ProfileCard.tsx @@ -4,6 +4,151 @@ type Props = { profile: UserProfile; }; +// Internal components for modularity +const Avatar = ({ url, login }: { url: string; login: string }) => ( +
+
+ {login} +
+); + +const ProfileMeta = ({ profile, joinDate }: { profile: UserProfile; joinDate: string }) => ( +
+ {profile.company && ( + + + {profile.company} + + )} + {profile.location && ( + + + {profile.location} + + )} + {profile.blog && ( + + + {profile.blog.replace(/^https?:\/\//, "")} + + )} + + + Joined {joinDate} + +
+); + +const ProfileStats = ({ profile }: { profile: UserProfile }) => ( +
+
+
+ {profile.followers.toLocaleString()} +
+
Followers
+
+
+
+ {profile.following.toLocaleString()} +
+
Following
+
+
+
+ {profile.public_repos.toLocaleString()} +
+
Repos
+
+
+); + +const Organizations = ({ orgs }: { orgs: UserProfile["orgs"] }) => { + if (orgs.length === 0) return null; + + return ( +
+

Organizations

+
+ {orgs.map((org) => ( + + {org.login} + {org.login} + + ))} +
+
+ ); +}; + +const PinnedRepos = ({ repos }: { repos: UserProfile["pinnedRepos"] }) => { + if (repos.length === 0) return null; + + return ( +
+

Pinned Repositories

+
+ {repos.map((repo) => ( + +
+
+ + {repo.name} + +
+ {repo.description && ( +

+ {repo.description} +

+ )} +
+ +
+ {repo.primaryLanguage && ( + + + {repo.primaryLanguage.name} + + )} + + + {repo.stargazerCount.toLocaleString()} + +
+
+ ))} +
+
+ ); +}; + export default function ProfileCard({ profile }: Props) { const joinDate = new Date(profile.created_at).toLocaleDateString("en-US", { year: "numeric", @@ -13,17 +158,8 @@ export default function ProfileCard({ profile }: Props) { return (
- {/* Avatar */} -
-
- {profile.login} -
+ - {/* Info */}

@@ -36,132 +172,13 @@ export default function ProfileCard({ profile }: Props) {

{profile.bio}

)} - {/* Meta */} -
- {profile.company && ( - - - {profile.company} - - )} - {profile.location && ( - - - {profile.location} - - )} - {profile.blog && ( - - - {profile.blog.replace(/^https?:\/\//, "")} - - )} - - - Joined {joinDate} - -
- - {/* Stats */} -
-
-
- {profile.followers.toLocaleString()} -
-
Followers
-
-
-
- {profile.following.toLocaleString()} -
-
Following
-
-
-
- {profile.public_repos.toLocaleString()} -
-
Repos
-
-
+ +

- {/* Organizations */} - {profile.orgs.length > 0 && ( -
-

Organizations

-
- {profile.orgs.map((org) => ( - - {org.login} - {org.login} - - ))} -
-
- )} - - {/* Pinned Repos */} - {profile.pinnedRepos.length > 0 && ( -
-

Pinned Repositories

-
- {profile.pinnedRepos.map((repo) => ( - -
-
- - {repo.name} - -
- {repo.description && ( -

- {repo.description} -

- )} -
- -
- {repo.primaryLanguage && ( - - - {repo.primaryLanguage.name} - - )} - - - {repo.stargazerCount.toLocaleString()} - -
-
- ))} -
-
- )} + +
); }