@@ -85,8 +85,6 @@ export default class FlasherFactory implements NotificationFactoryInterface {
8585 const nOptions = notification . options || { } ;
8686 const options = Array . isArray ( nOptions ) ? this . options : Object . assign ( { } , this . options , nOptions ) ;
8787
88- this . applyDarkMode ( ) ;
89-
9088 const onContainerReady = ( ) => {
9189 const container = this . createContainer ( options ) ;
9290 this . addToContainer ( container , envelope , options ) ;
@@ -102,6 +100,8 @@ export default class FlasherFactory implements NotificationFactoryInterface {
102100
103101 renderOptions ( options : FlasherOptions ) : void {
104102 this . options = Object . assign ( { } , this . options , options ) ;
103+
104+ this . applyDarkMode ( ) ;
105105 }
106106
107107 createContainer ( options : { position : string ; style : Properties } ) : HTMLDivElement {
@@ -200,6 +200,10 @@ export default class FlasherFactory implements NotificationFactoryInterface {
200200 }
201201
202202 applyDarkMode ( ) : void {
203+ if ( document . body . classList . contains ( 'fl-dark-mode' ) ) {
204+ return ;
205+ }
206+
203207 let [ mode , className = '.dark' ] = [ ] . concat ( this . options . darkMode as unknown as ConcatArray < never > ) ;
204208 let css = '.fl-main-container .fl-container.fl-flasher {background-color: rgb(15, 23, 42);color: rgb(255, 255, 255);}' ;
205209
@@ -211,6 +215,8 @@ export default class FlasherFactory implements NotificationFactoryInterface {
211215 style . type = 'text/css' ;
212216 style . appendChild ( document . createTextNode ( css ) ) ;
213217 document . head . appendChild ( style ) ;
218+
219+ document . body . classList . add ( 'fl-dark-mode' ) ;
214220 }
215221
216222 stringToHTML ( str : string ) : HTMLElement {
0 commit comments