-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
15,032 additions
and
18,983 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 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { {{pascalCase name}} } from '.'; | ||
|
||
const meta = { | ||
title: '{{pascalCase type}}/{{pascalCase subType}}/{{pascalCase name}}', | ||
component: {{pascalCase name}} | ||
} satisfies Meta<typeof {{pascalCase name}}>; | ||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default = {} satisfies Story; |
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,15 @@ | ||
import * as React from 'react'; | ||
|
||
import { cn } from '~/lib/utils'; | ||
|
||
type Props = { | ||
className?: string; | ||
}; | ||
|
||
export function {{pascalCase name}}({ className, ...props }: Props) { | ||
return ( | ||
<div data-testid='{{snakeCase name}}' className={cn('', className)}> | ||
Hello, world! | ||
</div> | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* @param {import('plop').NodePlopAPI} plop - Plop provides the API methods for plop actions | ||
*/ | ||
export default function ( | ||
plop | ||
) { | ||
plop.setGenerator('component', { | ||
description: 'Create a new component according to the Atomic Design methodology', | ||
prompts: [ | ||
{ | ||
type: 'input', | ||
name: 'name', | ||
message: 'What is your component name?' | ||
}, | ||
{ | ||
type: 'list', | ||
name: 'type', | ||
message: 'What is your component type? ', | ||
choices: ['atoms', 'molecules', 'organisms'] | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'subType', | ||
message: `What is your component sub-type? (e.g. 'typography' for atoms, 'cards' for molecules or 'sections' for organisms)`, | ||
}, | ||
{ | ||
type: 'confirm', | ||
name: 'confirmation', | ||
message: (answers) => { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access | ||
const pascalCaseName = answers.name.replace(/(^\w|-\w|\s\w|_\w)/g, (/** @type {string} */ s) => s.toUpperCase()).replace(/[-_\s]+/g, ''); | ||
|
||
return `Are you sure you want to create '~/components/${answers.type}/${answers.subType}/${pascalCaseName}'?`; | ||
}, | ||
} | ||
], | ||
actions: [ | ||
{ | ||
type: 'add', | ||
path: 'src/components/{{type}}/{{subType}}/{{pascalCase name}}/index.stories.tsx', | ||
templateFile: '.plop-templates/component/index.stories.tsx.hbs' | ||
}, | ||
{ | ||
type: 'add', | ||
path: 'src/components/{{type}}/{{subType}}/{{pascalCase name}}/index.tsx', | ||
templateFile: '.plop-templates/component/index.tsx.hbs' | ||
}, | ||
] | ||
}); | ||
} |
Oops, something went wrong.