feat: add justified/rows layout mode to masonry gallery (#146)

Add Google Photos-style justified row layout as a mode within masonry:

- Add masonryMode setting: 'columns' (Pinterest) or 'rows' (Google Photos)
- Create justifiedLayoutCalculator utility for row-based layouts
- Extract and store image dimensions on upload for layout calculations
- Include width/height in gallery API response
- Add row height and last row behavior controls to theme customizer
- Support responsive container width detection with ResizeObserver

Photos in rows mode maintain their aspect ratios while filling
horizontal rows at a consistent height. The number of photos per
row is automatically calculated based on target row height and
photo dimensions.

Closes #146
This commit is contained in:
Paul Nothaft
2026-01-27 09:58:09 +01:00
parent 85170b883f
commit e081b56a44
10 changed files with 666 additions and 20 deletions
+8 -2
View File
@@ -15,7 +15,10 @@ export interface GalleryLayoutSettings {
};
// Masonry specific
masonryMode?: 'columns' | 'rows'; // columns = Pinterest-style, rows = Google Photos-style
masonryGutter?: number;
masonryRowHeight?: number; // Target row height for rows mode (150-400)
masonryLastRowBehavior?: 'justify' | 'left' | 'center'; // How to align incomplete last row
// Carousel specific
carouselAutoplay?: boolean;
@@ -127,7 +130,7 @@ export const GALLERY_THEME_PRESETS: Record<string, EventTheme> = {
modernMasonry: {
name: 'Modern Masonry',
description: 'Pinterest-style dynamic layout',
description: 'Pinterest-style columns or Google Photos-style rows',
config: {
primaryColor: '#3b82f6',
accentColor: '#1e40af',
@@ -139,7 +142,10 @@ export const GALLERY_THEME_PRESETS: Record<string, EventTheme> = {
gallerySettings: {
spacing: 'tight',
photoAnimation: 'fade',
masonryGutter: 16
masonryMode: 'columns',
masonryGutter: 16,
masonryRowHeight: 250,
masonryLastRowBehavior: 'left'
},
headerStyle: 'minimal',
footerStyle: 'minimal',