Skip to content

Replace gallery S/M/L size buttons with a continuous thumbnail size slider#83

Open
Copilot wants to merge 2 commits intomainfrom
copilot/customize-image-gallery-grid
Open

Replace gallery S/M/L size buttons with a continuous thumbnail size slider#83
Copilot wants to merge 2 commits intomainfrom
copilot/customize-image-gallery-grid

Conversation

Copy link
Contributor

Copilot AI commented Mar 18, 2026

The image gallery only offered three fixed grid sizes (S/M/L). This adds a continuous slider (100–500px) that simultaneously controls thumbnail size and images-per-row via CSS grid's auto-fill.

State & persistence

  • New thumbnailSize field (default 220px) added to gallery state defaults and persisted in localStorage alongside viewMode
  • viewMode simplified to 'grid' | 'list'; legacy 'small'/'medium'/'large' values are migrated transparently via loadGalleryStateWithDefaults

Grid rendering

  • GalleryGridView now accepts thumbnailSize and applies it as an inline style instead of CSS class switching:
    { gridTemplateColumns: `repeat(auto-fill, minmax(${thumbnailSize}px, 1fr))` }
  • imagesPerPage scales inversely: Math.max(12, Math.round(15000 / thumbnailSize))

UI

  • S/M/L buttons replaced with a <input type="range" min=100 max=500 step=10> slider with a live pixel readout
  • List-view toggle button remains unchanged

Tests

  • Updated ImageGallery tests to use the slider and new state shape
  • Added 7 migration tests to galleryState.test.js covering all legacy viewMode values
Original prompt

This section details on the original issue you should resolve

<issue_title>Image Gallery Customizations</issue_title>
<issue_description>Allow the user to customize the grid view:

  • How many images appear in a row
  • How big the images are (there are already small, medium, large options but it would be nice to go larger)

Perhaps this is just one control, a slider to scale image size and as the images get larger the number in a row gets smaller and vice versa.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

…ze slider

- Add `thumbnailSize` (default 220) to gallery state defaults
- Change `viewMode` default to 'grid'; migrate legacy 'small'/'medium'/'large' values
- Replace S/M/L buttons with a range slider (100-500px) in ImageGallery
- Apply thumbnail size via inline gridTemplateColumns style in GalleryGridView
- Compute imagesPerPage dynamically from thumbnailSize
- Add CSS for slider control (.thumbnail-size-control, .thumbnail-size-slider, .thumbnail-size-label)
- Update ImageGallery tests; add 7 new migration tests to galleryState.test.js

Co-authored-by: travisdock <36681963+travisdock@users.noreply.github.com>
Copilot AI changed the title [WIP] Add customization options for image gallery grid view Replace gallery S/M/L size buttons with a continuous thumbnail size slider Mar 18, 2026
Copilot AI requested a review from travisdock March 18, 2026 14:44
@travisdock travisdock marked this pull request as ready for review March 18, 2026 17:41
Copilot AI review requested due to automatic review settings March 18, 2026 17:41
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the image gallery UI/state model to replace discrete S/M/L grid sizes with a continuous thumbnail-size slider, while keeping list-view as a separate mode and migrating legacy persisted state.

Changes:

  • Adds thumbnailSize to persisted gallery state (default 220) and migrates legacy viewMode values (small/medium/large) to viewMode='grid' + mapped thumbnailSize.
  • Replaces S/M/L buttons with a range slider and updates pagination sizing based on thumbnailSize.
  • Updates grid rendering to use CSS grid auto-fill with an inline gridTemplateColumns, and updates/extends unit tests for the new state + migration behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
frontend/src/utils/galleryState.js Adds defaults + migration logic for thumbnailSize and legacy viewMode values.
frontend/src/utils/tests/galleryState.test.js Adds migration test coverage for loadGalleryStateWithDefaults.
frontend/src/components/tests/ImageGallery.test.js Updates persistence/restoration tests to use the slider + new state shape.
frontend/src/components/ImageGallery.js Wires new slider UI, persists thumbnailSize, and updates imagesPerPage logic.
frontend/src/components/GalleryGridView.js Applies thumbnailSize via inline CSS grid template columns.
frontend/src/App.css Adds styling for the thumbnail size slider control in the header.

Comment on lines +58 to 60
const imagesPerPage = viewMode === 'list' ? 200 : Math.max(12, Math.round(IMAGES_PER_PAGE_SCALE / thumbnailSize));

const filteredImages = sortImages(
onImageLoadStatusChange,
}) {
const gridStyle = viewMode !== 'list'
? { gridTemplateColumns: `repeat(auto-fill, minmax(${thumbnailSize}px, 1fr))` }
Comment on lines 47 to +60
function loadGalleryStateWithDefaults(key) {
return { ...GALLERY_STATE_DEFAULTS, ...loadGalleryState(key) };
const saved = loadGalleryState(key);
const merged = { ...GALLERY_STATE_DEFAULTS, ...saved };

// Migrate old named viewMode values to 'grid' + thumbnailSize
const legacySizeMap = { small: 150, medium: 220, large: 300 };
if (legacySizeMap[merged.viewMode] !== undefined) {
if (saved.thumbnailSize === undefined) {
merged.thumbnailSize = legacySizeMap[merged.viewMode];
}
merged.viewMode = 'grid';
}

return merged;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Image Gallery Customizations

3 participants