-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
93 lines (77 loc) · 2.38 KB
/
index.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
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
88
89
90
91
92
93
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@vavt/message</title>
<style>
[data-theme='dark'] {
background-color: #000;
button {
background-color: #000;
color: #fff;
}
}
button {
outline: none;
border: none;
padding-left: 6px 10px;
}
button + button {
margin-top: 10px;
}
</style>
</head>
<body>
<div style="width: 100px; display: flex; flex-direction: column">
<button id="changeTheme">切换模式</button>
<button id="info">info</button>
<button id="error">error offsetTop40</button>
<button id="warning">warning 存在6s</button>
<button id="success">success 可关闭</button>
<button id="duration0">不会自动关闭</button>
<button id="duration01">更新内容</button>
<button id="closeAll">关闭全部</button>
</div>
<script type="module">
import { message } from './index.ts';
const msg =
'So even though we face the difficulties of today and tomorrow, I still have a dream.';
document.getElementById('changeTheme').onclick = () => {
const theme = document.documentElement.dataset.theme || 'light';
document.documentElement.dataset.theme = theme === 'dark' ? '' : 'dark';
};
document.getElementById('info').onclick = () => {
message.info(msg);
};
document.getElementById('warning').onclick = () => {
message.warning(msg, {
duration: 6000,
});
};
document.getElementById('success').onclick = () => {
message.success('包括消息、警告、成功和错误提示。', {
closeable: true,
});
};
let obj = {
close: () => {},
update: () => {},
};
document.getElementById('duration0').onclick = () => {
obj = message.error(msg, { duration: 0 });
};
document.getElementById('duration01').onclick = () => {
obj.update(Math.random());
};
document.getElementById('error').onclick = () => {
message.error(msg, {
offsetTop: 40,
});
};
document.getElementById('closeAll').onclick = () => {
message.closeAll();
};
</script>
</body>
</html>