Type-Scaf is a development tool designed to help you quickly generate form components and Storybook stories based on JavaScript classes. It aims to simplify building consistent UI components in your React projects, using a types-driven approach for automation.
Note: You do not need to set up a new Vite project to use Type-Scaf. It integrates seamlessly into any existing React project.
Automated Component Generation: Transform your JavaScript types into form components, saving time on boilerplate.
Storybook Integration: Quickly visualize and interact with your components in Storybook.
You can add Type-Scaf to any existing React project. If you need to start fresh, you can create a new project with Vite.
npm create vite@latest
Note: Type-Scaf currently only supports JavaScript, so avoid using TypeScript during setup.
Storybook is used to view and test the components generated by Type-Scaf.
npx storybook init
If you are just starting or want a clean working state, you can initialize a Git repository and commit your changes:
git init
git add .
git commit -m "Ground zero"
To initialize Type-Scaf in your project, run:
npx github:leewinter/type-scaf init
This command will add the necessary dependencies and scripts to your project.
After initialization, you should see a type-scaf/config
folder and a package-types.ts
file created in the root of your project. The package-types.ts
file contains example classes that you can modify to suit your needs.
You should also have a type-scaf/templates
folder with ejs templates used for generating the components and stories. The init command won't replace these files unless deleted so feel free to modify as required.
Run the following command to generate components using the example types:
npm run scaf-transform
This will generate React components and Storybook stories in your src
directory.
npm run storybook
You should now be able to see and interact with the generated components in Storybook.
If you encounter any issues or have suggestions for improvement, please feel free to open an issue or a pull request. Contributions are always welcome!