|
129 | 129 | list.className = 'crumb-list'; |
130 | 130 |
|
131 | 131 | trail.crumbs.forEach((crumb, index) => { |
132 | | - list.appendChild(renderCrumb(crumb, index === trail.crumbs.length - 1, trail.id)); |
| 132 | + list.appendChild(renderCrumb(crumb, index, trail.id)); |
133 | 133 | }); |
134 | 134 |
|
135 | 135 | content.appendChild(list); |
136 | 136 | } |
137 | 137 |
|
138 | | - function renderCrumb(crumb, isLast, trailId) { |
139 | | - const item = document.createElement('div'); |
140 | | - item.className = `crumb-item${isLast ? ' crumb-item--last' : ''}`; |
141 | | - item.dataset.crumbId = crumb.id; |
142 | | - item.dataset.trailId = trailId; |
| 138 | + function renderCrumb(crumb, index, trailId) { |
| 139 | + const details = document.createElement('details'); |
| 140 | + details.className = 'crumb-item'; |
| 141 | + details.dataset.crumbId = crumb.id; |
| 142 | + details.dataset.trailId = trailId; |
| 143 | + if (index === 0) { |
| 144 | + details.open = true; |
| 145 | + } |
| 146 | + |
| 147 | + const summary = document.createElement('summary'); |
| 148 | + summary.className = 'crumb-summary'; |
| 149 | + |
| 150 | + const summaryMeta = document.createElement('div'); |
| 151 | + summaryMeta.className = 'crumb-summary__meta'; |
| 152 | + |
| 153 | + const step = document.createElement('span'); |
| 154 | + step.className = 'crumb-step'; |
| 155 | + step.textContent = `Step ${index + 1}`; |
| 156 | + summaryMeta.appendChild(step); |
| 157 | + |
| 158 | + const title = document.createElement('span'); |
| 159 | + title.className = 'crumb-title'; |
| 160 | + title.textContent = `${crumb.filePath}:${crumb.rangeLabel}`; |
| 161 | + summaryMeta.appendChild(title); |
| 162 | + |
| 163 | + summary.appendChild(summaryMeta); |
143 | 164 |
|
144 | | - const marker = document.createElement('div'); |
145 | | - marker.className = 'crumb-item__marker'; |
146 | | - const markerLabel = document.createElement('span'); |
147 | | - markerLabel.textContent = String(crumb.index + 1); |
148 | | - marker.appendChild(markerLabel); |
149 | | - item.appendChild(marker); |
| 165 | + const preview = document.createElement('span'); |
| 166 | + preview.className = 'crumb-preview'; |
| 167 | + preview.textContent = crumb.note || crumb.snippetPreview || '(no preview)'; |
| 168 | + summary.appendChild(preview); |
| 169 | + |
| 170 | + const chevron = document.createElement('span'); |
| 171 | + chevron.className = 'crumb-chevron'; |
| 172 | + chevron.innerHTML = '▾'; |
| 173 | + summary.appendChild(chevron); |
| 174 | + |
| 175 | + details.appendChild(summary); |
150 | 176 |
|
151 | 177 | const body = document.createElement('div'); |
152 | | - body.className = 'crumb-item__body'; |
| 178 | + body.className = 'crumb-body'; |
153 | 179 |
|
154 | | - const header = document.createElement('div'); |
155 | | - header.className = 'crumb-item__header'; |
156 | | - const path = document.createElement('span'); |
157 | | - path.className = 'crumb-item__path'; |
158 | | - path.textContent = `${crumb.filePath}:${crumb.rangeLabel}`; |
159 | | - header.appendChild(path); |
160 | | - body.appendChild(header); |
| 180 | + const meta = document.createElement('p'); |
| 181 | + meta.className = 'crumb-meta'; |
| 182 | + const created = new Date(crumb.createdAt).toLocaleString(); |
| 183 | + meta.textContent = `Captured ${created}`; |
| 184 | + body.appendChild(meta); |
161 | 185 |
|
162 | 186 | if (crumb.note) { |
163 | 187 | const note = document.createElement('p'); |
164 | | - note.className = 'crumb-item__note'; |
| 188 | + note.className = 'crumb-note'; |
165 | 189 | note.textContent = crumb.note; |
166 | 190 | body.appendChild(note); |
167 | 191 | } |
168 | 192 |
|
169 | 193 | const snippet = document.createElement('pre'); |
170 | | - snippet.className = 'crumb-item__snippet'; |
| 194 | + snippet.className = 'crumb-snippet'; |
171 | 195 | snippet.textContent = crumb.snippet; |
| 196 | + snippet.addEventListener('click', (event) => { |
| 197 | + event.stopPropagation(); |
| 198 | + vscode.postMessage({ type: 'openCrumb', trailId, crumbId: crumb.id }); |
| 199 | + }); |
172 | 200 | body.appendChild(snippet); |
173 | 201 |
|
174 | | - const meta = document.createElement('p'); |
175 | | - meta.className = 'crumb-item__meta'; |
176 | | - const created = new Date(crumb.createdAt).toLocaleString(); |
177 | | - meta.textContent = `Captured ${created}`; |
178 | | - body.appendChild(meta); |
179 | | - |
180 | | - body.addEventListener('click', () => { |
181 | | - vscode.postMessage({ type: 'openCrumb', trailId, crumbId: crumb.id }); |
| 202 | + details.addEventListener('toggle', () => { |
| 203 | + if (details.open) { |
| 204 | + chevron.innerHTML = '▾'; |
| 205 | + } else { |
| 206 | + chevron.innerHTML = '▸'; |
| 207 | + } |
182 | 208 | }); |
183 | 209 |
|
184 | | - item.appendChild(body); |
| 210 | + chevron.innerHTML = details.open ? '▾' : '▸'; |
| 211 | + details.appendChild(body); |
185 | 212 |
|
186 | | - return item; |
| 213 | + return details; |
187 | 214 | } |
188 | 215 |
|
189 | 216 | vscode.postMessage({ type: 'ready' }); |
|
0 commit comments