mock date
npm install storybook-addon-mock-date-parameter- npm run start runs babel in watch mode and starts Storybook
- npm run build build and package your addon code
Don't want to use TypeScript? We offer a handy eject command: npm run eject-ts
This will convert all code to JS. It is a destructive process, so we recommended running this before you start writing any code.
```mdMy Addon
First, install the package.
`sh`
npm install --save-dev my-addon
Then, register it as an addon in .storybook/main.js.
`js
// .storybook/main.ts
// Replace your-framework with the framework you are using (e.g., react-webpack5, vue3-vite)
import type { StorybookConfig } from '@storybook/your-framework';
const config: StorybookConfig = {
// ...rest of config
addons: [
'@storybook/addon-essentials'
'storybook-addon-mock-date-parameter', // 👈 register the addon here
],
};
export default config;
`
The primary way to use this addon is to define the exampleParameter parameter. You can do this the
component level, as below, to affect all stories in the file, or you can do it for a single story.
`js
// Button.stories.ts
// Replace your-framework with the name of your framework
import type { Meta } from '@storybook/your-framework';
import { Button } from './Button';
const meta: Meta
component: Button,
parameters: {
mockingDate: new Date(2002, 1, 1)
}
};
export default meta;
``