-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmessage.html
36 lines (32 loc) · 1.31 KB
/
message.html
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
<!DOCTYPE html>
<html>
<head>
<link rel="icon" href="/logo.svg">
<title>MessageBoard Demo</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<script type="text/javascript" src="van-latest.nomodule.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected]/dist/van-ui.nomodule.js"></script>
<script>
const {a, button} = van.tags
const board = new MessageBoard({top: "20px"})
const example1 = () => board.show({message: "Hi!", durationSec: 1})
const example2 = () => board.show(
{message: ["Welcome to ", a({href: "https://vanjs.org/", style: "color: #0099FF"}, "🍦VanJS"), "!"], closer: "❌"})
const closed = van.state(false)
const example3 = () => {
closed.val = false
board.show({message: "Press ESC to close this message", closed})
}
document.addEventListener("keydown", e => e.key === "Escape" && (closed.val = true))
van.add(document.body,
button({onclick: example1}, "Example 1"), " ",
button({onclick: example2}, "Example 2"), " ",
button({onclick: example3}, "Example 3"), " ",
button({onclick: () => board.remove()}, "Remove Message Board")
)
</script>
</body>
</html>