generated from adamrybinski/haunted-snow
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mulInput.js
58 lines (51 loc) · 1.13 KB
/
mulInput.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
48
49
50
51
52
53
54
55
56
57
58
import {
html,
component,
useState,
useEffect,
} from './deps.js';
import './mulButton.js'
function MulInputs(el) {
const [first, setFirst] = useState('John');
const [last, setLast] = useState('Snow');
useEffect(() => {
const event = new CustomEvent('change', {
detail: `${first} ${last}`
});
this.dispatchEvent(event);
}, [first, last]);
return html`
<mul-button></mul-button>
<div>
<label for="first-name">First</label>
<input
value=${first}
@keyup=${ev => setFirst(ev.target.value)}
type="text"
name="first"
id="first-name"
/>
<label for="last-name">Last</label>
<input
value=${last}
@keyup=${ev => setLast(ev.target.value)}
type="text"
name="last"
id="last-name"
/>
</div>
<style>
div {
border: none;
display: grid;
grid-template-columns: 20% 80%;
}
input {
border: 1px solid #e5e5e5;
padding: 6px 10px;
margin-bottom: 1em;
}
</style>
`;
}
customElements.define("mul-inputs", component(MulInputs));