-
Notifications
You must be signed in to change notification settings - Fork 0
/
2
67 lines (51 loc) · 1.9 KB
/
2
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { SplitView } from "./Library/UX/SplitView.js"
import { View } from "./Library/UX/View.js"
import { Panel } from "./Library/UX/Panel.js"
export class Main extends View {
public connectedCallback () {
let rootSplitView = new SplitView()
let leftPanel = document.createElement("deacon-panel") as Panel
let rightPanel = document.createElement("deacon-panel") as Panel
leftPanel.style.backgroundColor = "pink"
rightPanel.style.backgroundColor = "blue"
let leftLabel = document.createElement("h1")
let rightLabel = document.createElement("h1")
leftLabel.innerText = "Left"
rightLabel.innerText = "Right"
leftPanel.appendChild(leftLabel)
rightPanel.appendChild(rightLabel)
rootSplitView.appendChild(leftPanel)
rootSplitView.appendChild(rightPanel)
rootSplitView.orientation = "horizontal"
rootSplitView.resizeable = true
rootSplitView.sizes = this.getStoredValue("sizes", [0.5, 0.5])
let weakReference = this
rootSplitView.RegisterEventListener("splitresize", (event: Event) => {
weakReference.setStoredValue("sizes", rootSplitView.sizes)
})
window.addEventListener("resize", (event: Event) => {
View.Layout()
})
this.RegisterEventListener("mousemove", (event: Event) => {
console.log("Bob Jones")
})
document.body.appendChild(rootSplitView)
}
public getStoredValue(key: string, defaultValue: any) {
// Retrieve the stored value from localStorage
let storedValue = localStorage.getItem(key)
if (storedValue == null) {
return defaultValue
}
return JSON.parse(storedValue)
}
public setStoredValue(key: string, value: any) {
localStorage.setItem(key, JSON.stringify(value))
}
}
customElements.define("deacon-main", Main)
let mains = document.querySelector("deacon-main")
if (!mains) {
mains = document.createElement("deacon-main") as Main
document.body.appendChild(mains)
}