-
Notifications
You must be signed in to change notification settings - Fork 0
🧹 Refactor BusinessCard component to improve maintainability #492
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import type { UserProfile } from "@/lib/types"; | ||
|
|
||
| export const AvatarBlock = ({ profile }: { profile: UserProfile }) => ( | ||
| <div className="mb-10 flex items-center gap-8"> | ||
| {/* eslint-disable-next-line @next/next/no-img-element */} | ||
| <img | ||
| src={profile.avatar_url} | ||
| alt={profile.login} | ||
| className="h-40 w-40 rounded-full border-4 border-card-border shadow-xl" | ||
| crossOrigin="anonymous" | ||
| /> | ||
| <div className="min-w-0 flex-1"> | ||
| <h1 className="mb-2 break-words text-6xl font-bold tracking-tight text-white"> | ||
| {profile.name || profile.login} | ||
| </h1> | ||
| <div className="break-all text-3xl text-gray-400">@{profile.login}</div> | ||
| </div> | ||
| </div> | ||
| ); | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,64 @@ | ||||||
| import type { UserProfile, CardDisplayOptions } from "@/lib/types"; | ||||||
| import { BuildingIcon, CalendarIcon, LinkIcon, MapPinIcon, TwitterIcon } from "../Icons"; | ||||||
|
|
||||||
| type Props = { | ||||||
| profile: UserProfile; | ||||||
| options?: CardDisplayOptions; | ||||||
| }; | ||||||
|
|
||||||
| export const BioBlock = ({ profile, options }: Props) => { | ||||||
| const { | ||||||
| showCompany = false, | ||||||
| showLocation = false, | ||||||
| showWebsite = false, | ||||||
| showTwitter = false, | ||||||
| showJoinedDate = false, | ||||||
| } = options || {}; | ||||||
|
|
||||||
| return ( | ||||||
| <> | ||||||
| <p className="mb-8 line-clamp-3 max-w-2xl text-2xl leading-relaxed text-gray-300"> | ||||||
| {profile.bio || "No bio available."} | ||||||
| </p> | ||||||
|
|
||||||
| {(showCompany || showLocation || showWebsite || showTwitter || showJoinedDate) && ( | ||||||
| <div className="flex flex-wrap gap-x-8 gap-y-4 text-xl text-gray-400"> | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The metadata row lost the old
Suggested change
Prompt To Fix With AIThis is a comment left during a code review.
Path: src/components/BusinessCardBlocks/BioBlock.tsx
Line: 25
Comment:
**Bio Metadata Spacing Changed**
The metadata row lost the old `mb-10` and changed from `gap-y-3 text-lg text-gray-300` to `gap-y-4 text-xl text-gray-400`. When company, location, website, Twitter, or joined date is enabled, the extracted block renders different spacing, size, and color from the original card.
```suggestion
<div className="mb-10 flex flex-wrap gap-x-8 gap-y-3 text-lg text-gray-300">
```
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||||||
| {showCompany && profile.company && ( | ||||||
| <div className="flex items-center gap-2"> | ||||||
| <BuildingIcon className="text-accent" /> | ||||||
| <span>{profile.company}</span> | ||||||
| </div> | ||||||
| )} | ||||||
| {showLocation && profile.location && ( | ||||||
| <div className="flex items-center gap-2"> | ||||||
| <MapPinIcon className="text-accent" /> | ||||||
| <span>{profile.location}</span> | ||||||
| </div> | ||||||
| )} | ||||||
| {showWebsite && profile.blog && ( | ||||||
| <div className="flex items-center gap-2"> | ||||||
| <LinkIcon className="text-accent" /> | ||||||
| <span className="max-w-[200px] truncate"> | ||||||
| {profile.blog.replace(/^https?:\/\//, "")} | ||||||
| </span> | ||||||
| </div> | ||||||
| )} | ||||||
| {showTwitter && profile.twitter_username && ( | ||||||
| <div className="flex items-center gap-2"> | ||||||
| <TwitterIcon className="text-accent" /> | ||||||
| <span>@{profile.twitter_username}</span> | ||||||
| </div> | ||||||
| )} | ||||||
| {showJoinedDate && ( | ||||||
| <div className="flex items-center gap-2"> | ||||||
| <CalendarIcon className="text-accent" /> | ||||||
| <span> | ||||||
| Joined {new Date(profile.created_at).toLocaleDateString("en-US", { month: "short", year: "numeric" })} | ||||||
| </span> | ||||||
| </div> | ||||||
| )} | ||||||
| </div> | ||||||
| )} | ||||||
| </> | ||||||
| ); | ||||||
| }; | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old inline block used
text-5xlwithleading-tight, but the extracted block renders the name astext-6xlwithout that line-height class. On the 1200×630 card preview/export path, long names or dense layouts can push lower blocks down and produce a different PNG than the pre-refactor card.Prompt To Fix With AI
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!