|
5 | 5 |
|
6 | 6 | import "vs/css!./notification"; |
7 | 7 |
|
8 | | -const NOTIFICATION_STORAGE_KEY = "dethcrypto:ethereum-code-viewer.notification"; |
9 | | -// Change this if a new notification should be shown |
10 | | -const NOTIFICATION_STORAGE_VALUE = "1"; |
11 | | - |
12 | | -const notifications = [ |
13 | | - { |
14 | | - text: "💸 Enjoy using DethCode? Consider funding development via GitCoin 💸", |
15 | | - link: "https://gitcoin.co/grants/4038/typechain-dksth", |
16 | | - }, |
17 | | -]; |
18 | | - |
19 | | -const notificationHtml = `${notifications.map( |
20 | | - (notification) => ` |
21 | | - <div class="notification-main"> |
22 | | - <a href="${notification.link}" target="_blank" class="notification-content"> |
23 | | - ${notification.text} |
24 | | - </a> |
25 | | - </div>` |
26 | | -)} |
27 | | -<div class="notification-footer"> |
28 | | - <button class="notification-confirm-button">Whatever</button> |
29 | | -</div> |
30 | | -`; |
31 | | - |
32 | 8 | export const renderNotification = () => { |
33 | | - // If user has confirmed the notification and checked `don't show me again`, ignore it |
34 | | - if ( |
35 | | - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition |
36 | | - !window.localStorage || |
37 | | - window.localStorage.getItem(NOTIFICATION_STORAGE_KEY) === |
38 | | - NOTIFICATION_STORAGE_VALUE |
39 | | - ) { |
40 | | - return; |
41 | | - } |
42 | | - |
43 | | - const notificationElement = document.createElement("div"); |
44 | | - notificationElement.classList.add("deth-notification"); |
45 | | - notificationElement.innerHTML = notificationHtml; |
46 | | - document.body.appendChild(notificationElement); |
47 | | - |
48 | | - notificationElement.querySelector<HTMLButtonElement>( |
49 | | - ".notification-confirm-button" |
50 | | - )!.onclick = () => { |
51 | | - // We won't show the banner again until NOTIFICATION_STORAGE_VALUE is changed. |
52 | | - window.localStorage.setItem( |
53 | | - NOTIFICATION_STORAGE_KEY, |
54 | | - NOTIFICATION_STORAGE_VALUE |
55 | | - ); |
56 | | - document.body.removeChild(notificationElement); |
57 | | - }; |
| 9 | + return; |
58 | 10 | }; |
0 commit comments