an easy way to do it
import Alert from './Alert.vue'
export default {
title: 'Molecules/Alert',
component: Alert,
}
const Template = (args, { argTypes }) => ({
components: { Alert },
props: Object.keys(argTypes),
template: `
<Alert v-bind="$props">
<template v-if="${'default' in args}" v-slot>${args.default}</template>
</Alert>
`,
})
export const Simple = Template.bind({})
Simple.storyName = 'Default'
Simple.args = {
icon: 'info',
linkLabel: 'More information',
linkUrl: '/products',
isExternalLink: false,
default:
'<p class="uk-inline-block uk-margin-remove">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.</p>',
}
if you're using named slots would be
import Alert from './Alert.vue'
export default {
title: 'Molecules/Alert',
component: Alert,
}
const Template = (args, { argTypes }) => ({
components: { Alert },
props: Object.keys(argTypes),
template: `
<Alert v-bind="$props">
<template v-if="${'namedSlot' in args}" v-slot>${args.namedSlot}</template>
</Alert>
`,
})
export const Simple = Template.bind({})
Simple.storyName = 'Default'
Simple.args = {
icon: 'info',
linkLabel: 'More information',
linkUrl: '/products',
isExternalLink: false,
namedSlot:
'<p class="uk-inline-block uk-margin-remove">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.</p>',
}
this is what I get in the story preview
(args, { argTypes }) => ({
2 components: { Alert },
3 props: Object.keys(argTypes),
4 template: `
5 <Alert v-bind="$props">
6 <template v-if="${'default' in args}" v-slot>${args.default}</template>
7 </Alert>
8 `,
9})
cheers