Skip to content

Commit 2d85127

Browse files
author
DavidQ
committed
Apply accordion to Samples xx and Class dropdown remove 2001-2051
1 parent 542fa52 commit 2d85127

3 files changed

Lines changed: 72 additions & 7 deletions

File tree

samples/index.css

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,49 @@
6262
align-items: center;
6363
gap: 4px;
6464
}
65+
66+
body.hub-page-samples .samples-phase-accordion {
67+
margin: 0 0 12px;
68+
border: 1px solid var(--line, rgba(221, 214, 254, 0.26));
69+
border-radius: 12px;
70+
background: linear-gradient(180deg, var(--panel, rgba(76, 29, 149, 0.88)) 0%, var(--panel2, rgba(49, 17, 102, 0.94)) 100%);
71+
overflow: hidden;
72+
border-bottom: 1px solid var(--line, rgba(221, 214, 254, 0.26));
73+
box-shadow: var(--theme-shadow);
74+
}
75+
76+
body.hub-page-samples .samples-phase-accordion > .is-collapsible__summary {
77+
display: flex;
78+
align-items: center;
79+
justify-content: space-between;
80+
gap: 10px;
81+
padding: 12px 14px;
82+
font-size: 1.35rem;
83+
background: rgba(43, 16, 91, 0.78);
84+
position: static;
85+
top: auto;
86+
left: auto;
87+
z-index: auto;
88+
color: var(--text, #f7f4ff);
89+
}
90+
91+
body.hub-page-samples .samples-phase-accordion > .is-collapsible__summary::before {
92+
font-size: calc(2em + 3px);
93+
margin-right: 6px;
94+
color: var(--text, #f7f4ff);
95+
}
96+
97+
body.hub-page-samples .samples-phase-accordion[open] > .is-collapsible__summary {
98+
position: static;
99+
}
100+
101+
.samples-phase-accordion__count {
102+
color: var(--muted, #e9ddff);
103+
font-size: 1rem;
104+
font-weight: 600;
105+
}
106+
107+
.samples-phase-accordion__content {
108+
padding: 12px;
109+
background: transparent;
110+
}

samples/index.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,9 @@ <h2>Filter Samples</h2>
6666
</div>
6767
<p id="samples-phase-filter-status" aria-live="polite"></p>
6868
</section>
69-
7069
<section class="content-section">
71-
<h2>All Phases and Samples</h2>
7270
<div id="samples-phase-list"></div>
7371
</section>
74-
7572
<div class="footer-note">
7673
Open sample pages through a local web server for stable module and asset loading.
7774
</div>

samples/index.render.js

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ function buildClassTokens(classValues, engineClassesUsed) {
5454
const classEntries = asArray(classValues).length > 0 ? asArray(classValues) : asArray(engineClassesUsed);
5555
const deduped = [...new Set(classEntries.map((entry) => normalize(entry)).filter(Boolean))];
5656
return deduped
57+
.filter((entry) => {
58+
const phase20SampleMatch = entry.match(/^samples\/phase-20\/(\d{4})$/i);
59+
if (!phase20SampleMatch) {
60+
return true;
61+
}
62+
const sampleNumber = Number(phase20SampleMatch[1]);
63+
return !Number.isInteger(sampleNumber) || sampleNumber < 2001 || sampleNumber > 2051;
64+
})
5765
.map((entry) => {
5866
const name = entry.split("/").at(-1) || entry;
5967
return { value: entry, label: name };
@@ -240,16 +248,30 @@ function renderPinnedList(container, rows) {
240248
function renderPhaseSections(container, phaseGroups) {
241249
container.innerHTML = "";
242250
for (const phaseGroup of phaseGroups) {
243-
const section = document.createElement("section");
244-
section.className = "content-section";
251+
const section = document.createElement("details");
252+
section.className = "is-collapsible samples-phase-accordion";
245253
section.dataset.phase = phaseGroup.phase;
246-
section.innerHTML = `<h2>${escapeHtml(phaseGroup.title)}</h2><p>${escapeHtml(phaseGroup.description)}</p>`;
254+
section.open = true;
255+
256+
const summary = document.createElement("summary");
257+
summary.className = "is-collapsible__summary";
258+
summary.innerHTML = `
259+
<span class="samples-phase-accordion__title">${escapeHtml(phaseGroup.title)}</span>
260+
<span class="samples-phase-accordion__count">${phaseGroup.samples.length} sample${phaseGroup.samples.length === 1 ? "" : "s"}</span>
261+
`;
262+
263+
const content = document.createElement("div");
264+
content.className = "is-collapsible__content samples-phase-accordion__content";
265+
content.innerHTML = `<p>${escapeHtml(phaseGroup.description)}</p>`;
266+
247267
const grid = document.createElement("div");
248268
grid.className = "card-grid";
249269
for (const sample of phaseGroup.samples) {
250270
grid.appendChild(buildSampleCard(sample));
251271
}
252-
section.appendChild(grid);
272+
content.appendChild(grid);
273+
section.appendChild(summary);
274+
section.appendChild(content);
253275
container.appendChild(section);
254276
}
255277
}

0 commit comments

Comments
 (0)