Skip to content

Commit 2f4519c

Browse files
committed
New example: Multicol module
1 parent 0579e4b commit 2f4519c

File tree

1 file changed

+16
-58
lines changed

1 file changed

+16
-58
lines changed

modules/multicol.html

+16-58
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
orphans: 3;
1313
gap: 1em;
1414
column-rule: 2px dashed #666;
15+
height: 40em;
1516
}
1617
.title {
1718
column-span: all;
@@ -24,13 +25,19 @@
2425
margin: 0 0 1em 0;
2526
line-height: 1.4;
2627
}
28+
.breakInside p {
29+
break-inside: avoid;
30+
}
2731
#options {
2832
position: fixed;
2933
top: 1rem;
3034
right: 1rem;
3135
background: white;
3236
display: none;
3337
}
38+
fieldset p {
39+
margin-bottom: 0.25em;
40+
}
3441
[aria-expanded] {
3542
position: relative;
3643
top: 0;
@@ -52,7 +59,7 @@
5259
}
5360
blockquote {
5461
border: 2px dashed red;
55-
margin: 0;
62+
margin: 0 0 0.25em 0;
5663
}
5764
blockquote p {
5865
margin-bottom: 0;
@@ -186,64 +193,15 @@ <h1>A Lament for Confederation</h1>
186193
<input type="checkbox" id="blockSpan" />
187194
<label for="blockSpan">Blockquote spans all columns</label>
188195
</p>
196+
<p>
197+
<input type="checkbox" id="colFill" />
198+
<label for="colFill">Balance columns</label>
199+
</p>
200+
<p>
201+
<input type="checkbox" id="break" />
202+
<label for="break">Don't break paragraphs</label>
203+
</p>
189204
</div>
190205
</fieldset>
191-
<script>
192-
const article = document.querySelector("article");
193-
const title = document.querySelector(".title");
194-
const options = document.querySelector("#options");
195-
const legend = document.querySelector("#options > legend");
196-
const colCount = document.getElementById("colCount");
197-
const colWidth = document.getElementById("colWidth");
198-
const gapSize = document.getElementById("gapSize");
199-
const colSpan = document.getElementById("colSpan");
200-
const blockSpan = document.getElementById("blockSpan");
201-
const blockquote = document.getElementsByTagName("blockquote")[0];
202-
203-
// make options visible if js is enabled
204-
options.style.display = "revert";
205-
206-
legend.addEventListener("click", () => {
207-
showAndHideMenu();
208-
});
209-
210-
colCount.addEventListener("change", () => {
211-
article.style.columnCount = colCount.value;
212-
});
213-
214-
colWidth.addEventListener("change", () => {
215-
article.style.columnWidth = `${colWidth.value}em`;
216-
});
217-
218-
gapSize.addEventListener("change", () => {
219-
article.style.gap = `${gapSize.value}em`;
220-
});
221-
222-
colSpan.addEventListener("change", () => {
223-
if (colSpan.checked) {
224-
title.style.columnSpan = "all";
225-
} else {
226-
title.style.columnSpan = "none";
227-
}
228-
});
229-
230-
blockSpan.addEventListener("change", () => {
231-
if (blockSpan.checked) {
232-
blockquote.style.columnSpan = "all";
233-
} else {
234-
blockquote.style.columnSpan = "none";
235-
}
236-
});
237-
238-
function showAndHideMenu() {
239-
if (legend.getAttribute("aria-expanded") === "true") {
240-
// close it
241-
legend.setAttribute("aria-expanded", "false");
242-
} else {
243-
// open it
244-
legend.setAttribute("aria-expanded", "true");
245-
}
246-
}
247-
</script>
248206
</body>
249207
</html>

0 commit comments

Comments
 (0)