File tree 5 files changed +82
-1
lines changed
workbench/statusBar/notification
5 files changed +82
-1
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ enum ContextViewEvent {
37
37
const contextViewClass = prefixClaName ( 'context-view' ) ;
38
38
const contentClassName = getBEMElement ( contextViewClass , 'content' ) ;
39
39
const blockClassName = getBEMElement ( contextViewClass , 'block' ) ;
40
- const shadowClassName = getBEMModifier ( contextViewClass , 'shadow' ) ;
40
+ export const shadowClassName = getBEMModifier ( contextViewClass , 'shadow' ) ;
41
41
42
42
const Emitter = new EventEmitter ( ) ;
43
43
Original file line number Diff line number Diff line change
1
+ import * as React from 'react' ;
2
+ import { IStatusBarItem , StatusBarEvent } from 'mo' ;
3
+ import { Controller } from 'mo/react/controller' ;
4
+ import { statusBarService } from 'mo/services' ;
5
+ import { singleton } from 'tsyringe' ;
6
+
7
+ export interface INotificationController {
8
+ onClick ?: ( e : React . MouseEvent , item : IStatusBarItem ) => void ;
9
+ }
10
+
11
+ @singleton ( )
12
+ export class NotificationController
13
+ extends Controller
14
+ implements INotificationController {
15
+ constructor ( ) {
16
+ super ( ) ;
17
+ this . initStatusBar ( ) ;
18
+ }
19
+
20
+ public onClick = ( e : React . MouseEvent , item : IStatusBarItem ) => {
21
+ this . emit ( StatusBarEvent . onClick , e , item ) ;
22
+ } ;
23
+
24
+ public notify ( ) {
25
+ console . log ( 'service:' , statusBarService ) ;
26
+ }
27
+
28
+ private initStatusBar ( ) {
29
+ }
30
+ }
Original file line number Diff line number Diff line change
1
+ import { Icon } from 'mo/components/icon' ;
2
+ import * as React from 'react' ;
3
+ import { injectable } from 'tsyringe' ;
4
+ import { IStatusBarItem } from './workbench/statusBar' ;
5
+
6
+ export type NotificationStatusType = 'message' | 'normal' ;
7
+
8
+ export interface INotification < T = any > extends IStatusBarItem {
9
+ data : T [ ] ;
10
+ status : NotificationStatusType ;
11
+ }
12
+
13
+ @injectable ( )
14
+ export class NotificationModel < T > implements INotification < T > {
15
+
16
+ static readonly ID = 'MO_NOTIFICATION' ;
17
+ static readonly NAME = 'Notification' ;
18
+
19
+ public id : string ;
20
+ public name : string ;
21
+ public data : T [ ] ;
22
+ public sortIndex : number ;
23
+ public render : ( ) => ReactNode ;
24
+ public status : NotificationStatusType ;
25
+
26
+ constructor (
27
+ id : string = NotificationModel . ID ,
28
+ name : string = NotificationModel . NAME ,
29
+ data : T [ ] = [ ] ,
30
+ sortIndex : number = 1 ,
31
+ render : ( ) => ReactNode = ( ) => < Icon type = "bell" /> ,
32
+ status : NotificationStatusType = 'normal'
33
+ ) {
34
+ this . id = id ;
35
+ this . name = name ;
36
+ this . sortIndex = sortIndex ;
37
+ this . render = render ;
38
+ this . status = status ;
39
+ this . data = data ;
40
+ }
41
+ }
Original file line number Diff line number Diff line change
1
+ import * as React from "react" ;
2
+ import { Icon } from "mo/components/icon" ;
3
+ import { INotification } from "mo/model/notification" ;
4
+ import { INotificationController } from "mo/controller/notification" ;
5
+
6
+ export function Notification ( props : INotification & INotificationController ) {
7
+ return (
8
+ < Icon type = "bell" />
9
+ )
10
+ }
You can’t perform that action at this time.
0 commit comments