/
index.js
47 lines (42 loc) · 1.86 KB
/
index.js
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
import { component, useEffect, useState } from 'haunted';
//import { html } from 'lit-html';
//import { html } from 'https://cdn.pika.dev/lighterhtml';
import { html } from 'lighterhtml-plus';
import WiredElements from 'wired-elements';
function LoginFE() {
const [customerid, setUserid] = useState(null);
useEffect(() => {
import('./kernel').then((Module) => {
Module.onKernelKey('change:customerid', _customerid => {
setUserid(_customerid);
});
setUserid(Module.getSharedKernel('customerid'));
})
}, []);
const update = (newState) => {
import('./kernel').then((Module) => {
Module.updateSharedKernel(newState);
})
}
return html`
<section class="wc-module">
<wired-card class="layout-container">
<img style="float: right; width: 300px; height: 300px;" src="/static/assets/pizza.svg">
<h1>Welcome to Tropical Pizzas!</h1>
<h2>Pineapples was only the beginning! We bring you the full experience of fruit, cheese, dough and whatever!</h2>
${customerid == null
?html`
<wired-card class="layout-form">
<h3>Log in or register an account!</h3>
<wired-input placeholder="User name"></wired-input>
<wired-input type="password" placeholder="Password"></wired-input>
<wired-button onclick=${ () => update({customerid: '45645645'})}>Log in</wired-button>
<wired-button>Register</wired-button>
</wired-card>
`
:html`<h2>(You are already logged in, go to the <a href="/pizzamenu">pizza menu</a> and order some pizzas :)</h2>`
}
</wired-card>
</section>`;
}
customElements.define('x-login', component(LoginFE, { useShadowDOM: false }));