Skip to content

Commit

Permalink
fix(toast-function): pass dismiss method from lib (#1887)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasaarcoverde authored Aug 26, 2024
2 parents 6f786b2 + cb7df7d commit 661874b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ToastStack, toast } from '../index'
import { Stack } from '../../stack'
import { Button } from '../../button'
import { Stack } from '../../stack'
import { ToastStack, toast } from '../index'

export default {
title: 'components/toast',
Expand Down Expand Up @@ -57,6 +57,21 @@ export function ToastFunction() {
>
Promise
</Button>
<Button
onClick={() => {
toast.dismiss()
}}
>
Cleanup all
</Button>
<Button
onClick={() => {
const id = toast.loading('Loading...')
setTimeout(() => toast.dismiss(id), 2000)
}}
>
Cleanup loading toast after 2 seconds!
</Button>
</Stack>
)
}
1 change: 1 addition & 0 deletions packages/shoreline/src/components/toast/toast-function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const toast = {
promise(promise: Promise<any>, messages: ToastPromiseMessages) {
return toastFactory.promise(promise, messages)
},
dismiss: toastFactory.dismiss,
}

function getOptions(variant: ToastVariant): any {
Expand Down

0 comments on commit 661874b

Please sign in to comment.