-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathui.ts
More file actions
37 lines (29 loc) · 809 Bytes
/
ui.ts
File metadata and controls
37 lines (29 loc) · 809 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
import {dom, RegisterOptions} from "@e280/sly"
import {Desk} from "./desk/view.js"
import {Studio} from "../studio.js"
import {Panels} from "../types.js"
export type UiViews = ReturnType<typeof prepareDom>["views"]
export type UiComponents = ReturnType<typeof prepareDom>["components"]
export class Ui {
views: UiViews
components: UiComponents
constructor(studio: Studio<any>) {
const {views, components} = prepareDom(studio)
this.views = views
this.components = components
}
registerComponents(options?: RegisterOptions) {
dom.register(this.components, options)
}
}
function prepareDom<PS extends Panels>(studio: Studio<PS>) {
const views = {
LettuceDesk: Desk({studio}),
}
return {
views,
components: {
LettuceDesk: views.LettuceDesk.component().props(() => []),
},
}
}