docs/_snippets/component-story-static-asset-with-import.md
import type { Meta, StoryObj } from '@storybook/angular';
import { MyComponent } from './my-component.component';
import imageFile from './static/image.png';
const meta: Meta<MyComponent> = {
component: MyComponent,
};
export default meta;
type Story = StoryObj<MyComponent>;
const image = {
src: imageFile,
alt: 'my image',
};
export const WithAnImage: Story = {
render: () => ({
props: {
src: image.src,
alt: image.alt,
},
template: ``,
}),
};
import preview from '../.storybook/preview';
import { MyComponent } from './my-component.component';
import imageFile from './static/image.png';
const meta = preview.meta({
component: MyComponent,
});
const image = {
src: imageFile,
alt: 'my image',
};
export const WithAnImage = meta.story({
render: () => ({
props: {
src: image.src,
alt: image.alt,
},
template: ``,
}),
});
import { MyComponent } from './MyComponent';
import imageFile from './static/image.png';
export default {
component: MyComponent,
};
const image = {
src: imageFile,
alt: 'my image',
};
export const WithAnImage = {
render: () => ,
};
// Replace your-framework with the framework you are using, e.g. react-vite, nextjs, nextjs-vite, etc.
import type { Meta, StoryObj } from '@storybook/your-framework';
import imageFile from './static/image.png';
import { MyComponent } from './MyComponent';
const meta = {
component: MyComponent,
} satisfies Meta<typeof MyComponent>;
export default meta;
type Story = StoryObj<typeof meta>;
const image = {
src: imageFile,
alt: 'my image',
};
export const WithAnImage: Story = {
render: () => ,
};
import imageFile from './static/image.png';
import { MyComponent } from './MyComponent';
export default {
component: MyComponent,
};
const image = {
src: imageFile,
alt: 'my image',
};
export const WithAnImage = {
render: () => ,
};
import type { Meta, StoryObj } from 'storybook-solidjs-vite';
import imageFile from './static/image.png';
import { MyComponent } from './MyComponent';
const meta = {
component: MyComponent,
} satisfies Meta<typeof MyComponent>;
export default meta;
type Story = StoryObj<typeof meta>;
const image = {
src: imageFile,
alt: 'my image',
};
export const WithAnImage: Story = {
render: () => ,
};
<script module>
import { defineMeta } from '@storybook/addon-svelte-csf';
import MyComponent from './MyComponent.svelte';
import imageFile from './static/image.png';
let image = {
src: imageFile,
alt: 'my image',
};
const { Story } = defineMeta({
component: MyComponent,
});
</script>
<Story name="WithAnImage">
<MyComponent {image} />
</Story>
import MyComponent from './MyComponent.svelte';
import imageFile from './static/image.png';
export default {
component: MyComponent,
};
const image = {
src: imageFile,
alt: 'my image',
};
export const WithAnImage = {
render: () => ({
Component: MyComponent,
props: image,
}),
};
<script module>
import { defineMeta } from '@storybook/addon-svelte-csf';
import MyComponent from './MyComponent.svelte';
import imageFile from './static/image.png';
let image = {
src: imageFile,
alt: 'my image',
};
const { Story } = defineMeta({
component: MyComponent,
});
</script>
<Story name="WithAnImage">
<MyComponent {image} />
</Story>
// Replace your-framework with svelte-vite or sveltekit
import type { Meta, StoryObj } from '@storybook/your-framework';
import MyComponent from './MyComponent.svelte';
import imageFile from './static/image.png';
const meta = {
component: MyComponent,
} satisfies Meta<typeof MyComponent>;
export default meta;
type Story = StoryObj<typeof meta>;
const image = {
src: imageFile,
alt: 'my image',
};
export const WithAnImage: Story = {
render: () => ({
Component: MyComponent,
props: image,
}),
};
import MyComponent from './MyComponent.vue';
import imageFile from './static/image.png';
export default {
component: MyComponent,
};
const image = {
src: imageFile,
alt: 'my image',
};
export const WithAnImage = {
render: () => ({
setup() {
//๐ Returns the content of the image object created above.
return { image };
},
template: ``,
}),
};
import type { Meta, StoryObj } from '@storybook/vue3-vite';
import MyComponent from './MyComponent.vue';
import imageFile from './static/image.png';
const meta = {
component: MyComponent,
} satisfies Meta<typeof MyComponent>;
const image = {
src: imageFile,
alt: 'my image',
};
export default meta;
type Story = StoryObj<typeof meta>;
export const WithAnImage: Story = {
render: () => ({
setup() {
//๐ Returns the content of the image object created above.
return { image };
},
template: ``,
}),
};
import preview from '../.storybook/preview';
import MyComponent from './MyComponent.vue';
import imageFile from './static/image.png';
const meta = preview.meta({
component: MyComponent,
});
const image = {
src: imageFile,
alt: 'my image',
};
export const WithAnImage = meta.story({
render: () => ({
setup() {
//๐ Returns the content of the image object created above.
return { image };
},
template: ``,
}),
});
import preview from '../.storybook/preview';
import MyComponent from './MyComponent.vue';
import imageFile from './static/image.png';
const meta = preview.meta({
component: MyComponent,
});
const image = {
src: imageFile,
alt: 'my image',
};
export const WithAnImage = meta.story({
render: () => ({
setup() {
//๐ Returns the content of the image object created above.
return { image };
},
template: ``,
}),
});
import { html } from 'lit';
import imageFile from './static/image.png';
export default {
component: 'my-component',
};
const image = {
src: imageFile,
alt: 'my image',
};
export const WithAnImage = {
render: () => html` `,
};
import type { Meta, StoryObj } from '@storybook/web-components-vite';
import { html } from 'lit';
import imageFile from './static/image.png';
const meta: Meta = {
component: 'my-component',
};
const image = {
src: imageFile,
alt: 'my image',
};
export default meta;
type Story = StoryObj;
export const WithAnImage: Story = {
render: () => html``,
};
import { html } from 'lit';
import preview from '../.storybook/preview';
import imageFile from './static/image.png';
const meta = preview.meta({
component: 'my-component',
});
const image = {
src: imageFile,
alt: 'my image',
};
export const WithAnImage = meta.story({
render: () => html` `,
});
import { html } from 'lit';
import preview from '../.storybook/preview';
import imageFile from './static/image.png';
const meta = preview.meta({
component: 'my-component',
});
const image = {
src: imageFile,
alt: 'my image',
};
export const WithAnImage = meta.story({
render: () => html``,
});
import preview from '../.storybook/preview';
import imageFile from './static/image.png';
import { MyComponent } from './MyComponent';
const meta = preview.meta({
component: MyComponent,
});
const image = {
src: imageFile,
alt: 'my image',
};
export const WithAnImage = meta.story({
render: () => ,
});
import preview from '../.storybook/preview';
import { MyComponent } from './MyComponent';
import imageFile from './static/image.png';
const meta = preview.meta({
component: MyComponent,
});
const image = {
src: imageFile,
alt: 'my image',
};
export const WithAnImage = meta.story({
render: () => ,
});