Skip to content

Commit

Permalink
feat(snackbar): add clear
Browse files Browse the repository at this point in the history
  • Loading branch information
BeADre committed Jan 15, 2021
1 parent dffc1dd commit aebe81b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
3 changes: 3 additions & 0 deletions packages/varlet-ui/src/snackbar/example/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ export default defineComponent({
content: "Hello, I'm a snackbar",
position,
})
setTimeout(() => {
Snackbar.clear()
}, 2000)
}
const changeMultiple = () => {
Expand Down
18 changes: 13 additions & 5 deletions packages/varlet-ui/src/snackbar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,17 @@ interface Snackbar {

allowMultiple(bool: boolean): void

success(options: SnackbarOptions | string): void
success(options: SnackbarOptions | string): SnackbarHandel

warning(options: SnackbarOptions | string): void
warning(options: SnackbarOptions | string): SnackbarHandel

info(options: SnackbarOptions | string): void
info(options: SnackbarOptions | string): SnackbarHandel

error(options: SnackbarOptions | string): void
error(options: SnackbarOptions | string): SnackbarHandel

loading(options: SnackbarOptions | string): void
loading(options: SnackbarOptions | string): SnackbarHandel

clear(): void

isAllowMultiple: boolean
isMount: boolean | undefined
Expand Down Expand Up @@ -169,6 +171,12 @@ Snackbar.allowMultiple = function (bool = false) {
}
}

Snackbar.clear = function () {
Snackbar.uniqSnackbarOptions.forEach((snackbar: UniqSnackbarOptions) => {
snackbar.reactiveSnackOptions.show = false
})
}

Snackbar.isAllowMultiple = false

Snackbar.isMount = false
Expand Down

0 comments on commit aebe81b

Please sign in to comment.