import type { Meta, StoryObj } from '@storybook/vue3' import { ref } from 'vue' import FdsTruncatedText from './FdsTruncatedText.vue' const meta: Meta = { title: 'FDS/FdsTruncatedText', component: FdsTruncatedText, tags: ['autodocs'], argTypes: { open: { control: { type: 'boolean' } }, content: { control: { type: 'text' } }, btnExpand: { control: { type: 'text' } }, btnCollapse: { control: { type: 'text' } }, previewLength: { control: { type: 'number' } }, minHiddenChars: { control: { type: 'number' } }, }, args: { open: false, content: `Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.`, btnExpand: 'Visa mer', btnCollapse: 'Visa mindre', previewLength: 150, minHiddenChars: 25, }, } export default meta type Story = StoryObj export const Default: Story = { render: (args: NonNullable) => ({ components: { FdsTruncatedText }, setup: () => { const open = ref(args.open) const handleToggle = (data: { open: boolean }) => { open.value = data.open } return { args: { ...args, open }, handleToggle } }, template: ``, }), } export const WithSlot: Story = { render: (args: NonNullable) => ({ components: { FdsTruncatedText }, setup: () => { const open = ref(args.open) const handleToggle = (data: { open: boolean }) => { open.value = data.open } return { args: { ...args, open }, handleToggle } }, template: ` Additional content that can be collapsed. This is a longer paragraph with more text to demonstrate the truncation functionality. It should be long enough to require the expand/collapse button. `, }), } export const Open: Story = { render: (args: NonNullable) => ({ components: { FdsTruncatedText }, setup: () => { const open = ref(args.open) const handleToggle = (data: { open: boolean }) => { open.value = data.open } return { args: { ...args, open }, handleToggle } }, template: ``, }), args: { open: true, }, }