Spaces:
Running
Running
Lab: truncate long variant names in the list, keeping the hash
#4
by volodymyrsvirhun - opened
- index.html +8 -1
index.html
CHANGED
|
@@ -60,6 +60,10 @@
|
|
| 60 |
.itembtn.active:hover { background: var(--accent);
|
| 61 |
border-color: var(--accent); }
|
| 62 |
.itembtn.active small { color: var(--accent-soft); }
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
#stage { flex: 1; position: relative; min-width: 0; }
|
| 64 |
#stage canvas { display: block; }
|
| 65 |
#hint { position: absolute; left: 12px; bottom: 10px; color: var(--ink-32);
|
|
@@ -607,7 +611,10 @@ fetch("classes.json")
|
|
| 607 |
const btn = document.createElement("button");
|
| 608 |
btn.className = "itembtn";
|
| 609 |
const d = item.dims_m;
|
| 610 |
-
|
|
|
|
|
|
|
|
|
|
| 611 |
<small>${d[0].toFixed(2)}×${d[1].toFixed(2)}×${d[2].toFixed(2)} m ·
|
| 612 |
${item.mass_kg.toFixed(1)} kg · ${item.joints.length} j</small>`;
|
| 613 |
btn.onclick = () => {
|
|
|
|
| 60 |
.itembtn.active:hover { background: var(--accent);
|
| 61 |
border-color: var(--accent); }
|
| 62 |
.itembtn.active small { color: var(--accent-soft); }
|
| 63 |
+
/* Long ids truncate in the middle: the trailing hash is what tells variants apart */
|
| 64 |
+
.itemname { display: flex; min-width: 0; white-space: nowrap; }
|
| 65 |
+
.itemname span:first-child { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
|
| 66 |
+
.itemname span + span { flex-shrink: 0; }
|
| 67 |
#stage { flex: 1; position: relative; min-width: 0; }
|
| 68 |
#stage canvas { display: block; }
|
| 69 |
#hint { position: absolute; left: 12px; bottom: 10px; color: var(--ink-32);
|
|
|
|
| 611 |
const btn = document.createElement("button");
|
| 612 |
btn.className = "itembtn";
|
| 613 |
const d = item.dims_m;
|
| 614 |
+
const label = item.id.replace(/^[a-z_]+_(?=\d)/, "#");
|
| 615 |
+
const [, head, tail] = label.match(/^(.*?)(_[0-9a-f]{6})?$/);
|
| 616 |
+
btn.title = item.id;
|
| 617 |
+
btn.innerHTML = `<span class="itemname"><span>${head}</span>${tail ? `<span>${tail}</span>` : ""}</span>
|
| 618 |
<small>${d[0].toFixed(2)}×${d[1].toFixed(2)}×${d[2].toFixed(2)} m ·
|
| 619 |
${item.mass_kg.toFixed(1)} kg · ${item.joints.length} j</small>`;
|
| 620 |
btn.onclick = () => {
|