diff --git a/.storybook/preview.ts b/.storybook/preview.ts index 2633860..e73d72a 100644 --- a/.storybook/preview.ts +++ b/.storybook/preview.ts @@ -5,6 +5,7 @@ import { far } from '@fortawesome/free-regular-svg-icons'; import { fas } from '@fortawesome/free-solid-svg-icons'; import { VlUiCore, VlUiUtil } from '@govflanders/vl-ui-design-system-vue3'; import { setup } from '@storybook/vue3'; +import { createPinia } from 'pinia'; import type { Preview } from '@storybook/vue3'; library.add(fas); @@ -14,6 +15,7 @@ library.add(fab); setup((app) => { app.use(VlUiCore); app.use(VlUiUtil); + app.use(createPinia()); }); const preview: Preview = { diff --git a/src/components/dumb/OeToaster.vue b/src/components/dumb/OeToaster.vue new file mode 100644 index 0000000..51c7cb6 --- /dev/null +++ b/src/components/dumb/OeToaster.vue @@ -0,0 +1,36 @@ + + + diff --git a/src/components/dumb/index.ts b/src/components/dumb/index.ts index e8e8fc9..93d371f 100644 --- a/src/components/dumb/index.ts +++ b/src/components/dumb/index.ts @@ -14,6 +14,7 @@ import OeHeader from './OeHeader.vue'; import OeLoader from './OeLoader.vue'; import OeSelect from './OeSelect.vue'; import OeTinyMce from './OeTinyMCE.vue'; +import OeToaster from './OeToaster.vue'; import OeWizard from './OeWizard.vue'; import SystemFields from './SystemFields.vue'; @@ -34,6 +35,7 @@ export { OeLoader, OeSelect, OeTinyMce, + OeToaster, OeWizard, SystemFields, }; diff --git a/src/stories/dumb-components/toaster.stories.ts b/src/stories/dumb-components/toaster.stories.ts new file mode 100644 index 0000000..e1e302a --- /dev/null +++ b/src/stories/dumb-components/toaster.stories.ts @@ -0,0 +1,68 @@ +import '@/scss/main.scss'; +import { useUtilStore } from '@/composables'; +import { OeButton } from '@components/dumb'; +import OeToaster from '@components/dumb/OeToaster.vue'; +import type { Meta, StoryObj } from '@storybook/vue3'; +import type { ToastType } from '@models/toast'; + +// More on how to set up stories at: https://storybook.js.org/docs/vue/writing-stories/introduction +const meta: Meta = { + title: 'Dumb components/Toaster', + component: OeToaster, + // This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/vue/writing-docs/autodocs + tags: ['autodocs'], + + parameters: { + layout: 'fullscreen', + docs: { + story: { + height: '250px', + }, + }, + }, +}; + +export default meta; +type Story = StoryObj; +/* + *👇 Render functions are a framework specific feature to allow you control on how the component renders. + * See https://storybook.js.org/docs/vue/api/csf + * to learn how to use render functions. + */ +export const Tabs: Story = { + parameters: { + docs: { + story: { + height: '500px', + }, + description: { + story: 'The component displays all toasts that are pushed to the `UtilStore` in the upper right corner.', + }, + }, + }, + render: () => ({ + components: { + OeToaster, + OeButton, + }, + setup: () => { + const utilStore = useUtilStore(); + const showToast = (type: ToastType) => { + utilStore.addToast({ + title: 'Title', + content: 'Content', + type, + }); + }; + + return { showToast }; + }, + template: ` + Push error toast to util store
+ Push success toast to util store
+ Push warning toast to util store
+ Push default toast to util store
+ + `, + }), +};