Skip to content

Commit 02f76cb

Browse files
clanker-loverclaude
andcommitted
Collapse imports behind toggle, bump v0.2.1
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c6222b6 commit 02f76cb

3 files changed

Lines changed: 36 additions & 8 deletions

File tree

codedocent/templates/base.html

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,21 @@
240240
text-transform: uppercase;
241241
letter-spacing: 0.08em;
242242
color: var(--text-imports-label);
243-
margin-bottom: 4px;
243+
cursor: pointer;
244+
list-style: none;
245+
}
246+
247+
.cd-imports__label::-webkit-details-marker {
248+
display: none;
249+
}
250+
251+
.cd-imports__label::before {
252+
content: "▶ ";
253+
font-size: 9px;
254+
}
255+
256+
.cd-imports[open] > .cd-imports__label::before {
257+
content: "▼ ";
244258
}
245259

246260
.cd-imports__item {
@@ -398,12 +412,12 @@
398412
</div>
399413
<div class="cd-node__body">
400414
{% if node.imports %}
401-
<div class="cd-imports">
402-
<div class="cd-imports__label">IMPORTS</div>
415+
<details class="cd-imports">
416+
<summary class="cd-imports__label">IMPORTS ({{ node.imports | length }})</summary>
403417
{% for imp in node.imports %}
404418
<div class="cd-imports__item">→ {{ imp }}</div>
405419
{% endfor %}
406-
</div>
420+
</details>
407421
{% endif %}
408422
{% if node.summary %}
409423
<div class="cd-summary">{{ node.summary }}</div>

codedocent/templates/interactive.html

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,21 @@
293293
text-transform: uppercase;
294294
letter-spacing: 0.08em;
295295
color: var(--text-imports-label);
296-
margin-bottom: 4px;
296+
cursor: pointer;
297+
list-style: none;
298+
}
299+
300+
.cd-imports__label::-webkit-details-marker {
301+
display: none;
302+
}
303+
304+
.cd-imports__label::before {
305+
content: "▶ ";
306+
font-size: 9px;
307+
}
308+
309+
.cd-imports[open] > .cd-imports__label::before {
310+
content: "▼ ";
297311
}
298312

299313
.cd-imports__item {
@@ -827,9 +841,9 @@ <h1 class="cd-header__title">codedocent</h1>
827841

828842
// Imports
829843
if (node.imports && node.imports.length > 0) {
830-
const imp = document.createElement('div');
844+
const imp = document.createElement('details');
831845
imp.className = 'cd-imports';
832-
imp.innerHTML = '<div class="cd-imports__label">IMPORTS</div>' +
846+
imp.innerHTML = '<summary class="cd-imports__label">IMPORTS (' + node.imports.length + ')</summary>' +
833847
node.imports.map(i => '<div class="cd-imports__item">\u2192 ' + escapeHtml(i) + '</div>').join('');
834848
body.appendChild(imp);
835849
}

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "codedocent"
7-
version = "0.2.0"
7+
version = "0.2.1"
88
description = "Code visualization for non-programmers"
99
license = "MIT"
1010
requires-python = ">=3.10"

0 commit comments

Comments
 (0)