Skip to content

Commit

Permalink
스토리북 및 크로마틱 작업 (#57)
Browse files Browse the repository at this point in the history
* chore: 스토리북 기본 세팅

* chore: 절대 경로 변경

* chore: chromatic 설치

* chore: chromatic ci 세팅

* fix: workflow 오타 수정

* chore: push 마다 배포하도록 변경

* chore: turbosnap 로직 제거
  • Loading branch information
hyoribogo authored Dec 29, 2023
1 parent a68242a commit 8acf5e3
Show file tree
Hide file tree
Showing 9 changed files with 14,739 additions and 1,849 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"plugin:tailwindcss/recommended",
"plugin:react/recommended",
"prettier",
"plugin:@tanstack/eslint-plugin-query/recommended"
"plugin:@tanstack/eslint-plugin-query/recommended",
"plugin:storybook/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/chromatic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: 'Chromatic'

on:
push:
branches-ignore:
- main

jobs:
chromatic:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install dependencies
run: npm ci

- name: Publish to Chromatic
uses: chromaui/action@latest
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ env:

on:
push:
branches: ["main"]
branches: ['main']

permissions:
contents: read
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,9 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts

# chromatic
build-storybook.log
chromatic.log
chromatic-build-*.xml
chromatic-diagnostics.json
28 changes: 28 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import path from 'path';
import type { StorybookConfig } from '@storybook/nextjs';

const config: StorybookConfig = {
stories: ['../app/**/*.mdx', '../app/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-onboarding',
'@storybook/addon-interactions',
],
framework: {
name: '@storybook/nextjs',
options: {},
},
webpackFinal: async (config) => {
if (config.resolve) {
config.resolve.alias = {
...config.resolve.alias,
'@': path.resolve(__dirname, '../'),
};
}

return config;
},
};

export default config;
19 changes: 19 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { Preview } from '@storybook/react';
import '../app/globals.css';

const preview: Preview = {
parameters: {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
nextjs: {
appDirectory: true,
},
},
};

export default preview;
26 changes: 26 additions & 0 deletions app/Button.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Button from '@/components/common/buttons/button';
import type { Meta, StoryObj } from '@storybook/react';

// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
const meta: Meta<typeof Button> = {
title: 'Components/Button',
component: Button,
parameters: {
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
layout: 'centered',
},
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
tags: ['autodocs'],
// More on argTypes: https://storybook.js.org/docs/api/argtypes
// argTypes: {
// backgroundColor: { control: 'color' },
// },
};

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

// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
export const Primary: Story = {
render: () => <Button>버튼</Button>,
};
Loading

0 comments on commit 8acf5e3

Please sign in to comment.