-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: story docs 자동화 추가 * docs: 스토리북 문서 자잘한 수정 * chore: button 타입 style로 네이밍 변경 * chore: codegen 시 validation 추가 * chore: 불필요한 부분 삭제 * docs: eslint 규칙 따르도록 double quote로 변경
- Loading branch information
1 parent
954f409
commit 944cf6e
Showing
10 changed files
with
667 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "codegen", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"type": "module", | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"plop": "^4.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { promises as fs } from "fs"; | ||
import { exit } from "process"; | ||
|
||
export default async function async(plop) { | ||
const COMPONENT_DIR = "../wow-ui/src/components"; | ||
const files = await fs.readdir(COMPONENT_DIR); | ||
|
||
plop.setGenerator("Story", { | ||
description: "Create a story file", | ||
prompts: [ | ||
{ | ||
type: "input", | ||
name: "name", | ||
message: "스토리를 작성할 컴포넌트 이름을 입력해주세요", | ||
validate: (input) => { | ||
if (!files.includes(input)) { | ||
console.log("\n만들어진 컴포넌트 이름을 입력해주세요."); | ||
exit(1); | ||
} | ||
|
||
return true; | ||
}, | ||
}, | ||
], | ||
actions: [ | ||
{ | ||
type: "add", | ||
path: "../wow-ui/src/components/{{pascalCase name}}/{{pascalCase name}}.stories.tsx", | ||
templateFile: "templates/Story.tsx.hbs", | ||
}, | ||
], | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import {{pascalCase name}} from "@/components/{{pascalCase name}}"; | ||
|
||
const meta = { | ||
title: "UI/{{pascalCase name}}", | ||
component: {{pascalCase name}}, | ||
tags: ["autodocs"], | ||
parameters: { | ||
// 컴포넌트 부제목 작성 ex. 버튼 컴포넌트 | ||
componentSubtitle: "", | ||
// 색 대조 관련 웹 접근성 테스트 불가하게 하는 속성 | ||
// 필요 없으면 지우기 | ||
//a11y: { | ||
// config: { | ||
// rules: [{ id: "color-contrast", enabled: false }], | ||
// }, | ||
//}, | ||
}, | ||
argTypes: { | ||
props1: { | ||
description: "props1은 default 값이 있는 필수적인 속성입니다."", | ||
table: { | ||
// type, 필수가 아닐 경우 required 삭제 | ||
type: { summary: "string", required: true }, | ||
// defaultValue (Optional) | ||
defaultValue: { summary: "기본 값" }, | ||
}, | ||
control: { | ||
// Args Table에서 사용자가 조작할 수 있는 타입 | ||
// select일 경우 options를 배열로 제공 | ||
// 그 외 text, number, boolean, color, check, radio 등 존재 | ||
// control 불가능하게 하고 싶을 경우 객체가 아니라 false로 설정 | ||
// ex. control: false, | ||
// 참고 : https://storybook.js.org/docs/react/essentials/controls | ||
type: "select", | ||
options: ["option1", "option2"], | ||
}, | ||
}, | ||
}, | ||
// decorators (Optional) | ||
// 공통적으로 적용하고 싶은 컴포넌트 설정 | ||
decorators: [ | ||
(Story) => ( | ||
<> | ||
{Story()} | ||
</> | ||
), | ||
], | ||
} satisfies Meta<typeof {{pascalCase name}}>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Primary: Story = { | ||
args: {}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.