Skip to content

Commit 3cec0fe

Browse files
Refactor mode table UI and update logic
- Enhanced table layout and styling for modes display (CSS and JSX) - Refactored vote/download count update logic for clarity and reusability - Updated Archie mode description for improved clarity and detail
1 parent c723c6a commit 3cec0fe

File tree

4 files changed

+82
-34
lines changed

4 files changed

+82
-34
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"author": "spoon",
3-
"description": "This mode is made for code review and stuff",
4-
"date": "2025-07-20"
2+
"author": "spoon",
3+
"description": "Archie is a mode for architectural guidance, enforcing system-wide principles, maintainability, and risk mitigation in modern web applications. It provides step-by-step, machine-readable implementation plans and challenges technical debt, acting as a lead software architect for the codebase.",
4+
"date": "2025-07-20"
55
}

packages/openmodes/src/index.css

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -186,17 +186,65 @@ header {
186186
}
187187
}
188188

189-
table {
190-
border-collapse: separate;
191-
border-spacing: 0;
192-
font-size: 0.875rem;
189+
table.table-modes {
193190
width: 100%;
191+
border-collapse: collapse;
192+
table-layout: fixed;
193+
font-size: 0.875rem;
194194
margin-top: var(--header-height);
195-
max-width: 1200px;
195+
max-width: 1280px;
196196
margin-left: auto;
197197
margin-right: auto;
198198
}
199199

200+
.table-modes th,
201+
.table-modes td {
202+
padding: 0.75rem;
203+
text-align: left;
204+
border-bottom: 1px solid var(--color-border);
205+
}
206+
207+
/* Left block: Name and Author */
208+
.table-modes th.name,
209+
.table-modes td.name {
210+
width: 120px;
211+
}
212+
213+
.table-modes th.author,
214+
.table-modes td.author {
215+
width: 120px;
216+
}
217+
218+
/* Center: Description takes remaining space */
219+
.table-modes th.description,
220+
.table-modes td.description {
221+
width: auto;
222+
max-width: 300px;
223+
overflow: hidden;
224+
text-overflow: ellipsis;
225+
white-space: nowrap;
226+
padding-right: 2.5rem;
227+
}
228+
229+
/* Right block: Votes, Downloads, Updated */
230+
.table-modes th.votes,
231+
.table-modes td.votes {
232+
width: 100px;
233+
text-align: left;
234+
}
235+
236+
.table-modes th.downloads,
237+
.table-modes td.downloads {
238+
width: 130px;
239+
text-align: left;
240+
}
241+
242+
.table-modes th.updated,
243+
.table-modes td.updated {
244+
width: 120px;
245+
text-align: left;
246+
}
247+
200248
table thead th {
201249
position: sticky;
202250
top: var(--header-height);
@@ -254,12 +302,6 @@ tbody tr {
254302
overflow: hidden;
255303
text-overflow: ellipsis;
256304
}
257-
258-
.votes {
259-
font-weight: 500;
260-
color: var(--color-text);
261-
font-family: var(--font-mono);
262-
}
263305
}
264306

265307
dialog::backdrop {

packages/openmodes/src/index.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,7 @@ async function vote(direction: 'up' | 'down') {
385385

386386
if (call === apiCalls[apiCalls.length - 1]) {
387387
const result = await response.json();
388-
updateVoteCount(result.newVoteCount, modeId);
389-
}
388+
updateCountUI('votes', result.newVoteCount, modeId); }
390389
}
391390
} catch (error) {
392391
console.error('Failed to vote:', error);
@@ -437,15 +436,18 @@ function setButtonsDisabled(disabled: boolean) {
437436
}
438437
}
439438

440-
function updateVoteCount(newCount: number, modeId: string) {
441-
currentMode.votes = newCount;
442-
DOMElements.voteCountEl.textContent = newCount.toString();
443-
439+
function updateCountUI(type: 'votes' | 'downloads', newCount: number, modeId: string) {
440+
if (!currentMode) return;
441+
currentMode[type] = newCount;
442+
const modalCountEl = type === 'votes' ? DOMElements.voteCountEl : DOMElements.downloadCountEl;
443+
modalCountEl.textContent = newCount.toString();
444444
const tableRow = document.querySelector(`tr[data-mode-id="${modeId}"]`);
445-
const votesCell = tableRow?.querySelector('.votes');
446-
if (votesCell) votesCell.textContent = newCount.toString();
445+
const cellClass = type;
446+
const cell = tableRow?.querySelector(`.${cellClass}`);
447+
if (cell) cell.textContent = newCount.toString();
447448
}
448449

450+
449451
async function downloadMode() {
450452
if (!currentMode) return;
451453

@@ -490,6 +492,8 @@ function downloadFile(blob: Blob, filename: string) {
490492
URL.revokeObjectURL(url);
491493
}
492494

495+
496+
493497
async function updateDownloadCount(modeId: string) {
494498
try {
495499
const countResponse = await fetch('/api/download', {
@@ -500,9 +504,7 @@ async function updateDownloadCount(modeId: string) {
500504

501505
if (countResponse.ok) {
502506
const result = await countResponse.json();
503-
currentMode.downloads = result.newDownloadCount;
504-
DOMElements.downloadCountEl.textContent =
505-
result.newDownloadCount.toString();
507+
updateCountUI('downloads', result.newDownloadCount, modeId);
506508
UserDataManager.setDownloadStatus(modeId);
507509
DOMElements.downloadBtn.classList.add('downloaded');
508510
}

packages/openmodes/src/render.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -286,22 +286,25 @@ export function getRenderWithCurrentVotes() {
286286
<button id='help'>How to use</button>
287287
</div>
288288
</header>
289-
<table>
289+
<table class='table-modes'>
290290
<thead>
291291
<tr>
292-
<th class='sortable' data-type='text'>
292+
<th class='name sortable' data-type='text'>
293293
Name <span class='sort-indicator'></span>
294294
</th>
295-
<th class='sortable' data-type='text'>
295+
<th class='author sortable' data-type='text'>
296296
Author <span class='sort-indicator'></span>
297297
</th>
298-
<th class='sortable' data-type='text'>
298+
<th class='description sortable' data-type='text'>
299299
Description <span class='sort-indicator'></span>
300300
</th>
301-
<th class='sortable' data-type='number'>
301+
<th class='votes sortable' data-type='number'>
302302
Votes <span class='sort-indicator'></span>
303303
</th>
304-
<th class='sortable' data-type='text'>
304+
<th class='downloads sortable' data-type='number'>
305+
Downloads <span class='sort-indicator'></span>
306+
</th>
307+
<th class='updated sortable' data-type='text'>
305308
Updated <span class='sort-indicator'></span>
306309
</th>
307310
</tr>
@@ -316,11 +319,12 @@ export function getRenderWithCurrentVotes() {
316319
data-mode-id={modeId}
317320
onclick='openModeModal(this)'
318321
>
319-
<td class='mode-name'>{mode.name}</td>
320-
<td>{mode.author}</td>
322+
<td class='name mode-name'>{mode.name}</td>
323+
<td class='author'>{mode.author}</td>
321324
<td class='description'>{mode.description}</td>
322325
<td class='votes'>{mode.votes}</td>
323-
<td>{mode.updated_at}</td>
326+
<td class='downloads'>{mode.downloads}</td>
327+
<td class='updated'>{mode.updated_at}</td>
324328
</tr>
325329
))}
326330
</tbody>

0 commit comments

Comments
 (0)