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

[FEAT] 프로젝트 카드 컴포넌트 추가 #18

Merged
merged 2 commits into from
Aug 9, 2024
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
Binary file added public/images/mock-project-thumbnail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
import { MockProjectData } from "@/components/common/ProjectCard/_mock/mock-project";
import { ProjectCard } from "@/components/common/ProjectCard/ProjectCard";

export default function Home() {
return <main>Hello, world!</main>;
const data = MockProjectData;
return (
<main>
<ProjectCard data={data} />
</main>
);
}
101 changes: 101 additions & 0 deletions src/components/common/ProjectCard/ProjectCard.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
.card {
width: 300px;
height: 410px;
background-color: var(--color-surfaceContainerLowest);
border: 1px solid var(--color-outlineVariant);
border-radius: 12px;
}

.img-section {
padding: 8px;
position: relative;
}

.img {
width: auto;
height: auto;
max-width: 100%;
max-height: 100%;
border-radius: 8px;
}

.img:hover ~ .icon {
transform: scale(1.5);
top: 75%;
left: 85%;
transition: 0.5s;
}

.icon {
color: var(--color-outlineVariant);
position: absolute;
top: 85%;
left: 90%;
transform: translate(-50%, -50%);
}

.badge-group {
height: fit-content;
}

.title {
height: 48px;
max-height: 48px;
font-size: 24px;
line-height: 25px;
font-weight: 700;
color: var(--color-onSurface);
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
word-break: keep-all;
}

@supports (-webkit-line-clamp: 2) {
.title {
white-space: initial;
display: -webkit-box;
line-clamp: 2;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
}

.participants-container {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
height: 24px;
font-size: 14px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

폰트 크기 vw로 해주세요!

font-weight: 500;
line-height: 24px;
color: var(--color-outline);
}

.attr-wrapper {
font-size: 16px;
font-weight: 600;
line-height: 24px;
color: var(--color-onSurface);
}

.value-wrapper {
font-size: 16px;
font-weight: 400;
line-height: 24px;
color: var(--color-onSurface);
}

.like-section {
display: flex;
background-color: var(--color-surfaceVariant);
height: 40px;
align-items: center;
}

.likes-wrapper {
font-size: 16px;
font-weight: 600;
line-height: 24px;
color: var(--color-primary);
}
25 changes: 25 additions & 0 deletions src/components/common/ProjectCard/ProjectCard.story.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { Meta, StoryObj } from "@storybook/react";
import { ProjectCard } from "./ProjectCard";
import { MockProjectData } from "./_mock/mock-project";

const meta = {
title: "ProjectCard",
component: ProjectCard,
parameters: {
layout: "centered",
},
tags: ["autodocs"],
argTypes: {},
args: {},
} satisfies Meta<typeof ProjectCard>;

export default meta;
type Story = StoryObj<typeof meta>;

const data = MockProjectData;

export const Usage: Story = {
args: {
data: data,
},
};
76 changes: 76 additions & 0 deletions src/components/common/ProjectCard/ProjectCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { Card, CardSection, Divider, Group, Stack } from "@mantine/core";
import Image from "next/image";
import classes from "./ProjectCard.module.css";
import { IconSearch } from "@tabler/icons-react";
import Link from "next/link";
import { ProjectCardLikeSection } from "./ProjectCardLikeSection";

export type ProjectCardDataType = {
id: number;
title: string;
thumbnailUrl: string; // uuid 예정
categories: string[];
participants: string[];
team: string;
advisor: string;
likes: number;
isMarked: boolean;
};

export interface ProjectCardProps {
data: ProjectCardDataType;
width?: string;
height?: string;
}

export function ProjectCard({ data, width, height }: ProjectCardProps) {
const ParticipantsString = data.participants.join(", ");
return (
<Card className={classes.card} w={width} h={height}>
<CardSection className={classes["img-section"]}>
<Link
href={{
pathname: `/${data.id}`,
}}
style={{ textDecorationLine: "none" }}
>
<Image
src={data.thumbnailUrl}
alt={"thumbnail"}
className={classes.img}
width={500}
height={500}
priority
/>
<IconSearch className={classes.icon} />
</Link>
</CardSection>
<CardSection pl={24} pt={8}>
<Group className={classes["badge-group"]} gap={16}>
{/* TODO: div를 카드뱃지 컴포넌트로 수정 */}
{data.categories.map((category, index) => (
<div key={index}>{category}</div>
))}
</Group>
</CardSection>
<CardSection pl={24} pr={24} pb={16} pt={8}>
<Stack gap={8}>
<div className={classes.title}>{data.title}</div>
<div className={classes["participants-container"]}>{ParticipantsString}</div>
<Divider c={"var(--color-outline)"} />
</Stack>
<Stack gap={0} mt={8}>
<Group gap={24}>
<div className={classes["attr-wrapper"]}>참가팀명</div>
<div className={classes["value-wrapper"]}>{data.team}</div>
</Group>
<Group gap={24}>
<div className={classes["attr-wrapper"]}>지도교수</div>
<div className={classes["value-wrapper"]}>{data.advisor}</div>
</Group>
</Stack>
</CardSection>
<ProjectCardLikeSection likes={data.likes} isMarked={data.isMarked} />
</Card>
);
}
30 changes: 30 additions & 0 deletions src/components/common/ProjectCard/ProjectCardLikeSection.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { CardSection, Group, UnstyledButton } from "@mantine/core";
import { IconBookmark, IconBookmarkFilled, IconThumbUp } from "@tabler/icons-react";
import classes from "./ProjectCard.module.css";

export interface ProjectCardLikeSectionProps {
likes: number;
isMarked: boolean;
}

export function ProjectCardLikeSection({ likes, isMarked }: ProjectCardLikeSectionProps) {
return (
<CardSection className={classes["like-section"]}>
<Group align="center" justify="space-between" w={500} p={16}>
<UnstyledButton>
<Group gap={0}>
<IconThumbUp color="var(--color-primary)" />
<div className={classes["likes-wrapper"]}>{likes}</div>
</Group>
</UnstyledButton>
<UnstyledButton>
{isMarked ? (
<IconBookmarkFilled color="var(--color-primary)" />
) : (
<IconBookmark color="var(--color-primary)" />
)}
</UnstyledButton>
</Group>
</CardSection>
);
}
13 changes: 13 additions & 0 deletions src/components/common/ProjectCard/_mock/mock-project.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ProjectCardDataType } from "../ProjectCard";

export const MockProjectData: ProjectCardDataType = {
id: 1,
title: "GPT 기반의 일상 대화형 챗봇 모델 개발",
thumbnailUrl: "/images/mock-project-thumbnail.png",
categories: ["AI", "자연어처리"],
participants: ["조민규", "조하빈", "장준우", "김예윤", "신준서"],
team: "바이브컴퍼니",
advisor: "박희선",
likes: 63,
isMarked: true,
};
1 change: 1 addition & 0 deletions src/components/common/ProjectCard/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { ProjectCard } from "./ProjectCard";
Loading
Loading