11import m from 'mithril' ;
2- import { Button , Toaster , Toast } from '@/' ;
2+ import { Button , Toaster , Toast , Switch } from '@/' ;
33import { Example } from '@shared/examples' ;
44
55const EXAMPLE_SRC = 'components/toast/examples/declarative.ts' ;
@@ -11,9 +11,10 @@ interface INotification {
1111
1212export class ToastDeclarativeExample {
1313 private notifications : INotification [ ] = [ ] ;
14+ private timeout : number = 3000 ;
1415
1516 public view ( ) {
16- return m ( Example , { src : EXAMPLE_SRC } , [
17+ return m ( Example , { options : this . renderOptions ( ) , src : EXAMPLE_SRC } , [
1718 m ( Button , {
1819 label : 'Show toast' ,
1920 intent : 'primary' ,
@@ -24,7 +25,8 @@ export class ToastDeclarativeExample {
2425 toasts : this . notifications . map ( notification => m ( Toast , {
2526 key : notification . key ,
2627 message : notification . message ,
27- onDismiss : this . dismiss
28+ onDismiss : this . dismiss ,
29+ timeout : this . timeout
2830 } ) )
2931 } )
3032 ] ) ;
@@ -41,4 +43,14 @@ export class ToastDeclarativeExample {
4143 const index = this . notifications . findIndex ( x => x . key === key ) ;
4244 this . notifications . splice ( index , 1 ) ;
4345 }
46+
47+ private renderOptions ( ) {
48+ return [
49+ m ( Switch , {
50+ checked : this . timeout === 0 ,
51+ label : 'Timeout = 0' ,
52+ onchange : ( ) => this . timeout = this . timeout === 0 ? 3000 : 0
53+ } )
54+ ] ;
55+ }
4456}
0 commit comments