-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.ts
37 lines (32 loc) · 827 Bytes
/
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
import html from '../../src/index';
import baemin from 'url:./jiayou.gif';
const state = {
text: '',
};
const inputHandler = (ev: InputEvent) => {
state.text = (ev.target as any).value;
const $display = document.querySelector('#display');
if ($display) {
$display.textContent = state.text;
}
};
const containerClassName = 'input-wrapper';
function render() {
const $app = document.querySelector('#app');
const myComponent = html`
<div class="${containerClassName}">
${html` <img src="${baemin}" alt="woowa-img" /> `}
<input
type="text"
placeholder="아무거나 입력하세요"
onInput=${inputHandler}
/>
<span id="display">${state.text}</span>
</div>
`;
if ($app) {
$app.innerHTML = '';
$app.appendChild(myComponent);
}
}
render();