Skip to content

Commit c3f3b76

Browse files
Update bannerImpl.md
1 parent deffc14 commit c3f3b76

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

docs/developers/bannerImpl.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
## Implementation of the Warning Banners
22
The implementation of the warning banners are implemented in few steps, which first are implemented in the `pushNotificationMessage` function.
33
The function then pushes a new message into the stack and renders it.
4-
## Implementation
5-
Here is the implementation of `pushNotificationMessage`.
4+
65
``` ts
76
export function pushNotificationMessage(options: NotificationOptions): void {
87
if (!notificationsInitialized) {
@@ -14,5 +13,25 @@ export function pushNotificationMessage(options: NotificationOptions): void {
1413
notificationMessages.push(options);
1514
}
1615
```
16+
[pushNotificationMessage Implementation](https://github.com/microsoft/pxt/blob/master/skillmap/src/lib/notifications.ts#L7-L9)
17+
18+
It then processes into the warning notification function, a higher level function that gets passed by pushNotificationMessage. In the end, all these steps get executed by `showNotificationMsg`. And finally, gets exposed to `errorNotification` and `warningNotification.`
19+
20+
``` ts
21+
function showNotificationMsg(kind: string, msg: string) {
22+
pushNotificationMessage({ kind: kind, text: msg, hc: false }); // No high contrast support in skillmap
23+
}
24+
25+
export function errorNotification(msg: string) {
26+
pxt.tickEvent("notification.error", { message: msg })
27+
debugger // trigger a breakpoint when a debugger is connected, like in U.oops()
28+
showNotificationMsg("err", msg)
29+
}
30+
31+
export function warningNotification(msg: string) {
32+
pxt.log("warning: " + msg)
33+
showNotificationMsg("warn", msg)
34+
}
35+
```
36+
[notification banner implementation](https://github.com/microsoft/pxt/blob/master/skillmap/src/lib/notifications.ts#L07-L20)
1737
18-
[warning](https://github.com/microsoft/pxt/blob/master/skillmap/src/lib/notifications.ts#L7-L9)

0 commit comments

Comments
 (0)