Skip to content

Commit

Permalink
Merge branch 'dev' into 34-add-storybook-for-form-components
Browse files Browse the repository at this point in the history
  • Loading branch information
malloc3141 authored Nov 11, 2024
2 parents d477c20 + fd9b6ca commit 30c29de
Show file tree
Hide file tree
Showing 6 changed files with 215 additions and 2 deletions.
55 changes: 55 additions & 0 deletions packages/web/stories/Filter.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import type { Meta, StoryObj } from "@storybook/react";

import { fn } from "@storybook/test";

import { useState } from "@storybook/preview-api";

import Filter from "@sparcs-students/web/common/components/Filter/index";

const meta: Meta<typeof Filter> = {
title: "components/Filter",
component: Filter,
parameters: {
layout: "centered",
},

argTypes: {
itemList: {
control: false,
},
selectedList: {
control: false,
},
setSelectedList: {
control: false,
},
},

args: { setSelectedList: fn() },
};

export default meta;

type Story = StoryObj<typeof meta>;

export const example: Story = {
args: {
itemList: ["개발자", "디자이너", "기획자"],
selectedList: ["개발자", "디자이너", "기획자"],
},
render: function Render(args) {
const [selectedList, setSelectedList] = useState<string[]>([
"개발자",
"디자이너",
"기획자",
]);
return (
<Filter
{...args}
itemList={["개발자", "디자이너", "기획자"]}
selectedList={selectedList}
setSelectedList={setSelectedList}
/>
);
},
};
48 changes: 48 additions & 0 deletions packages/web/stories/FoldableSectionTitle.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import type { Meta, StoryObj } from "@storybook/react";

import { fn } from "@storybook/test";
import { useState } from "@storybook/preview-api";

import FoldableSectionTitle from "@sparcs-students/web/common/components/FoldableSectionTitle";

const meta: Meta<typeof FoldableSectionTitle> = {
title: "components/FoldableSectionTitle",
component: FoldableSectionTitle,
parameters: {
layout: "centered",
},

argTypes: {
title: {
control: { type: "text" },
},
toggle: {
control: false,
},
toggleHandler: {
control: false,
},
},
args: { toggleHandler: fn() },
};

export default meta;

type Story = StoryObj<typeof meta>;

export const example: Story = {
args: {
title: "2024년 가을학기",
toggle: false,
},
render: function Render(args) {
const [toggle, setToggle] = useState<boolean>(false);
return (
<FoldableSectionTitle
{...args}
toggle={toggle}
toggleHandler={() => setToggle(!toggle)}
/>
);
},
};
27 changes: 27 additions & 0 deletions packages/web/stories/Info.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { Meta, StoryObj } from "@storybook/react";

import Info from "@sparcs-students/web/common/components/Info";

const meta: Meta<typeof Info> = {
title: "components/Info",
component: Info,
parameters: {
layout: "centered",
},

argTypes: {
text: {
control: { type: "text" },
},
},
};

export default meta;

type Story = StoryObj<typeof meta>;

export const example: Story = {
args: {
text: "술박스는 술박스입니다.",
},
};
42 changes: 42 additions & 0 deletions packages/web/stories/SearchInput.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import type { Meta, StoryObj } from "@storybook/react";

import { useState } from "@storybook/preview-api";

import SearchInput from "@sparcs-students/web/common/components/SearchInput";

const meta: Meta<typeof SearchInput> = {
title: "components/SearchInput",
component: SearchInput,
parameters: {
layout: "centered",
},

argTypes: {
searchText: {
control: false,
},
handleChange: {
control: false,
},
},
};

export default meta;

type Story = StoryObj<typeof meta>;

export const example: Story = {
args: {
searchText: "술박스",
},
render: function Render(args) {
const [searchText, setSearchText] = useState<string>("");
return (
<SearchInput
{...args}
searchText={searchText}
handleChange={setSearchText}
/>
);
},
};
43 changes: 43 additions & 0 deletions packages/web/stories/Tag.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import type { Meta, StoryObj } from "@storybook/react";

import Tag from "@sparcs-students/web/common/components/Tag";

const meta: Meta<typeof Tag> = {
title: "components/Tag",
component: Tag,
parameters: {
layout: "centered",
},
tags: ["autodocs"], // CHACHA: needed to display description

argTypes: {
children: {
control: false,
},
color: {
control: { type: "select" },
options: [
"GREEN",
"BLUE",
"ORANGE",
"PURPLE",
"PINK",
"YELLOW",
"RED",
"GRAY",
],
description:
"다양한 색을 전달할 수 있으나, 현재 GREEN, RED에 관한 디자인만 설정되어 있습니다.",
},
},
};

export default meta;

type Story = StoryObj<typeof meta>;

export const example: Story = {
args: {
children: <div>Example Tag Children</div>,
},
};
2 changes: 0 additions & 2 deletions pnpm-lock.yaml

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

0 comments on commit 30c29de

Please sign in to comment.