import type { Meta, StoryObj } from '@storybook/vue3-vite' import { ref } from 'vue' import VvDropdown from '@/components/VvDropdown/VvDropdown.vue' import VvDropdownAction from '@/components/VvDropdown/VvDropdownAction.vue' import VvIcon from '@/components/VvIcon/VvIcon.vue' import { argTypes, defaultArgs } from './Dropdown.settings' import { defaultTest } from './Dropdown.test' const meta: Meta = { title: 'Components/Dropdown/Slots', component: VvDropdown, args: defaultArgs, argTypes, } export default meta type Story = StoryObj export const Default: Story = { args: { ...defaultArgs, }, render: args => ({ components: { VvDropdown, VvDropdownAction, VvIcon }, setup() { const expanded = ref(false) return { expanded, args } }, watch: { expanded(newValue) { if (!newValue) { return } setTimeout(() => { this.centerWrapper() }, 300) }, }, methods: { centerWrapper() { document.getElementById('toggle-button')?.scrollIntoView({ inline: 'center', block: 'center', }) }, }, mounted() { this.centerWrapper() }, template: /* html */ `
`, }), play: defaultTest, } export const Before: Story = { ...Default, args: { ...Default.args, before: '
Before
', }, } export const After: Story = { ...Default, args: { ...Default.args, after: '
After
', }, }