-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
wouter-adriaens
committed
Feb 15, 2024
1 parent
242f6b5
commit 4836225
Showing
4 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<template> | ||
<vl-toaster mod-top-right> | ||
<vl-alert | ||
v-for="toast in store.toasts" | ||
:key="toast.id" | ||
mod-small | ||
:icon="toast.type === 'success' ? 'check' : 'warning'" | ||
:mod-error="toast.type === 'error'" | ||
:mod-success="toast.type === 'success'" | ||
:mod-warning="toast.type === 'warning'" | ||
mod-fade-out | ||
closable | ||
close-text="Toast sluiten" | ||
:title="toast.title" | ||
@close="store.removeToast(toast?.id as string)" | ||
> | ||
<template v-if="typeof toast.content === 'string'"> | ||
{{ toast.content }} | ||
</template> | ||
<template v-else> | ||
<ul> | ||
<li v-for="message in toast.content" :key="message"> | ||
{{ message }} | ||
</li> | ||
</ul> | ||
</template> | ||
</vl-alert> | ||
</vl-toaster> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { VlAlert, VlToaster } from '@govflanders/vl-ui-design-system-vue3'; | ||
import { useUtilStore } from '@/composables'; | ||
const store = useUtilStore(); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<typeof OeToaster> = { | ||
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<typeof OeToaster>; | ||
/* | ||
*👇 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: ` | ||
<oe-button class="vl-u-spacer-bottom" @click="showToast('error')">Push error toast to util store</oe-button><br/> | ||
<oe-button class="vl-u-spacer-bottom" @click="showToast('success')">Push success toast to util store</oe-button><br/> | ||
<oe-button class="vl-u-spacer-bottom" @click="showToast('warning')">Push warning toast to util store</oe-button><br/> | ||
<oe-button class="vl-u-spacer-bottom" @click="showToast">Push default toast to util store</oe-button><br/> | ||
<oe-toaster /> | ||
`, | ||
}), | ||
}; |