-
Notifications
You must be signed in to change notification settings - Fork 1
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
Ivan Kudinov
committed
Sep 5, 2024
1 parent
c5920d8
commit 541696c
Showing
4 changed files
with
38 additions
and
44 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,28 +1,33 @@ | ||
import { toast, ToastPosition, TypeOptions } from 'react-toastify' | ||
import { toast, ToastPosition } from 'react-toastify' | ||
import { RootStore } from '../../store/rootStore' | ||
import ToastInner from './ToastInner' | ||
import { makeObservable, observable } from 'mobx' | ||
|
||
export class ToastStore { | ||
rootStore: RootStore | ||
isDarkTheme: boolean | ||
@observable lastText: string | ||
|
||
constructor(rootStore: RootStore) { | ||
makeObservable(this) | ||
|
||
this.rootStore = rootStore | ||
this.isDarkTheme = false | ||
this.lastText = '' | ||
} | ||
|
||
setTheme(isDarkTheme: boolean) { | ||
this.isDarkTheme = isDarkTheme | ||
} | ||
|
||
showToast(text: string, timeout = 3000) { | ||
this.lastText = text | ||
|
||
const toastOptions = { | ||
theme: this.isDarkTheme ? 'dark' : 'light', | ||
position: 'bottom-left' as ToastPosition, | ||
autoClose: timeout, | ||
type: 'info' as TypeOptions, | ||
} | ||
|
||
toast(ToastInner({ text }), toastOptions) | ||
toast.info(text, toastOptions) | ||
} | ||
} |
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