-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovider-app.ts
87 lines (74 loc) · 2.45 KB
/
provider-app.ts
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { LitElement, css, html } from 'lit';
import { property } from 'lit/decorators.js';
import { contextProvider } from '@lit-labs/context';
import { ScopedElementsMixin } from '@open-wc/scoped-elements';
import { get } from 'svelte/store';
import { SensemakerStore } from '@neighbourhoods/nh-launcher-applet';
import { ComputeContextInput } from '@neighbourhoods/sensemaker-lite-types';
import { sensemakerStoreContext } from './contexts';
import { ProviderStore, providerStoreContext } from '@neighbourhoods/provider-store';
import { ProviderComponent } from '@neighbourhoods/provider-component'
export class ProviderApp extends ScopedElementsMixin(LitElement) {
// set up the context providers for both stores so that they can be accessed by other components
@contextProvider({ context: providerStoreContext })
@property()
providerStore!: ProviderStore;
@contextProvider({ context: sensemakerStoreContext })
@property()
sensemakerStore!: SensemakerStore;
async firstUpdated() {
}
render() {
return html`
<main>
<div class="home-page">
<provider-component></provider-component>
</div>
</main>
`;
}
// this is an example function of computing a context, since your UI will likely be displaying various contexts
// this is an example from the todo applet
async computeContext(_e: CustomEvent) {
const contextResultInput: ComputeContextInput = {
resource_ehs: await this.providerStore.allProviderResourceEntryHashes(),
context_eh: get(this.sensemakerStore.appletConfig()).cultural_contexts["most_important_tasks"],
can_publish_result: false,
}
const contextResult = await this.sensemakerStore.computeContext("most_important_tasks", contextResultInput)
}
static get scopedElements() {
return {
'provider-component': ProviderComponent,
};
}
static styles = css`
.home-page {
display: flex;
flex-direction: row;
}
:host {
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
font-size: calc(10px + 2vmin);
color: #1a2b42;
max-width: 960px;
margin: 0 auto;
text-align: center;
background-color: var(--lit-element-background-color);
}
main {
flex-grow: 1;
}
.app-footer {
font-size: calc(12px + 0.5vmin);
align-items: center;
}
.app-footer a {
margin-left: 5px;
}
`;
}