storybook/docs/snippets/web-components/component-story-static-asset-with-import.ts.mdx
2023-01-05 14:53:03 +00:00

32 lines
682 B
Plaintext

```ts
// MyComponent.stories.ts
import { html } from 'lit-html';
import type { Meta, StoryObj } from '@storybook/web-components';
import imageFile from './static/image.png';
const meta: Meta = {
title: 'img',
component: 'my-component',
};
const image = {
src: imageFile,
alt: 'my image',
};
export default meta;
type Story = StoryObj;
/*
*👇 Render functions are a framework specific feature to allow you control on how the component renders.
* See https://storybook.js.org/docs/7.0/web-components/api/csf
* to learn how to use render functions.
*/
export const WithAnImage: Story = {
render: () => html`<img src="${image.src}" alt="${image.alt}" />`,
};
```