import type { Meta, StoryObj } from '@storybook/vue3' import icons from '../../../assets/icons' import FdsBlockExpander from './FdsBlockExpander.vue' const blockExpanderTransform = ( _src: string, storyContext: { args?: { heading?: string icon?: string iconClass?: string open?: boolean disabled?: boolean default?: string stickerText?: string stickerColor?: string } }, ) => { const args = storyContext?.args || {} const attrs = [] if (args.heading) attrs.push(`heading="${args.heading}"`) if (args.icon) attrs.push(`icon="${args.icon}"`) if (args.iconClass) attrs.push(`iconClass="${args.iconClass}"`) if (args.open) attrs.push(':open="true"') if (args.disabled) attrs.push(':disabled="true"') if (args.stickerText) attrs.push(`sticker-text="${args.stickerText}"`) if (args.stickerColor) attrs.push(`sticker-color="${args.stickerColor}"`) const attrsStr = attrs.length ? ` ${attrs.join(' ')}` : '' const content = args.default ? `\n

${args.default}

\n` : '' return `${content}` } const meta: Meta = { title: 'FDS/Blocks/FdsBlockExpander', component: FdsBlockExpander, tags: ['autodocs'], parameters: { docs: { source: { transform: blockExpanderTransform, }, }, }, argTypes: { disabled: { control: { type: 'boolean' } }, open: { control: { type: 'boolean' } }, heading: { control: { type: 'text' } }, icon: { control: { type: 'select' }, options: Object.keys(icons) }, iconClass: { control: { type: 'text' } }, default: { control: { type: 'text' } }, stickerText: { control: { type: 'text' } }, stickerColor: { control: { type: 'select' }, options: ['blue', 'green', 'red', 'yellow', 'gray', 't_blue'], }, }, args: { disabled: false, open: false, heading: 'Expandable Content', icon: undefined, iconClass: undefined, default: 'This is the expandable content that shows when the block is opened.', }, } export default meta type Story = StoryObj export const Default: Story = { render: (args: Story['args']) => ({ components: { FdsBlockExpander }, setup: () => ({ args }), template: `

{{ args.default }}

`, }), args: { heading: 'Expandable Content', default: 'This is the expandable content that shows when the block is opened.', }, } export const WithIcon: Story = { render: () => ({ components: { FdsBlockExpander }, template: `

This expander block has an icon in the header.

Click to expand and see more content.

`, }), } export const WithSticker: Story = { render: () => ({ components: { FdsBlockExpander }, template: `

Den här block expandern visar en sticker i headern.

Använd den för att visa status, t.ex. "Ny", "Ändrad" eller "Viktig".

`, }), } export const Open: Story = { render: () => ({ components: { FdsBlockExpander }, template: `

This expander block starts in the open state.

You can still click the header to close it.

`, }), } export const Disabled: Story = { render: () => ({ components: { FdsBlockExpander }, template: `

This expander block is disabled and cannot be interacted with.

`, }), } export const MultipleBlocks: Story = { render: () => ({ components: { FdsBlockExpander }, template: `

Content for the first expander block.

Content for the second expander block.

Content for the third expander block.

`, }), }