### Install auto-story-generator package Source: https://github.com/takuma-ru/auto-story-generator/blob/main/docs/introduction/getting-started.md Installs the auto-story-generator as a development dependency using various package managers. Choose the command corresponding to your project's package manager. ```npm npm i -D @takuma-ru/auto-story-generator ``` ```yarn yarn add -D @takuma-ru/auto-story-generator ``` ```pnpm pnpm add -D @takuma-ru/auto-story-generator ``` -------------------------------- ### Install auto-story-generator package Source: https://github.com/takuma-ru/auto-story-generator/blob/main/packages/auto-story-generator/README.md The installation command for adding the auto-story-generator dependency to your project using npm. ```bash npm i @takuma-ru/auto-story-generator ``` -------------------------------- ### Configure auto-story-generator in Storybook main config Source: https://github.com/takuma-ru/auto-story-generator/blob/main/docs/introduction/getting-started.md Integrates the plugin into the Storybook configuration file. Supports both Vite and Webpack environments by adding the plugin to the respective final configuration hooks. ```Vite import type { StorybookConfig } from "@storybook/react-vite"; import { mergeConfig } from "vite"; import autoStoryGenerator from "@takuma-ru/auto-story-generator"; const config: StorybookConfig = { /* ... */ viteFinal: (config) => mergeConfig(config, { plugins: [ autoStoryGenerator.vite({ preset: "react", imports: ["src/components/**/*.tsx"], }), ], }), }; export default config; ``` ```Webpack import type { StorybookConfig } from "@storybook/react/types"; import autoStoryGenerator from "@takuma-ru/auto-story-generator"; const config: StorybookConfig = { /* ... */ webpackFinal: (config) => { config.plugins.push( autoStoryGenerator.webpack({ preset: "react", imports: ["src/components/**/*.tsx"], }) ); return config; }, }; export default config; ``` -------------------------------- ### Example React Component and Storybook Story Source: https://github.com/takuma-ru/auto-story-generator/blob/main/docs/useCase/react.md This example shows a React component 'XXXX' with its props defined using an interface, and its corresponding Storybook story file. The story configuration includes title, component reference, tags, default arguments, and argument types. ```tsx import { FC } from "react"; interface XXXXProps { propA: string; propB?: boolean; } export const XXXX: FC = ({ propA, propB = false, }) => { return (

{propA}

{ propB ?

propB is true

:

propB is false

}
); }; ``` ```tsx import type { Meta, StoryObj } from "@storybook/react"; import { XXXX } from "./XXXX.tsx"; const meta: Meta = { title: "components/XXXX", component: XXXX, tags: ["autodocs"], args: { propA: undefined, propB: undefined }, argTypes: { propA: { control: "text" }, propB: { control: "boolean" } }, }; export default meta; type Story = StoryObj; export const Primary: Story = {}; ``` -------------------------------- ### Configure Auto Story Generator for Lit (Vite) Source: https://github.com/takuma-ru/auto-story-generator/blob/main/docs/useCase/lit.md Sets up the auto-story-generator for Lit components using the Vite preset. This configuration should be placed in your `.storybook/main.ts` or `.storybook/main.js` file. It specifies the preset as 'lit' and points to the component files to be imported. ```typescript autoStoryGenerator.vite({ preset: "lit", imports: ["src/components/**/*.ce.ts"], }) ``` -------------------------------- ### Configure Auto Story Generator for Lit (Webpack) Source: https://github.com/takuma-ru/auto-story-generator/blob/main/docs/useCase/lit.md Configures the auto-story-generator for Lit components using the Webpack preset. This setup is intended for `.storybook/main.ts` or `.storybook/main.js` files. It defines the preset as 'lit' and lists the component files to be imported. ```typescript autoStoryGenerator.webpack({ preset: "lit", imports: ["src/components/**/*.ce.ts"], }) ``` -------------------------------- ### Configure auto-story-generator in Storybook Source: https://github.com/takuma-ru/auto-story-generator/blob/main/packages/auto-story-generator/README.md Integrates the generator into the Storybook configuration file. This example demonstrates usage with React and Vite, specifying the preset and the file path patterns for component discovery. ```typescript import type { StorybookConfig } from "@storybook/react-vite"; import autoStoryGenerator from "@takuma-ru/auto-story-generator"; import { mergeConfig } from "vite"; const config: StorybookConfig = { viteFinal: async config => mergeConfig(config, { plugins: [ autoStoryGenerator.vite({ preset: "react", imports: ["src/components/**/*.tsx"], }), ], }), }; export default config; ``` -------------------------------- ### Configure ESLint for Type-Aware Linting in React/TypeScript Source: https://github.com/takuma-ru/auto-story-generator/blob/main/playgrounds/react/README.md This configuration snippet demonstrates how to set up ESLint for type-aware linting in a React and TypeScript project. It requires specifying TypeScript project files and enables recommended type-checked rules from the @typescript-eslint plugin. Ensure `tsconfig.json` and `tsconfig.node.json` are correctly configured. ```javascript export default { // other rules... parserOptions: { ecmaVersion: 'latest', sourceType: 'module', project: ['./tsconfig.json', './tsconfig.node.json'], tsconfigRootDir: __dirname, }, } ``` -------------------------------- ### Configure Vite for React with Auto Story Generator Source: https://github.com/takuma-ru/auto-story-generator/blob/main/README.md Configures Vite to use the auto-story-generator plugin for React projects. This setup allows for automatic generation of story files from component files. ```typescript import type { StorybookConfig } from "@storybook/react-vite"; import { mergeConfig } from "vite"; import autoStoryGenerator from "@takuma-ru/auto-story-generator"; const config: StorybookConfig = { viteFinal: async (config) => mergeConfig(config, { plugins: [ autoStoryGenerator.vite({ preset: "react", imports: ["src/components/**/*.tsx"], }), ], }), }; export default config; ``` -------------------------------- ### ESLint Base Configuration with Vue Support (JavaScript) Source: https://github.com/takuma-ru/auto-story-generator/blob/main/config/eslint/README.md This JavaScript code defines the base ESLint configuration. It imports a main configuration object from './main.mjs' and exports a function that applies Vue.js specific settings to this main configuration. This setup is useful for projects that utilize Vue.js and require specific linting rules. ```javascript import mainConfig from './main.mjs' function config() { return mainConfig({ vue: true, }) } export default config ``` -------------------------------- ### React Component Prop Definitions for Story Generation Source: https://github.com/takuma-ru/auto-story-generator/blob/main/docs/useCase/react.md Examples of supported prop definition styles within React components required by Auto Story Generator. This includes defining props using interfaces, types, or directly within component arguments. ```tsx // {ComponentName}Props Interface interface ComponentNameProps { propA: string; } // {ComponentName}Props Type type ComponentNameProps = { propA: string; } // Props Interface interface Props { propA: string; } // Props Type type Props = { propA: string; } // Defined within component arguments const ComponentName = ({ propA }: {propA: string}) => { return
{propA}
} ``` -------------------------------- ### Configure Preset for Auto Story Generator Source: https://github.com/takuma-ru/auto-story-generator/blob/main/docs/introduction/options.md Specify the UI framework preset for story generation. Supported presets include 'react', 'vue', 'lit', 'svelte', and 'custom'. Some presets are marked as 'Work in progress' or 'Not yet implemented', indicating their current support status. ```typescript autoStoryGenerator.vite({ preset: "react", }) ``` -------------------------------- ### Customize meta properties in Storybook stories Source: https://github.com/takuma-ru/auto-story-generator/blob/main/docs/faq.md Demonstrates how to manually define and override meta properties, such as the title, within a Storybook component file. This approach ensures that specific configurations are preserved while allowing the library to manage other parts of the meta object. ```tsx const meta: Meta = { title: "components/Component", // ... }; meta.title = "components/utils/Component"; export default meta; ``` -------------------------------- ### Configure Import Paths for Auto Story Generator Source: https://github.com/takuma-ru/auto-story-generator/blob/main/docs/introduction/options.md Define the directory or directories where the component files for which stories should be generated are located. This option accepts an array of glob patterns. ```typescript autoStoryGenerator.vite({ imports: ["src/components/**/*.tsx"], }) ``` -------------------------------- ### Configure Prettier Path for Auto Story Generator Source: https://github.com/takuma-ru/auto-story-generator/blob/main/docs/introduction/options.md Set the path to the Prettier configuration file. Prettier will be used to format the generated story files, ensuring consistent code style. ```typescript autoStoryGenerator.vite({ prettierConfigPath: resolve(__dirname, "../.prettierrc"), }) ``` -------------------------------- ### Configure Auto Story Generator for React (Vite) Source: https://github.com/takuma-ru/auto-story-generator/blob/main/docs/useCase/react.md This snippet shows how to configure the Auto Story Generator for a React project using Vite. It specifies the preset as 'react' and indicates the path to component files for import. ```typescript autoStoryGenerator.vite({ preset: "react", imports: ["src/components/**/*.tsx"], }) ``` -------------------------------- ### Enable Build-Time Story Generation for Auto Story Generator Source: https://github.com/takuma-ru/auto-story-generator/blob/main/docs/introduction/options.md Control whether story files should be automatically generated for all component files once during the build process (e.g., when running 'dev' or 'build' commands). ```typescript autoStoryGenerator.vite({ isGenerateStoriesFileAtBuild: true, }) ``` -------------------------------- ### Configure Auto Story Generator for React (Webpack) Source: https://github.com/takuma-ru/auto-story-generator/blob/main/docs/useCase/react.md This snippet demonstrates the configuration for Auto Story Generator in a React project utilizing Webpack. It sets the preset to 'react' and lists the directories containing the component files to be imported. ```typescript autoStoryGenerator.webpack({ preset: "react", imports: ["src/components/**/*.tsx"], }) ``` -------------------------------- ### Configure Ignore Paths for Auto Story Generator Source: https://github.com/takuma-ru/auto-story-generator/blob/main/docs/introduction/options.md Specify directories or files that should be excluded from story generation. This is useful for components that should not have stories generated for them. ```typescript autoStoryGenerator.vite({ ignores: ["src/components/IgnoreComponent/IgnoredComponent.tsx"], }) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.