()
| 2593 | } |
| 2594 | |
| 2595 | function renderUiExamples() { |
| 2596 | if (!uiExamplesList) return; |
| 2597 | uiExamplesList.innerHTML = ""; |
| 2598 | |
| 2599 | const list = uiExamplesActiveTab === "oled" ? UI_EXAMPLES_OLED : UI_EXAMPLES; |
| 2600 | const totalPages = Math.max(1, Math.ceil(list.length / UI_EXAMPLES_PER_PAGE)); |
| 2601 | const currentPage = Math.min( |
| 2602 | totalPages - 1, |
| 2603 | Math.max(0, uiExamplesPageByTab[uiExamplesActiveTab] || 0) |
| 2604 | ); |
| 2605 | uiExamplesPageByTab[uiExamplesActiveTab] = currentPage; |
| 2606 | |
| 2607 | if (uiExamplesPagePill) { |
| 2608 | uiExamplesPagePill.textContent = `Page ${currentPage + 1} / ${totalPages}`; |
| 2609 | } |
| 2610 | if (uiExamplesPrevBtn) uiExamplesPrevBtn.disabled = currentPage <= 0; |
| 2611 | if (uiExamplesNextBtn) uiExamplesNextBtn.disabled = currentPage >= totalPages - 1; |
| 2612 | |
| 2613 | const start = currentPage * UI_EXAMPLES_PER_PAGE; |
| 2614 | const pageItems = list.slice(start, start + UI_EXAMPLES_PER_PAGE); |
| 2615 | |
| 2616 | pageItems.forEach((ex) => { |
| 2617 | const btn = document.createElement("button"); |
| 2618 | btn.type = "button"; |
| 2619 | btn.className = "link-chip example-chip"; |
| 2620 | btn.innerHTML = ` |
| 2621 | <span class="icon">${ex.icon}</span> |
| 2622 | <span class="example-chip-text"> |
| 2623 | <span class="example-chip-title">${ex.title}</span> |
| 2624 | <span class="example-chip-desc">${ex.desc}</span> |
| 2625 | </span> |
| 2626 | `; |
| 2627 | btn.addEventListener("click", () => { |
| 2628 | const screen = createScreen(ex.title, safeFnNameFromTitle(ex.title)); |
| 2629 | screen.elements = ex.build(dispWidth, dispHeight); |
| 2630 | refreshScreenUI(); |
| 2631 | setActiveScreen(screen.id, false); |
| 2632 | pushHistory(); |
| 2633 | scrollToScreensSettings(); |
| 2634 | }); |
| 2635 | uiExamplesList.appendChild(btn); |
| 2636 | }); |
| 2637 | } |
| 2638 | |
| 2639 | function normalizeIconNameFromFile(file) { |
| 2640 | const raw = String(file || "").replace(/\\/g, "/"); |
no test coverage detected