import type { Meta, StoryObj } from '@storybook/vue3-vite'; import { toast } from '../../../utils/sonner'; import Button from '../../button/button.vue'; import Sonner from '../sonner.vue'; import 'vue-sonner/style.css'; const meta: Meta = { title: 'Components/Sonner', component: Sonner, }; export default meta; type Story = StoryObj; export const Default: Story = { args: { position: 'top-center', }, render: args => ({ components: { Sonner, Button }, setup() { const showBasicToast = (): void => { toast('Event has been created', { dismissable: false }); }; const showToastWithDescription = (): void => { toast('Event has been created', { description: 'Monday, January 3rd at 6:00pm', }); }; const showSuccessToast = (): void => { toast.success('Changes saved!', { description: 'Your changes have been saved successfully.', }); }; const showErrorToast = (): void => { toast.error('Something went wrong!', { description: 'Please try again later.', }); }; const showWarningToast = (): void => { toast.warning('Please review!', { description: 'Please review your changes before proceeding.', }); }; const showInfoToast = (): void => { toast.info('Information', { description: 'Here is some helpful information.', }); }; const showFeatureToast = (): void => { toast.feature('New Feature!', { description: 'Check out this amazing new feature.', }); }; const showFillVariant = (): void => { toast.success('Success with fill!', { description: 'This uses the fill variant style.', variant: 'fill', }); }; const showLightVariant = (): void => { toast.info('Info with light variant', { description: 'This uses the light variant style.', variant: 'light', }); }; const showDismissExample = (): void => { const toastId = toast('This toast can be dismissed', { description: 'Click the dismiss button to remove this toast.', duration: Infinity, }); setTimeout(() => { toast.dismiss(toastId); toast.success('Toast dismissed!', { description: 'The previous toast was programmatically dismissed.', }); }, 3000); }; const showCustomSizing = (): void => { toast('Custom sized toast', { description: 'This toast uses a smaller size.', size: 'sm', }); }; return { args, showBasicToast, showToastWithDescription, showSuccessToast, showErrorToast, showWarningToast, showInfoToast, showFeatureToast, showFillVariant, showLightVariant, showDismissExample, showCustomSizing, }; }, template: `

Basic Toasts

Default: success state, stroke variant, large size, dismissable

Helper Functions

Variant Examples

Advanced Features

All toasts are 360px wide when space allows, but shrink responsively on narrow viewports. They appear in the {{ args.position }} position. Default styling: success state, stroke variant, large size, dismissable.

`, }), };