import type { Meta, StoryObj } from '@storybook/vue3'
import FdsBlockAlert from './FdsBlockAlert.vue'
const blockAlertTransform = (
_src: string,
storyContext: {
args?: {
visible?: boolean
heading?: string
closeable?: boolean
collapsable?: boolean
expanded?: boolean
default?: string
}
},
) => {
const args = storyContext?.args || {}
const attrs = []
if (args.heading) attrs.push(`heading="${args.heading}"`)
if (args.closeable) attrs.push(':closeable="true"')
if (args.collapsable) attrs.push(':collapsable="true"')
if (args.expanded) attrs.push(':expanded="true"')
const attrsStr = attrs.length ? ` ${attrs.join(' ')}` : ''
let content = ''
if (args.default) {
content = `\n
${args.default}
\n`
}
return `${content}`
}
const meta: Meta = {
title: 'FDS/Blocks/FdsBlockAlert',
component: FdsBlockAlert,
tags: ['autodocs'],
parameters: {
docs: {
source: {
transform: blockAlertTransform,
},
},
},
argTypes: {
closeable: { control: { type: 'boolean' } },
collapsable: { control: { type: 'boolean' } },
expanded: { control: { type: 'boolean' } },
heading: { control: { type: 'text' } },
default: { control: { type: 'text' } },
},
args: {
visible: true,
closeable: false,
collapsable: false,
expanded: false,
heading: 'About this component',
default: 'This is an alert block with some important information.',
},
}
export default meta
type Story = StoryObj
export const Default: Story = {
render: (args: Story['args']) => ({
components: { FdsBlockAlert },
setup: () => ({ args }),
template: `{{ args.default }}
`,
}),
args: {
heading: 'About this component',
default: 'This is an alert block with some important information.',
},
}
export const WithHeading: Story = {
render: () => ({
components: { FdsBlockAlert },
template: `
This alert block has a test heading and provides important information to the user.
`,
}),
parameters: {
docs: {
source: {
transform: () => `
This alert block has a test heading and provides important information to the user.
`,
},
},
},
}
export const Collapsable: Story = {
render: () => ({
components: { FdsBlockAlert },
template: `
This alert block can be collapsed and expanded. The content below is only visible when expanded.
Additional details about the alert can be shown here.
`,
}),
parameters: {
docs: {
source: {
transform: () => `
This alert block can be collapsed and expanded. The content below is only visible when expanded.
Additional details about the alert can be shown here.
`,
},
},
},
}