import type { Meta, StoryObj } from '@storybook/vue3' import SkipLink from './SkipLink.vue' import { computed } from 'vue' const getMainTargetUrl = (): string => { if (typeof window === 'undefined') { return '#main' } try { const locationFromTop = window.top?.location const locationFromParent = window.parent?.location const loc = locationFromTop ?? locationFromParent ?? window.location return `${loc.origin}${loc.pathname}${loc.search}#main` } catch { return `${window.location.origin}${window.location.pathname}${window.location.search}#main` } } const meta = { title: 'Composants/Navigation/SkipLink', component: SkipLink, argTypes: { default: { control: { type: 'text' }, default: 'Skip to content', }, }, parameters: { layout: 'fullscreen', }, } as Meta export default meta type Story = StoryObj export const Default: Story = { parameters: { sourceCode: [ { name: 'Template', code: ` `, }, { name: 'Script', code: ` `, }, ], }, args: { target: '', }, render: (args) => { return { components: { SkipLink }, setup() { const resolvedTarget = computed(() => { return !args.target || args.target.includes('/iframe.html') ? getMainTargetUrl() : args.target }) return { args, resolvedTarget } }, template: `

Pour afficher le composant, cliquez ici et appuyer sur Tab.

`, } }, } export const WithSlot: Story = { parameters: { sourceCode: [ { name: 'Template', code: ` `, }, { name: 'Script', code: ` `, }, ], }, args: { target: '', default: 'lorem ipsum', }, render: (args) => { return { components: { SkipLink }, setup() { const resolvedTarget = computed(() => { return !args.target || args.target.includes('/iframe.html') ? getMainTargetUrl() : args.target }) return { args, resolvedTarget } }, template: `

Pour afficher le composant, cliquez ici et appuyer sur Tab.

`, } }, }