import Button from '@/lib/components/Button/Button.vue'; import Toast from '@/lib/components/Toast'; import { commonArgTypes, sizeOptions } from '@/lib/constants'; import type { Meta } from '@storybook/vue3'; import { ref } from 'vue'; const meta = { title: 'Feedback Component/Toast', component: Toast, parameters: { layout: 'centered', docs: { description: { component: '팝업 UI형태로 화면 하단에 일시적으로 노출되는 메시지 창' }, source: { type: 'code' } } }, argTypes: { radius: { ...commonArgTypes.radius, description: 'Toast border 둥굴기' }, scaling: { ...commonArgTypes.scaling, description: 'Toast 비율' }, size: { ...commonArgTypes.size, table: { category: 'Props', type: { summary: sizeOptions.filter((option) => option !== 'x-small').join(' | ') } }, options: sizeOptions.filter((option) => option !== 'x-small'), description: 'Toast 크기' }, color: { table: { category: 'Props', type: { summary: ['danger', 'warning', 'success', 'information'].join(' | ') } }, options: ['danger', 'warning', 'success', 'information'], control: { type: 'select' }, defaultValue: { summary: 'none' }, description: 'Toast 색' } } } as Meta; export default meta; const toastComponent = { ToastRoot: Toast.Root, ToastTitle: Toast.Title, ToastDescription: Toast.Description, ToastActionButton: Toast.ActionButton, Button }; export const Default = { render: (args: any) => ({ components: toastComponent, setup() { const open = ref(false); const handleShowToast = () => { open.value = true; }; const handleClickActionButton = () => { open.value = false; }; return { args, open, handleShowToast, handleClickActionButton }; }, template: `
토스트 제목 토스트 내용이 위치합니다 닫기
` }), parameters: { docs: { source: { code: ` ` } } } }; export const Color = { render: (args: any) => ({ components: toastComponent, setup() { const open = ref(false); const semanticColor = ref('information'); const colorMapping = { sky: 'information', red: 'danger', yellow: 'warning', green: 'success' }; const handleShowToast = (color: 'sky' | 'red' | 'yellow' | 'green') => { open.value = true; semanticColor.value = colorMapping[color]; }; const handleClickActionButton = () => { open.value = false; }; return { args, open, semanticColor, handleShowToast, handleClickActionButton }; }, template: `
토스트 제목 토스트 내용이 위치합니다 닫기
` }), parameters: { docs: { source: { code: ` ` } } } }; export const NoTitleToast = { render: (args: any) => ({ components: toastComponent, setup() { const open = ref(false); const handleShowToast = () => { open.value = true; }; const handleClickActionButton = () => { open.value = false; }; return { open, handleShowToast, handleClickActionButton, args }; }, template: `
토스트 내용이 위치합니다 닫기
` }), parameters: { docs: { source: { code: ` ` } } } }; export const NoButtonToast = { render: (args: any) => ({ components: toastComponent, setup() { const open = ref(false); const handleShowToast = () => { open.value = true; }; const handleClickActionButton = () => { open.value = false; }; return { open, handleShowToast, handleClickActionButton, args }; }, template: `
토스트 제목 토스트 내용이 위치합니다
` }), parameters: { docs: { source: { code: ` ` } } } };