/* eslint-disable no-useless-escape */ import type { Meta, StoryFn } from '@storybook/vue3' import NotificationBar from './NotificationBar.vue' import { VBtn } from 'vuetify/components' import { useNotificationService } from '@/services/NotificationService' import type { Notification } from '@/components/NotificationBar/types' interface StoryArgs { closeBtnText: string type: Notification['type'] bottom: boolean rounded: string | number | boolean showAll: boolean } const meta: Meta = { title: 'Composants/Feedback/NotificationBar', parameters: { layout: 'fullscreen', controls: { exclude: ['currentNotification', 'isNotificationVisible', 'hasActionSlot', 'isMobileVersion', 'hasLongContent', 'color', 'icon', 'contentStyle', 'smallCloseBtn', 'isVertical', 'type'] }, }, component: NotificationBar, argTypes: { closeBtnText: { control: 'text', table: { type: { summary: 'string', }, defaultValue: { summary: 'Fermer', }, }, }, bottom: { control: 'boolean', table: { type: { summary: 'boolean', }, defaultValue: { summary: 'false', }, }, }, rounded: { control: 'select', options: [0, 1, 2, 3, 4, 'xs', 'sm', true, 'lg', 'xl', 'pill', 'circle', 'shaped'], table: { type: { summary: '0, 1, 2, 3, 4, \'xs\', \'sm\', true, \'lg\', \'xl\', \'pill\', \'circle\', \'shaped\'', }, defaultValue: { summary: '4', }, }, }, showAll: { control: 'boolean', description: 'Afficher toutes les notifications au lieu de la dernière uniquement', table: { type: { summary: 'boolean', }, defaultValue: { summary: 'false', }, }, }, }, } export default meta type Story = StoryFn export const Default: Story = (args) => { return { components: { NotificationBar, VBtn }, setup() { const { addNotification } = useNotificationService() const argsType = args.type || 'info' const envoyerNotification = (message: string) => { const notification: Notification = { id: Date.now().toString(), message, type: argsType, timeout: -1, } addNotification(notification) } return { args, argsType, envoyerNotification, } }, template: `
Afficher la notification
`, } } Default.args = { closeBtnText: 'Fermer', rounded: 4, } Default.parameters = { sourceCode: [ { name: 'Template', code: `
Afficher la notification
`, }, { name: 'Script', code: ` `, }, ], } export const Success: Story = Default.bind({}) Success.args = { ...Default.args, type: 'success', } Success.parameters = { sourceCode: [ { name: 'Template', code: `
Afficher la notification
`, }, { name: 'Script', code: ` `, }, ], } export const Warning: Story = Default.bind({}) Warning.args = { ...Default.args, type: 'warning', } Warning.parameters = { sourceCode: [ { name: 'Template', code: `
Afficher la notification
`, }, { name: 'Script', code: ` `, }, ], } export const Error: Story = Default.bind({}) Error.args = { ...Default.args, type: 'error', } Error.parameters = { sourceCode: [ { name: 'Template', code: `
Afficher la notification
`, }, { name: 'Script', code: ` `, }, ], } export const Bottom: Story = Default.bind({}) Bottom.args = { ...Default.args, bottom: true, } Bottom.parameters = { sourceCode: [ { name: 'Template', code: `
Afficher la notification
`, }, { name: 'Script', code: ` `, }, ], } export const CustomCloseBtnText: Story = Default.bind({}) CustomCloseBtnText.args = { ...Default.args, closeBtnText: 'Masquer', } CustomCloseBtnText.parameters = { sourceCode: [ { name: 'Template', code: `
Afficher la notification
`, }, { name: 'Script', code: ` `, }, ], } export const DefaultSlot: Story = (args) => { return { components: { NotificationBar, VBtn }, setup() { const { addNotification } = useNotificationService() const envoyerNotification = () => { const notification: Notification = { id: Date.now().toString(), message: 'Notification avec contenu principal personnalisé.', type: 'info', timeout: -1, } addNotification(notification) } return { args, envoyerNotification } }, template: `
Afficher la notification
`, } } DefaultSlot.args = { ...Default.args, } DefaultSlot.parameters = { sourceCode: [ { name: 'Template', code: ` `, }, { name: 'Script', code: ` `, }, ], } export const ActionSlot: Story = (args) => { return { components: { NotificationBar, VBtn }, setup() { const { addNotification } = useNotificationService() const envoyerNotification = () => { const notification: Notification = { id: Date.now().toString(), message: 'Notification avec contenu personnalisé via slot.', type: 'info', timeout: -1, } addNotification(notification) } return { args, envoyerNotification } }, template: `
Afficher la notification
`, } } ActionSlot.args = { ...Default.args, } ActionSlot.parameters = { sourceCode: [ { name: 'Template', code: ` `, }, { name: 'Script', code: ` `, }, ], } export const Customization: Story = Default.bind({}) Customization.args = { ...Default.args, rounded: 'pill', type: 'success', } Customization.parameters = { sourceCode: [ { name: 'Template', code: `
Afficher la notification
`, }, { name: 'Script', code: ` `, }, ], } export const WithClearQueue: Story = (args) => { return { components: { NotificationBar, VBtn }, setup() { const { addNotification, clearQueue } = useNotificationService() // Fonction pour ajouter une notification avec un type spécifique const envoyerNotification = (message: string, type: Notification['type'] = 'info') => { const notification: Notification = { id: Date.now().toString(), message, type, timeout: -1, } addNotification(notification) } return { args, envoyerNotification, clearQueue, } }, template: `
Ajouter info Ajouter succès Ajouter avertissement Ajouter erreur Fermer toutes les notifications

Ajoutez plusieurs notifications pour tester l'affichage.

`, } } WithClearQueue.args = { ...Default.args, bottom: true, } export const showAll: Story = (args) => { return { components: { NotificationBar, VBtn }, setup() { const { addNotification, clearQueue } = useNotificationService() const envoyerNotification = (message: string, type: Notification['type'] = 'info') => { const notification: Notification = { id: Date.now().toString(), message, type: type, timeout: -1, } addNotification(notification) } return { args, envoyerNotification, clearQueue, } }, template: `
Ajouter info Ajouter succès Ajouter avertissement Ajouter erreur Fermer toutes les notifications

Ajoutez plusieurs notifications pour tester l'affichage.

`, } } showAll.args = { ...Default.args, showAll: true, bottom: true, } showAll.parameters = { sourceCode: [ { name: 'Template', code: `
Ajouter une notification info Ajouter une notification succès Ajouter une notification avertissement Ajouter une notification erreur

Ajoutez plusieurs notifications pour tester l'affichage.

`, }, { name: 'Script', code: ` `, }, ], }