Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 11 additions & 0 deletions .github/actions/pnpm-setup-node/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: setup pnpm & node
description: setup pnpm & node
runs:
using: composite
steps:
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 22.17.0
cache: 'pnpm'
cache-dependency-path: 'pnpm-lock.yaml'
56 changes: 56 additions & 0 deletions .github/workflows/deploy-chromatic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: 'Deploy Chromatic'

permissions:
contents: write
pull-requests: write

on:
pull_request:
types: [opened, synchronize]
branches:
- main
- develop
- feat/**
paths:
- '**.stories.tsx'
- '**.stories.ts'
- '**.mdx'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
chromatic-deployment:
runs-on: ubuntu-latest
env:
WORKDIR: .

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js and pnpm
uses: ./.github/actions/pnpm-setup-node

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Publish Chromatic
id: chromatic
uses: chromaui/action@latest
with:
workingDir: apps/storybook
buildScriptName: build
autoAcceptChanges: true
onlyChanged: true
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Comment PR with Storybook URL
uses: thollander/actions-comment-pull-request@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
message: '🚀storybook: ${{ steps.chromatic.outputs.storybookUrl }}'
44 changes: 44 additions & 0 deletions apps/storybook/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# env files (can opt-in for committing if needed)
.env*

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

*storybook.log
storybook-static
24 changes: 24 additions & 0 deletions apps/storybook/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { StorybookConfig } from '@storybook/nextjs'

const config: StorybookConfig = {
stories: [
'../stories/**/*.mdx',
'../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)',
// '../../../packages/ui/src/**/*.stories.@(js|jsx|mjs|ts|tsx)',
],
addons: [
'@chromatic-com/storybook',
'@storybook/addon-docs',
'@storybook/addon-a11y',
],
framework: {
name: '@storybook/nextjs',
options: {},
},
staticDirs: [
'../../../packages/ui/public', // UI 컴포넌트용 리소스
'../public', // Storybook 전용 리소스
],
}

export default config
14 changes: 14 additions & 0 deletions apps/storybook/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { Preview } from '@storybook/nextjs'

const preview: Preview = {
parameters: {
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
};

export default preview;
18 changes: 18 additions & 0 deletions apps/storybook/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import storybook from 'eslint-plugin-storybook'
import tseslint from 'typescript-eslint'

export default [
// TypeScript 기본 설정
...tseslint.configs.recommended,

// Storybook 설정
...storybook.configs['flat/recommended'],

// 모든 TypeScript/JavaScript 파일에 적용
{
files: ['**/*.{js,mjs,cjs,ts,mts,cts,tsx}'],
languageOptions: {
parser: tseslint.parser,
},
},
]
40 changes: 40 additions & 0 deletions apps/storybook/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "storybook",
"version": "0.1.0",
"type": "module",
"private": true,
"scripts": {
"dev": "storybook dev -p 6006",
"build": "storybook build"
},
"dependencies": {
"@repo/ui": "workspace:^"
},
"devDependencies": {
"@repo/eslint-config": "workspace:*",
"@repo/tailwind-config": "workspace:*",
"@repo/typescript-config": "workspace:*",
"@chromatic-com/storybook": "^4.1.0",
"@eslint/eslintrc": "^3",
"@storybook/addon-a11y": "^9.1.0",
"@storybook/addon-docs": "^9.1.0",
"@storybook/nextjs": "^9.1.0",
"@tailwindcss/postcss": "^4",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"@typescript-eslint/eslint-plugin": "^8.38.0",
"@typescript-eslint/parser": "^8.38.0",
"chromatic": "^13.1.3",
"eslint": "^9.32.0",
"eslint-config-next": "15.4.5",
"eslint-plugin-react": "^7.37.4",
"eslint-plugin-storybook": "^9.1.0",
"storybook": "^9.1.0",
"tailwindcss": "^4",
"typescript": "^5.8.2",
"typescript-eslint": "^8.37.0"
}
}


5 changes: 5 additions & 0 deletions apps/storybook/postcss.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const config = {
plugins: ["@tailwindcss/postcss"],
};

export default config;
Binary file added apps/storybook/public/favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions apps/storybook/public/file.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions apps/storybook/public/globe.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions apps/storybook/public/next.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions apps/storybook/public/vercel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions apps/storybook/public/window.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions apps/storybook/stories/Button.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import type { Meta, StoryObj } from '@storybook/nextjs';

import { fn } from 'storybook/test';

import { Button } from './Button';

// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
const meta = {
title: 'Example/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' },
},
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
args: { onClick: fn() },
} satisfies Meta<typeof Button>;

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

// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
export const Primary: Story = {
args: {
primary: true,
label: 'Button',
},
};

export const Secondary: Story = {
args: {
label: 'Button',
},
};

export const Large: Story = {
args: {
size: 'large',
label: 'Button',
},
};

export const Small: Story = {
args: {
size: 'small',
label: 'Button',
},
};
39 changes: 39 additions & 0 deletions apps/storybook/stories/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import './button.css';

export interface ButtonProps {
/** Is this the principal call to action on the page? */
primary?: boolean;
/** What background color to use */
backgroundColor?: string;
/** How large should the button be? */
size?: 'small' | 'medium' | 'large';
/** Button contents */
label: string;
/** Optional click handler */
onClick?: () => void;
}

/** Primary UI component for user interaction */
export const Button = ({
primary = false,
size = 'medium',
backgroundColor,
label,
...props
}: ButtonProps) => {
const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
return (
<button
type="button"
className={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
{...props}
>
{label}
<style jsx>{`
button {
background-color: ${backgroundColor};
}
`}</style>
</button>
);
};
Loading