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] 카드 뱃지 컴포넌트 추가 #12

Merged
merged 1 commit 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
31 changes: 31 additions & 0 deletions src/components/common/CardBadge/CardBadge.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
@font-face {
font-family: "GmarketSans";
font-weight: 700;
font-style: normal;
src: url("https://cdn.jsdelivr.net/gh/webfontworld/gmarket/GmarketSansBold.eot");
src:
url("https://cdn.jsdelivr.net/gh/webfontworld/gmarket/GmarketSansBold.eot?#iefix")
format("embedded-opentype"),
url("https://cdn.jsdelivr.net/gh/webfontworld/gmarket/GmarketSansBold.woff2") format("woff2"),
url("https://cdn.jsdelivr.net/gh/webfontworld/gmarket/GmarketSansBold.woff") format("woff"),
url("https://cdn.jsdelivr.net/gh/webfontworld/gmarket/GmarketSansBold.ttf") format("truetype");
font-display: swap;
}

.element {
Copy link
Contributor

Choose a reason for hiding this comment

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

폰트 사이즈 vw, pretedard 폰트 사용 필요해보입니다.

Copy link
Member Author

Choose a reason for hiding this comment

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

폰트는 지마켓 산스로 의도하신것 같아서 그대로 적용하였씁니당

font-family: "GmarketSans";
font-size: 10px;
color: black;
}

.container {
background-color: var(--color-primaryContainer);
border-radius: 5px;
display: inline-flex;
justify-content: center;
text-align: center;
align-items: center;
height: 20px;
padding-left: 5px;
padding-right: 5px;
}
21 changes: 21 additions & 0 deletions src/components/common/CardBadge/CardBadge.story.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { Meta, StoryObj } from "@storybook/react";
import { CardBadge } from "./CardBadge";

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

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

export const Usage: Story = {
args: {
label: "Badge",
backgroundColor: "var(--color-primaryContainer)",
},
};
11 changes: 11 additions & 0 deletions src/components/common/CardBadge/CardBadge.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { render } from "@testing-library/react";
import "@testing-library/jest-dom";
import { CardBadge } from "./CardBadge";

describe("CardBadge component", () => {
it("applies the color prop to the label text", () => {
const { getByText } = render(<CardBadge label="Badge" color="red" />);
const labelElement = getByText("Badge");
expect(labelElement).toHaveStyle("color: red");
});
});
22 changes: 22 additions & 0 deletions src/components/common/CardBadge/CardBadge.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import classes from "./CardBadge.module.css";

interface CardBadgeProps {
label: string;
width?: string;
height?: string;
backgroundColor?: string;
color?: string;
}

export function CardBadge({ label, width, height, backgroundColor, color }: CardBadgeProps) {
return (
<div
className={classes.container}
style={{ width: width, height: height, backgroundColor: backgroundColor }}
>
<div className={classes.element} style={{ color: color }}>
{label}
</div>
</div>
);
}
1 change: 1 addition & 0 deletions src/components/common/CardBadge/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { CardBadge } from "./CardBadge";
Loading