diff --git a/components/atoms/UserCard/user-card.tsx b/components/atoms/UserCard/user-card.tsx new file mode 100644 index 0000000000..73f03b4a8e --- /dev/null +++ b/components/atoms/UserCard/user-card.tsx @@ -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 ( +
+
+
+ {`${username}'s +
+

{name}

+

{`@${username}`}

+
+
+
+ {meta.map(({ name, count }, i) => ( +
+

{name}

+ {count > 0 ? count : "-"} +
+ ))} + {/*
+

Followers

+ {followersCount > 0 ? followersCount : "-"} +
+
+

Following

+ {followingCount > 0 ? followingCount : "-"} +
+
+

Highlights

+ {highlightsCount > 0 ? highlightsCount : "-"} +
*/} +
+
+
+ ); +}; + +export default UserCard; diff --git a/stories/atoms/user-card.stories.tsx b/stories/atoms/user-card.stories.tsx new file mode 100644 index 0000000000..4d83a9030a --- /dev/null +++ b/stories/atoms/user-card.stories.tsx @@ -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; + +export default storyConfig; + +const UserCardTemplate: ComponentStory = (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 }, + ], +};