Skip to content

Commit

Permalink
Merge pull request #28 from academic-relations/27-setup-storybook
Browse files Browse the repository at this point in the history
Setup storybook
  • Loading branch information
ChaeyeonAhn authored Nov 5, 2024
2 parents c52c13f + 58adb31 commit 345208c
Show file tree
Hide file tree
Showing 9 changed files with 4,489 additions and 158 deletions.
2 changes: 2 additions & 0 deletions packages/web/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts

*storybook.log
22 changes: 22 additions & 0 deletions packages/web/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { StorybookConfig } from "@storybook/nextjs";

const config: StorybookConfig = {
stories: [
"../stories/**/*.stories.@(js|jsx|ts|tsx)",
"../stories/*.stories.@(js|jsx|ts|tsx)",
],
addons: [
"@storybook/addon-onboarding",
"@storybook/addon-links",
"@storybook/addon-essentials",
"@chromatic-com/storybook",
"@storybook/addon-interactions",
"@storybook/addon-themes",
],
framework: {
name: "@storybook/nextjs",
options: {},
},
staticDirs: ["../public"],
};
export default config;
10 changes: 10 additions & 0 deletions packages/web/.storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<link
rel="stylesheet"
href="https://fonts.googleapis.com/icon?family=Material+Icons"
/>

<style>
a {
text-decoration: none;
}
</style>
46 changes: 46 additions & 0 deletions packages/web/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import react from "React";

import type { Preview } from "@storybook/react";

import { ThemeProvider } from "styled-components";
import { withThemeFromJSXProvider } from "@storybook/addon-themes";

import colors from "../src/styles/themes/colors";
import fonts from "../src/styles/themes/fonts";
import responsive from "../src/styles/themes/responsive";
import round from "../src/styles/themes/round";
import shadow from "../src/styles/themes/shadow";
import sizes from "../src/styles/themes/sizes";
import zIndices from "../src/styles/themes/zIndices";

const Theme = {
colors,
fonts,
responsive,
round,
shadow,
sizes,
zIndices,
};

// import fonts from '@sparcs-students/web/common/components/styles/themes.d.ts'
const preview: Preview = {
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
decorators: [
withThemeFromJSXProvider({
themes: {
Theme,
},
Provider: ThemeProvider,
}),
],
};

export default preview;
16 changes: 15 additions & 1 deletion packages/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"lint": "next lint",
"build-start": "next build && next start",
"mock:front": "pnpm dev",
"mock:back": "echo \"In mock:back mode, the 'web' package will not be run. Exiting.\""
"mock:back": "echo \"In mock:back mode, the 'web' package will not be run. Exiting.\"",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
},
"dependencies": {
"@emotion/cache": "11.11.0",
Expand Down Expand Up @@ -37,11 +39,23 @@
"zustand": "^4.5.2"
},
"devDependencies": {
"@chromatic-com/storybook": "^1.9.0",
"@sparcs-students/interface": "workspace:*",
"@storybook/addon-essentials": "^8.3.6",
"@storybook/addon-interactions": "^8.3.6",
"@storybook/addon-links": "^8.3.6",
"@storybook/addon-onboarding": "^8.3.6",
"@storybook/addon-styling-webpack": "^1.0.0",
"@storybook/addon-themes": "^8.3.6",
"@storybook/blocks": "^8.3.6",
"@storybook/nextjs": "^8.3.6",
"@storybook/react": "^8.3.6",
"@storybook/test": "^8.3.6",
"@tanstack/react-query-devtools": "^5.28.4",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"storybook": "^8.3.6",
"typescript": "^5"
},
"packageManager": "pnpm@8.15.8"
Expand Down
33 changes: 33 additions & 0 deletions packages/web/stories/BreadCrumb.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import type { Meta, StoryObj } from "@storybook/react";

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

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

argTypes: {
items: {
control: { type: "object" },
},
},
};

export default meta;

type Story = StoryObj<typeof meta>;

export const example: Story = {
args: {
items: [
{
name: "동아리 목록",
path: "/clubs",
},
],
enableLast: false,
},
};
44 changes: 44 additions & 0 deletions packages/web/stories/Buttons/Button.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import type { Meta, StoryObj } from "@storybook/react";
import React from "react";

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

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

const meta: Meta<typeof Button> = {
title: "components/Buttons/Button",
component: Button,
parameters: {
layout: "centered",
},
argTypes: {
type: {
control: { type: "select", options: ["default", "outlined", "disabled"] },
defaultValue: "default",
},
buttonText: {
control: "text",
},
iconType: {
control: "text",
},
children: {
control: false,
},
},
args: { onClick: fn() },
};

export default meta;

type Story = StoryObj<typeof meta>;

export const example: Story = {
args: {
type: "default",
buttonText: "Button",
children: <Tag color="GREEN">Example Tag Children</Tag>,
iconType: "person",
},
};
30 changes: 30 additions & 0 deletions packages/web/stories/Buttons/TextButton.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import type { Meta, StoryObj } from "@storybook/react";

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

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

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

argTypes: {
text: {
control: "text",
},
},
args: { onClick: fn() },
};

export default meta;

type Story = StoryObj<typeof meta>;

export const example: Story = {
args: {
text: "Button",
},
};
Loading

0 comments on commit 345208c

Please sign in to comment.