Skip to content

Commit 6fe5c81

Browse files
committed
Add manual column number configuration and make styles more consistent
1 parent 329bac7 commit 6fe5c81

File tree

6 files changed

+260
-27
lines changed

6 files changed

+260
-27
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
**/out/
44
src/test/samples/env/
55
src/test/samples/folder*
6-
.vscode-test-web/
6+
.vscode-test-web/
7+
.vscode-test/

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
"watch-tests": "tsc -p . -w --outDir dist",
118118
"pretest": "npm run compile-tests && npm run compile && npm run lint",
119119
"lint": "eslint src --ext ts",
120-
"test": "node ./out/test/runTest.js"
120+
"test": "node ./dist/test/runTest.js"
121121
},
122122
"devDependencies": {
123123
"@types/glob": "^7.2.0",

src/gallery/gallery.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,16 @@ class GalleryWebview {
105105
});
106106
break;
107107

108+
case "POST.gallery.updateColumnCount":
109+
webview.postMessage({
110+
command: "POST.gallery.setColumnCount",
111+
columnCount: message.columnCount
112+
});
113+
reporter.sendTelemetryEvent(`${telemetryPrefix}.updateColumnCount`, {
114+
'columnCount': message.columnCount.toString()
115+
});
116+
break;
117+
108118
case "POST.gallery.requestSort":
109119
this.gFolders = this.customSorter.sort(this.gFolders, message.valueName, message.ascending);
110120
reporter.sendTelemetryEvent(`${telemetryPrefix}.requestSort`, {

src/gallery/script.js

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ function initMessageListeners() {
2929
DOMManager.updateGlobalDoms(message);
3030
DOMManager.updateGalleryContent();
3131
break;
32+
case "POST.gallery.setColumnCount":
33+
updateColumnCount(message.columnCount);
34+
break;
3235
}
3336
});
3437
}
@@ -306,6 +309,72 @@ class EventListener {
306309
}
307310
}
308311

312+
// Column control functionality
313+
const columnInput = document.getElementById('column-count');
314+
const columnArrows = document.querySelectorAll('.column-arrow');
315+
const autoCheckbox = document.getElementById('auto-columns');
316+
317+
function updateColumnCount(count) {
318+
const grids = document.querySelectorAll('.grid');
319+
grids.forEach(grid => {
320+
if (autoCheckbox.checked) {
321+
grid.style.removeProperty('--column-count');
322+
grid.style.removeProperty('--column-width');
323+
} else {
324+
grid.style.setProperty('--column-count', count);
325+
grid.style.setProperty('--column-width', '1fr');
326+
}
327+
});
328+
}
329+
330+
// Update column input and arrows state based on auto checkbox
331+
function updateColumnControlState() {
332+
const isAuto = autoCheckbox.checked;
333+
columnInput.disabled = isAuto;
334+
columnArrows.forEach(arrow => arrow.disabled = isAuto);
335+
updateColumnCount(isAuto ? null : columnInput.value);
336+
}
337+
338+
columnInput.addEventListener('change', (e) => {
339+
if (autoCheckbox.checked) {return;}
340+
const value = Math.min(Math.max(parseInt(e.target.value) || 1, 1), 100);
341+
e.target.value = value;
342+
vscode.postMessage({
343+
command: 'POST.gallery.updateColumnCount',
344+
columnCount: value
345+
});
346+
updateColumnCount(value);
347+
});
348+
349+
columnArrows.forEach(arrow => {
350+
arrow.addEventListener('click', () => {
351+
if (autoCheckbox.checked) {return;}
352+
const currentValue = parseInt(columnInput.value) || 1;
353+
const direction = arrow.dataset.direction;
354+
const newValue = direction === 'up'
355+
? Math.min(currentValue + 1, 100)
356+
: Math.max(currentValue - 1, 1);
357+
358+
columnInput.value = newValue;
359+
vscode.postMessage({
360+
command: 'POST.gallery.updateColumnCount',
361+
columnCount: newValue
362+
});
363+
updateColumnCount(newValue);
364+
});
365+
});
366+
367+
autoCheckbox.addEventListener('change', () => {
368+
updateColumnControlState();
369+
vscode.postMessage({
370+
command: 'POST.gallery.updateColumnCount',
371+
columnCount: autoCheckbox.checked ? null : columnInput.value
372+
});
373+
});
374+
375+
// Initialize column control state
376+
updateColumnControlState();
377+
309378
(function () {
310379
init();
311380
}());

0 commit comments

Comments
 (0)