storybook/docs/snippets/react/component-story-static-asset-with-import.ts.mdx
2022-11-17 16:32:02 +01:00

35 lines
864 B
Plaintext

```tsx
// MyComponent.stories.ts|tsx
import imageFile from './static/image.png';
import type { Meta, StoryObj } from '@storybook/react';
import { MyComponent } from './MyComponent';
const meta: Meta<typeof MyComponent> = {
/* 👇 The title prop is optional.
* See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'img',
};
export default meta;
type Story = StoryObj<typeof MyComponent>;
const image = {
src: imageFile,
alt: 'my image',
};
/*
*👇 Render functions are a framework specific feature to allow you control on how the component renders.
* See https://storybook.js.org/docs/7.0/react/api/csf
* to learn how to use render functions.
*/
export const WithAnImage: Story = {
render: () => <img src={image.src} alt={image.alt} />,
};
```