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

Create storybook for TextInput, Card, Modal #1245

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion packages/web/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const config: StorybookConfig = {
options: {},
},
docs: {
autodocs: true,
autodocs: true, // CHACHA: 요거 몇 개는 docs에서 꺠지는 컴포넌트가 있어서 (예: Modal) default false로 하는 거 어떤가요?
ChaeyeonAhn marked this conversation as resolved.
Show resolved Hide resolved
},
};
export default config;
1 change: 1 addition & 0 deletions packages/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"@storybook/addon-links": "^8.4.5",
"@storybook/blocks": "^8.4.5",
"@storybook/nextjs": "^8.4.5",
"@storybook/preview-api": "^8.4.6",
"@storybook/react": "^8.4.5",
"@tanstack/react-query-devtools": "^5.28.4",
"@types/node": "^20",
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/common/components/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import isPropValid from "@emotion/is-prop-valid";
import styled from "styled-components";

interface CardProps {
export interface CardProps {
outline?: boolean;
padding?: string;
gap?: number;
Expand Down
31 changes: 31 additions & 0 deletions packages/web/src/stories/Card.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import Card, { CardProps } from "../common/components/Card";

import type { Meta, StoryObj } from "@storybook/react";

const meta: Meta<typeof Card> = {
component: Card,
parameters: {
layout: "centered",
},
};

export default meta;

type Story = StoryObj<typeof Card>;

export const Primary: Story = {
args: {
outline: true,
padding: "8px",
ChaeyeonAhn marked this conversation as resolved.
Show resolved Hide resolved
gap: 20,
},
argTypes: {
outline: { control: "boolean" },
gap: { control: "number" },
},
render: (props: CardProps) => (
<Card {...props}>
<div>SPARCS Clubs</div>
</Card>
),
};
40 changes: 40 additions & 0 deletions packages/web/src/stories/Modal.stories.tsx
Copy link
Contributor

Choose a reason for hiding this comment

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

요거 스토리북 Primary 말고 하나 더 추가되면 좋을 거 같다!
PlayGround..? 이름 뭐라 해야 할지 모르겠는데 버튼 클릭하면 모달 열리고 확인 혹은 취소 누르면 모달 사라지는? 그런 동적인걸 확인 할 수 있게 하나 더 있으면 좋을거 같아!

그리고 CancellableModal 말고 ConfirmModal, ErrorModal, AgreeModal 도 있으면 좋을거 같오

Copy link
Contributor

Choose a reason for hiding this comment

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

시간 되면 예전에 프론트 문서에 요렇게 적었었는데 onClose 관련된 부분도 어디 설명이 되어 있으면 좋을 것 같아
image

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { action } from "@storybook/addon-actions";

import { Meta, StoryObj } from "@storybook/react";

import Modal from "../common/components/Modal";
import CancellableModalContent from "../common/components/Modal/CancellableModalContent";
ChaeyeonAhn marked this conversation as resolved.
Show resolved Hide resolved

const meta: Meta<typeof Modal> = {
component: Modal,
parameters: {
layout: "centered",
docs: {
autodocs: false,
},
},
ChaeyeonAhn marked this conversation as resolved.
Show resolved Hide resolved
};

export default meta;

type Story = StoryObj<typeof Modal>;

export const Primary: Story = {
args: {
isOpen: true,
},
render: function Render(args) {
return (
<Modal {...args}>
<CancellableModalContent
onConfirm={action("onConfirm")}
onClose={action("onClose")}
>
공고를 삭제하면 복구할 수 없습니다.
<br />
ㄱㅊ?
</CancellableModalContent>
</Modal>
);
},
};
54 changes: 54 additions & 0 deletions packages/web/src/stories/TextInput.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { useArgs } from "@storybook/preview-api";

import { Meta, StoryObj } from "@storybook/react";

import TextInput from "../common/components/Forms/TextInput";

const meta: Meta<typeof TextInput> = {
component: TextInput,
parameters: {
layout: "centered",
},
};

export default meta;

type Story = StoryObj<typeof TextInput>;

export const Primary: Story = {
args: {
label: "TextInput",
placeholder: "입력하세요.",
errorMessage: "",
area: false,
disabled: false,
value: "",
},
argTypes: {
ChaeyeonAhn marked this conversation as resolved.
Show resolved Hide resolved
value: { control: "text" },
label: { control: "text" },
placeholder: { control: "text" },
errorMessage: { control: "text" },
area: { control: "boolean" },
disabled: { control: "boolean" },
},
render: function Render(args) {
const [{ value }, updateArgs] = useArgs<{ value: string }>();

const handleChange = (newValue: string) => {
updateArgs({ value: newValue });
};

return (
<TextInput
label={args.label}
placeholder={args.placeholder}
errorMessage={args.errorMessage}
area={args.area}
disabled={args.disabled}
value={value}
handleChange={handleChange}
/>
);
},
};
11 changes: 11 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading