-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
151 lines (138 loc) · 4.8 KB
/
demo.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<!DOCTYPE html>
<html>
<head>
<title>macaron</title>
<link
rel="icon"
href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🍩</text></svg>"
/>
<meta charset="utf8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link rel="preconnect" href="https://unpkg.com" />
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Nunito&display=swap"
/>
<link rel="stylesheet" type="text/css" href="dist/macaron.css" />
<style>
:root {
font-family: Nunito, sans-serif;
font-size: 16px;
background: #c18b72;
color: #d8d0d5;
}
body {
max-width: 800px;
margin: 4em auto;
background: #151515;
padding: 0.5em 1em 2em;
box-shadow: 0.5em 0.6em #303030;
}
input,
button {
border: 1px solid transparent;
font-family: inherit;
font-weight: bold;
padding: 0.25em 0.5em;
border-radius: 4px;
background: #202020;
color: inherit;
margin: 0.1em 0;
}
input:focus {
border: 1px solid #9be099;
outline: unset;
}
input[type="color"] {
border: none;
padding: 0;
height: 1em;
width: 1em;
}
</style>
<script src="dist/macaron.js" type="text/javascript"></script>
</head>
<body>
<h1>macaron 🍩</h1>
<div>simple minimalistic toast notifications</div>
<div>
<input type="text" id="message" placeholder="message" />
<button
onclick="macaron.info(message.value || 'this is a macaron')"
>
info
</button>
<button
onclick="macaron.success(message.value || 'this is a macaron')"
>
success
</button>
<button
onclick="macaron.warn(message.value || 'this is a macaron')"
>
warn
</button>
<button
onclick="macaron.error(message.value || 'this is a macaron', { action: () => console.log('bad boy!') })"
>
error
</button>
</div>
<div>
<input
type="number"
id="timeout"
placeholder="timeout (milliseconds)"
onchange="macaron.setDefaultTimeout(timeout.value || 3 * 1000)"
/>
<br />
<br />
<code id="colors">
--macaron-bg: <span>#151515</span>
<input type="color" value="#151515" />;
<br />
--macaron-fg: <span>#d8d0d5</span>
<input type="color" value="#d8d0d5" />;
<br />
--macaron-shadow: <span>#151515</span>
<input type="color" value="#151515" />; <br />
<br />
--macaron-info: <span>#d895ee</span>
<input type="color" value="#d895ee" />;
<br />
--macaron-success: <span>#9be099</span>
<input type="color" value="#9be099" />;
<br />
--macaron-error: <span>#ee9598</span>
<input type="color" value="#ee9598" />;
<br />
--macaron-warn: <span>#e8d097</span>
<input type="color" value="#e8d097" />;
<br />
</code>
<script>
const vars = [
"bg",
"fg",
"shadow",
"info",
"success",
"error",
"warn",
];
const text = colors.querySelectorAll("span");
const inputs = colors.querySelectorAll("input");
for (const [i, input] of inputs.entries())
input.onchange = () => {
text[i].innerText = input.value;
document.body.style.setProperty(
`--macaron-${vars[i]}`,
input.value
);
};
</script>
</div>
</body>
</html>