forked from codesandbox/codesandbox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotifications.ts
More file actions
31 lines (29 loc) · 865 Bytes
/
notifications.ts
File metadata and controls
31 lines (29 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { Action } from './';
export interface NotificationAction extends Action {
title: string;
notificationType: 'notice' | 'warning' | 'error' | 'success';
timeAlive: number;
}
/**
* Returns an action that describes to open a notification in the editor
*
* @export
* @param {string} title
* @param {('notice' | 'warning' | 'error' | 'success')} [notificationType='notice']
* @param {number} [timeAlive=2] How long the notification should show in seconds
* @returns {NotificationAction}
*/
export function show(
title: string,
notificationType: 'notice' | 'warning' | 'error' | 'success' = 'notice',
timeAlive: number = 2
): NotificationAction {
// TODO automatically add type: 'action', maybe do this after conversion to TS
return {
type: 'action',
action: 'notification',
title,
notificationType,
timeAlive,
};
}