-
-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
UserCard
component to storybook design system (#1295)
- Loading branch information
Showing
2 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { getAvatarByUsername } from "lib/utils/github"; | ||
import Image from "next/image"; | ||
import React from "react"; | ||
|
||
type MetaObj = { | ||
name: "Followers" | "Following" | "Highlights"; | ||
count: number; | ||
}; | ||
interface UserCardProps { | ||
username: string; | ||
meta: MetaObj[]; | ||
name: string; | ||
} | ||
const UserCard = ({ username, name, meta }: UserCardProps) => { | ||
const avatarUrl = getAvatarByUsername(username); | ||
|
||
return ( | ||
<div className="mt-10 bg-white border w-max rounded-2xl border-zinc-200"> | ||
<div className="flex flex-col items-center gap-6 px-6 -translate-y-12 "> | ||
<div className="flex flex-col items-center gap-2"> | ||
<Image | ||
className="border border-white rounded-full" | ||
width={110} | ||
height={110} | ||
src={avatarUrl} | ||
alt={`${username}'s avatar image`} | ||
/> | ||
<div> | ||
<h3 className="text-lg text-center">{name}</h3> | ||
<p className="text-center text-light-slate-9">{`@${username}`}</p> | ||
</div> | ||
</div> | ||
<div className="flex items-center gap-5 text-lg text-center"> | ||
{meta.map(({ name, count }, i) => ( | ||
<div key={i.toLocaleString()}> | ||
<p className="text-center text-light-slate-9">{name}</p> | ||
{count > 0 ? count : "-"} | ||
</div> | ||
))} | ||
{/* <div> | ||
<p className="text-center text-light-slate-9">Followers</p> | ||
{followersCount > 0 ? followersCount : "-"} | ||
</div> | ||
<div> | ||
<p className="text-center text-light-slate-9">Following</p> | ||
{followingCount > 0 ? followingCount : "-"} | ||
</div> | ||
<div> | ||
<p className="text-center text-light-slate-9">Highlights</p> | ||
{highlightsCount > 0 ? highlightsCount : "-"} | ||
</div> */} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default UserCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import UserCard from "components/atoms/UserCard/user-card"; | ||
import { ComponentMeta, ComponentStory } from "@storybook/react"; | ||
|
||
const storyConfig = { | ||
title: "Design System/Atoms/UserCard", | ||
} as ComponentMeta<typeof UserCard>; | ||
|
||
export default storyConfig; | ||
|
||
const UserCardTemplate: ComponentStory<typeof UserCard> = (args) => <UserCard {...args} />; | ||
|
||
export const UserCardStory = UserCardTemplate.bind({}); | ||
|
||
export const NoActivities = UserCardTemplate.bind({}); | ||
|
||
UserCardStory.args = { | ||
username: "foxyblocks", | ||
name: "Chris Schlensker", | ||
meta: [ | ||
{ name: "Followers", count: 3 }, | ||
{ name: "Following", count: 103 }, | ||
{ name: "Highlights", count: 55 }, | ||
], | ||
}; | ||
|
||
NoActivities.args = { | ||
username: "foxyblocks", | ||
name: "Chris Schlensker", | ||
meta: [ | ||
{ name: "Followers", count: 0 }, | ||
{ name: "Following", count: 0 }, | ||
{ name: "Highlights", count: 0 }, | ||
], | ||
}; |