storybook/docs/snippets/react/component-story-static-asset-with-import.ts-4-9.mdx
Kasper Peulen 7452663a26 Prettyyy
2023-01-17 08:10:49 +01:00

35 lines
866 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 = {
/* 👇 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',
} satisfies Meta<typeof MyComponent>;
export default meta;
type Story = StoryObj<typeof meta>;
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} />,
};
```