Skip to content

Commit 03e7eba

Browse files
Separate and collapse CSV column selector card (#123)
### Motivation - Improve the CSV Row Viewer UI by separating column selection from row browsing so the controls are clearer and less crowded. - Make the column selector collapsible and collapsed by default to reduce visual noise for users who only want to view rows. - Display column checkboxes in a single vertical list with the checkbox on the left for clear, accessible selection. ### Description - Moved the column selection UI out of the `#viewer` card into a new `#column-selector` card that contains a `<details>` block with a `summary` titled "Column selection" so it is collapsed by default. - Removed the inline column-filter markup from `#viewer` and added `#column-filter-card` and `#column-checkboxes` inside the new `#column-selector` markup. - Adjusted CSS to make the checkbox list vertical (`.column-checkboxes { grid-template-columns: 1fr; }`) and added `.column-filter-details>summary` styles to indicate the collapsible header. - Updated JavaScript to reference the new `columnSelector` element and show/hide `columnSelector` together with `columnFilterCard` during CSV load and on parse errors, preserving existing checkbox and "select all" behavior. ------ [Codex Task](https://chatgpt.com/codex/tasks/task_e_69c3c3f0a4f08325a4678927023530b4)
1 parent 3b3d7b6 commit 03e7eba

1 file changed

Lines changed: 26 additions & 17 deletions

File tree

csv-row-viewer.html

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@
6666
.column-filter-card {
6767
display: grid;
6868
gap: 1rem;
69-
margin-bottom: 1.25rem;
70-
padding: 1rem;
71-
border: 1px solid var(--border-subtle, #d0d5dd);
72-
border-radius: 0.75rem;
73-
background: var(--background-subtle, #f8f9fb);
7469
}
7570

7671
.column-filter-header {
@@ -84,7 +79,12 @@
8479
.column-checkboxes {
8580
display: grid;
8681
gap: 0.5rem;
87-
grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
82+
grid-template-columns: 1fr;
83+
}
84+
85+
.column-filter-details>summary {
86+
cursor: pointer;
87+
font-weight: 700;
8888
}
8989

9090
.checkbox-row {
@@ -126,23 +126,28 @@ <h1>CSV Row Viewer</h1>
126126
<p id="load-status" class="status" aria-live="polite">No file loaded.</p>
127127
</section>
128128

129+
<section id="column-selector" class="surface tool-card" hidden>
130+
<details id="column-filter-details" class="column-filter-details">
131+
<summary>Column selection</summary>
132+
<div id="column-filter-card" class="column-filter-card" hidden>
133+
<div class="column-filter-header">
134+
<strong>Visible columns</strong>
135+
<label class="checkbox-row" for="toggle-all-columns">
136+
<input id="toggle-all-columns" type="checkbox">
137+
<span>Select all</span>
138+
</label>
139+
</div>
140+
<div id="column-checkboxes" class="column-checkboxes"></div>
141+
</div>
142+
</details>
143+
</section>
144+
129145
<section id="viewer" class="surface tool-card" hidden>
130146
<div class="meta">
131147
<span id="row-indicator">Row 1 of 1</span>
132148
<span id="file-summary"></span>
133149
</div>
134150

135-
<div id="column-filter-card" class="column-filter-card" hidden>
136-
<div class="column-filter-header">
137-
<strong>Visible columns</strong>
138-
<label class="checkbox-row" for="toggle-all-columns">
139-
<input id="toggle-all-columns" type="checkbox">
140-
<span>Select all</span>
141-
</label>
142-
</div>
143-
<div id="column-checkboxes" class="column-checkboxes"></div>
144-
</div>
145-
146151
<div class="table-container" aria-live="polite">
147152
<table>
148153
<thead>
@@ -183,6 +188,7 @@ <h1>CSV Row Viewer</h1>
183188
const nextButton = document.getElementById('next-row');
184189
const jumpInput = document.getElementById('jump-row');
185190
const jumpButton = document.getElementById('jump-button');
191+
const columnSelector = document.getElementById('column-selector');
186192
const columnFilterCard = document.getElementById('column-filter-card');
187193
const columnCheckboxes = document.getElementById('column-checkboxes');
188194
const toggleAllColumns = document.getElementById('toggle-all-columns');
@@ -285,10 +291,12 @@ <h1>CSV Row Viewer</h1>
285291

286292
const renderColumnFilters = () => {
287293
if (!columnLabels.length) {
294+
columnSelector.hidden = true;
288295
columnFilterCard.hidden = true;
289296
return;
290297
}
291298

299+
columnSelector.hidden = false;
292300
columnFilterCard.hidden = false;
293301
columnCheckboxes.innerHTML = columnLabels.map((label, index) => `
294302
<label class="checkbox-row" for="column-toggle-${index}">
@@ -342,6 +350,7 @@ <h1>CSV Row Viewer</h1>
342350
renderRow();
343351
} catch (error) {
344352
viewer.hidden = true;
353+
columnSelector.hidden = true;
345354
headers = [];
346355
rows = [];
347356
columnLabels = [];

0 commit comments

Comments
 (0)