{
//..
"scripts": {
//..
"gen": "gencb"
//..
}
//..
}
npm run gen <Component Name>
Make boilerplate.config.json
in your root directory.
{
"baseDir": "/src/components", // Output directory
"ext": "ts" // js | ts
}
You only need to prepare a component name for files. If you named some component 'Text', you can get below files in Text folder:
Text
├── index.ts
├── Text.tsx
├── Text.test.tsx
├── Text.stories.tsx
export * from './Text'
export interface TextProps {}
export default function Text({}: TextProps) {
return <div></div>
}
import { render } from '@testing-library/react'
import Text, { TextProps } from './Text'
const renderText = (props?: TextProps) => {
return render(<Text {...props}></Text>)
}
describe('<Text/>', () => {
test('Renders correctly', () => {})
})
import { Meta, StoryObj } from '@storybook/react'
import Text from './Text'
const meta: Meta<typeof Text> = {
title: 'Components/Text',
component: Text,
tags: ['autodocs'],
}
export default meta
type Story = StoryObj<typeof Text>
/**
* Text
*/
export const TextDefault: Story = {
name: 'Text',
}