Skip to content

Commit a4c66b8

Browse files
committed
mobile responsive
#4
1 parent 585f5a8 commit a4c66b8

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

index.html

+8
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@
6767

6868
<body>
6969
<div class="wrapper">
70+
<select id="mainSelect">
71+
<option>Polygon</option>
72+
<option>Random Points</option>
73+
<option>Cluster the Points (K-Means)</option>
74+
<option>Centroids</option>
75+
<option>Voronoi</option>
76+
<option>Voronoi Clip</option>
77+
</select>
7078
<calcite-stepper icon numbered>
7179
<calcite-stepper-item
7280
item-title="Polygon"

main.js

+12
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,14 @@ let reRun2 = false;
356356
let reRun3 = false;
357357
let reRun = false;
358358

359+
// change handler for mobile-view select
360+
let selector = document.querySelector("#mainSelect");
361+
selector.addEventListener("change", (evt) => {
362+
let s2 = `calcite-stepper > *:nth-child(${evt.target.selectedIndex + 1})`;
363+
document.querySelector(s2).click();
364+
selector.click();
365+
});
366+
359367
// Create click handlers:
360368
for (let i = 0; i < steps.length; i++) {
361369
let selector = `calcite-stepper > *:nth-child(${i + 1})`;
@@ -425,6 +433,10 @@ for (let i = 0; i < steps.length; i++) {
425433
}
426434
}
427435

436+
// let selector = document.querySelectorAll("#mainSelect option")[i].value;
437+
document.querySelector("#mainSelect").value = document.querySelectorAll(
438+
"#mainSelect option"
439+
)[i].value;
428440
runForStep(i);
429441
});
430442
}

style.css

+22
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,25 @@ calcite-stepper {
3939
#codeBlock .linkWrapper {
4040
text-align: right;
4141
}
42+
43+
#mainSelect {
44+
display: none;
45+
}
46+
@media (max-width: 1200px) {
47+
calcite-stepper {
48+
display: none;
49+
}
50+
#mainSelect {
51+
display: block;
52+
}
53+
#codeBlock {
54+
bottom: 0px;
55+
right: 0px;
56+
left: 0px;
57+
height: 143px;
58+
overflow-y: auto;
59+
top: auto;
60+
width: auto;
61+
padding-bottom: 20px;
62+
}
63+
}

0 commit comments

Comments
 (0)