diff --git a/.changeset/eighty-apricots-punch.md b/.changeset/eighty-apricots-punch.md
new file mode 100644
index 0000000..5626d39
--- /dev/null
+++ b/.changeset/eighty-apricots-punch.md
@@ -0,0 +1,5 @@
+---
+"@sipe-team/card": minor
+---
+
+add custom ratio in card component
diff --git a/README.md b/README.md
index 7eb6799..25f8937 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
![](./public/assets/og-image.png)
# Sipe Design System
-[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/sipe-team/3-2_side/blob/main/LICENSE) ![Package Manager](https://img.shields.io/badge/pnpm-9.7.1-orange?logo=pnpm) [![Storybook](https://img.shields.io/badge/Storybook-8.4.7-ff4785?logo=storybook)](https://67417e47644abe8d4e63f82f-ggwavglffa.chromatic.com) ![Tests](https://img.shields.io/badge/Vitest-2.1.4-green?logo=vitest) [![codecov](https://codecov.io/gh/sipe-team/3-2_side/branch/changeset-release%2Fmain/graph/badge.svg?token=1TNLVUFPXC)](https://codecov.io/gh/sipe-team/3-2_side)
+[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/sipe-team/3-2_side/blob/main/LICENSE) ![Package Manager](https://img.shields.io/badge/pnpm-9.7.1-orange?logo=pnpm) [![Storybook](https://img.shields.io/badge/Storybook-8.4.7-ff4785?logo=storybook)](https://67417e47644abe8d4e63f82f-lynsfaiqst.chromatic.com) ![Tests](https://img.shields.io/badge/Vitest-2.1.4-green?logo=vitest) [![codecov](https://codecov.io/gh/sipe-team/3-2_side/branch/changeset-release%2Fmain/graph/badge.svg?token=1TNLVUFPXC)](https://codecov.io/gh/sipe-team/3-2_side)
Sipe Design System is a monorepo-based component library built to modernize and standardize the official Sipe website. Drawing inspiration from our existing design patterns, we're creating a robust, type-safe, and accessible component system that can be used across all Sipe projects.
diff --git a/packages/card/src/Card.stories.tsx b/packages/card/src/Card.stories.tsx
index b6372b7..cafcb08 100644
--- a/packages/card/src/Card.stories.tsx
+++ b/packages/card/src/Card.stories.tsx
@@ -7,6 +7,16 @@ const meta = {
parameters: {
layout: 'centered',
},
+ argTypes: {
+ ratio: {
+ control: 'select',
+ options: ['rectangle', 'square', 'wide', 'portrait', 'auto'],
+ },
+ variant: {
+ control: 'select',
+ options: ['filled', 'outline'],
+ },
+ },
} satisfies Meta;
export default meta;
@@ -15,7 +25,6 @@ type Story = StoryObj;
export const Default: Story = {
args: {
children: Card,
- ratio: 'rectangle',
variant: 'filled',
},
};
diff --git a/packages/card/src/Card.test.tsx b/packages/card/src/Card.test.tsx
index d449892..c847d55 100644
--- a/packages/card/src/Card.test.tsx
+++ b/packages/card/src/Card.test.tsx
@@ -37,6 +37,21 @@ test('ratio에 wide로 넣으면 aspect-ratio는 21/9로 반환한다.', () => {
expect(screen.getByText('Card')).toHaveStyle('aspect-ratio: 21 / 9');
});
+test('ratio에 square로 넣으면 aspect-ratio는 1/1로 반환한다.', () => {
+ render(Card);
+ expect(screen.getByText('Card')).toHaveStyle('aspect-ratio: 1 / 1');
+});
+
+test('ratio에 portrait로 넣으면 aspect-ratio는 3/4로 반환한다.', () => {
+ render(Card);
+ expect(screen.getByText('Card')).toHaveStyle('aspect-ratio: 3 / 4');
+});
+
+test('ratio에 auto로 넣으면 aspect-ratio는 auto로 반환한다.', () => {
+ render(Card);
+ expect(screen.getByText('Card')).toHaveStyle('aspect-ratio: auto');
+});
+
test('variant는 default로 filled를 적용한다.', () => {
render(Card);
expect(screen.getByText('Card')).toHaveStyle({
@@ -50,3 +65,17 @@ test(`variant가 outline으로 넣으면 border(${color.cyan300}) 색상을 적
border: `1px solid ${color.cyan300}`,
});
});
+
+test(`variant가 filled일 때 배경색이 ${color.gray100}이다.`, () => {
+ render(Card);
+ expect(screen.getByText('Card')).toHaveStyle({
+ backgroundColor: color.gray100,
+ });
+});
+
+test(`variant가 outline일 때 배경색이 ${color.gray50}이다.`, () => {
+ render(Card);
+ expect(screen.getByText('Card')).toHaveStyle({
+ backgroundColor: color.gray50,
+ });
+});
diff --git a/packages/card/src/Card.tsx b/packages/card/src/Card.tsx
index e3166bd..2afebe6 100644
--- a/packages/card/src/Card.tsx
+++ b/packages/card/src/Card.tsx
@@ -9,7 +9,7 @@ import {
} from 'react';
import styles from './Card.module.css';
-export type CardRatio = 'rectangle' | 'square' | 'wide' | 'portrait';
+export type CardRatio = 'rectangle' | 'square' | 'wide' | 'portrait' | 'auto';
export type CardVariant = 'filled' | 'outline';
export interface CardProps extends ComponentProps<'div'> {
@@ -76,6 +76,6 @@ function getAspectRatio(ratio: CardRatio) {
case 'portrait':
return '3 / 4';
default:
- return '16 / 9';
+ return 'auto';
}
}