-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
181 lines (171 loc) · 5.02 KB
/
index.html
File metadata and controls
181 lines (171 loc) · 5.02 KB
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="src/style.css">
<!-- no favicon -->
<link rel="shortcut icon" href="#" />
<script>
async function loadSource(component, target, r = null) {
if (r == null) {
r = await fetch("src/"+component+".html").then(r => r.text());
}
target.innerHTML += `<div class="src row space-around"><details><summary class="color-default">View HTML</summary><div><pre><code></code></pre></div</details></div>`;
target.querySelector(".src code").innerText = r;
fetch("src/"+component+".css").then(r => r.text()).then(r => {
let bytes = (new TextEncoder().encode(r)).length;
target.querySelector(".src").innerHTML += `<details><summary class="color-default">View CSS (${bytes} Byte)</summary><div><pre><code></code></pre></div</details>`;
target.querySelectorAll(".src code")[1].innerText = r;
});
}
/* This is just for loading the sections from partials */
function loadComponent(component, target, withSource = true) {
fetch("example/"+component+".html").then(r => r.text()).then(r => {
target.innerHTML = r;
if (withSource) {
loadSource(component, target, r);
}
});
}
async function nodeFromFetch(component) {
let html = await fetch("example/"+component+".html").then(r => r.text());
return document.createRange().createContextualFragment(html);
}
document.addEventListener("DOMContentLoaded", (event) => {
[
"typography", "code", "breadcrumbs", "kbd",
"pagination", "button", "badge", "label",
"spinner", "tooltip", "dark", "alert",
"modal", "accordion", "tab",
"table", "card", "form",
"helper"].forEach(e => loadComponent(e, document.getElementById(e)));
["toast", "layout", "nav", "footer"].forEach(e => loadSource(e, document.getElementById(e)));
nodeFromFetch("nav").then(r => {
let node = document.getElementById("dark-mode");
node.parentNode.insertBefore(r, node);
});
nodeFromFetch("layout").then(r => {
let node = document.getElementById("layout");
node.parentNode.insertBefore(r, node);
});
nodeFromFetch("toast").then(r => {
let node = document.querySelector("main");
node.parentNode.insertBefore(r, node);
});
nodeFromFetch("footer").then(r => {
let node = document.querySelector("main");
node.parentNode.appendChild(r, node);
});
});
</script>
<title>nobloat/css</title>
<style>
section {
max-width: 75rem;
--margin: 2rem;
}
section:not(.no-margin) {
margin-bottom: 6rem;
}
.row {
padding-top: 2rem;
}
</style>
</head>
<body>
<!-- Dark/Light theme switch -->
<input id="dark-mode" class="dark-mode-checkbox" type="checkbox" hidden>
<main>
<section>
<article id="typography">
</article>
</section>
<section>
<article id="nav">
<h2>Navigation</h2>
<p>The Navigation menu/header is responsive and supports menus.
By default it wraps at <code>60rem</code>.
</p>
</article>
</section>
<section>
<article id="code">
</article>
<article id="breadcrumbs">
</article>
</section>
<section>
<article id="kbd">
</article>
<article id="pagination">
</article>
</section>
<section>
<article id="label">
</article>
<article id="badge">
</article>
<article id="button">
</article>
</section>
<section>
<article id="spinner">
</article>
</section>
<section>
<article id="tooltip">
</article>
<article id="dark">
</article>
</section>
<section>
<article id="alert">
</article>
</section>
<section>
<article id="toast">
<h2>Toasts</h2>
<p>They appear in a specified corner using one of the classes <code>right bottom</code>, <code>right top</code>, <code>left bottom</code> or <code>left top</code>.</p>
<p>Usage of the optional classes <code>close in-10</code> will autoclose the toast.</p>
</article>
</section>
<section>
<article id="modal">
</article>
</section>
<section>
<article id="accordion">
</article>
</section>
<section>
<article id="tab">
</article>
</section>
<section>
<article id="table">
</article>
</section>
<section>
<article id="card">
</article>
</section>
<section>
<article id="form">
</article>
</section>
<section class="no-margin" id="layout">
</section>
<section>
<article id="helper">
</article>
</section>
<section>
<article id="footer">
<h2>Footer</h2>
<p>It always sticks to the bottom of the page</p>
</article>
</section>
</main>
</body>
</html>