forked from MichiSpebach/mammutmap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtutorialWidgets.ts
More file actions
38 lines (32 loc) · 1005 Bytes
/
tutorialWidgets.ts
File metadata and controls
38 lines (32 loc) · 1005 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
32
33
34
35
36
37
38
import { SimpleWidget } from '../dist/core/Widget'
import { MenuItemFile, PopupWidget, RenderElements, applicationMenu, coreUtil } from '../dist/pluginFacade'
applicationMenu.addMenuItemTo('tutorialWidgets.js', new MenuItemFile({label: 'show popup with widget', click: () => showPopupWithWidget()}))
async function showPopupWithWidget(): Promise<void> {
const widget = new TutorialWidget()
PopupWidget.newAndRender({
title: widget.getId(),
content: await widget.shape(),
onClose: () => widget.unrender()
})
}
class TutorialWidget extends SimpleWidget {
private counter: number = 0
public constructor() {
super(`tutorialWidget${coreUtil.generateId()}`, 'div')
}
protected override shapeInner(): RenderElements {
return [
{
type: 'button',
style: {width: '250px'},
onclick: () => {this.counter++; this.render()},
children: '+1'
},
{
type: 'div',
style: {color: `rgb(0, ${this.counter*10}, 0)`},
children: `Count is ${this.counter}.`
}
]
}
}