Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@simple-photo-gallery/common",
"version": "2.1.4",
"version": "2.1.5",
"description": "Shared utilities and types for Simple Photo Gallery",
"license": "MIT",
"author": "Vladimir Haltakov, Tomasz Rusin",
Expand Down
20 changes: 8 additions & 12 deletions common/src/client/photoswipe/lightbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,13 @@ export interface GalleryLightboxOptions {
const CAPTION_SAMPLE_SIZE = 50;
const CAPTION_SAMPLE_HEIGHT_RATIO = 0.15;

/* Caption background endpoints for brightness interpolation (0=dark image, 1=light image) */
const CAPTION_BG_DARK = { r: 255, g: 255, b: 255, a: 0.5 }; // white frost on dark images
const CAPTION_BG_LIGHT = { r: 0, g: 0, b: 0, a: 0.8 }; // dark frost on light images

function interpolateCaptionBg(brightness: number): string {
const t = Math.min(1, Math.max(0, brightness / 255));
const r = Math.round(CAPTION_BG_DARK.r + (CAPTION_BG_LIGHT.r - CAPTION_BG_DARK.r) * t);
const g = Math.round(CAPTION_BG_DARK.g + (CAPTION_BG_LIGHT.g - CAPTION_BG_DARK.g) * t);
const b = Math.round(CAPTION_BG_DARK.b + (CAPTION_BG_LIGHT.b - CAPTION_BG_DARK.b) * t);
const a = +(CAPTION_BG_DARK.a + (CAPTION_BG_LIGHT.a - CAPTION_BG_DARK.a) * t).toFixed(3);
return `rgba(${r}, ${g}, ${b}, ${a})`;
/* Caption backgrounds chosen based on image brightness */
const CAPTION_BG_DARK = 'rgba(255, 255, 255, 0.5)'; // white frost on dark images
const CAPTION_BG_LIGHT = 'rgba(0, 0, 0, 0.8)'; // dark frost on light images
const BRIGHTNESS_THRESHOLD = 80;

function captionBgForBrightness(brightness: number): string {
return brightness >= BRIGHTNESS_THRESHOLD ? CAPTION_BG_LIGHT : CAPTION_BG_DARK;
}

/**
Expand Down Expand Up @@ -168,7 +164,7 @@ export async function createGalleryLightbox(options: GalleryLightboxOptions = {}
if (brightness === null) {
el.style.removeProperty('--pswp-caption-bg');
} else {
el.style.setProperty('--pswp-caption-bg', interpolateCaptionBg(brightness));
el.style.setProperty('--pswp-caption-bg', captionBgForBrightness(brightness));
}
};

Expand Down
6 changes: 3 additions & 3 deletions gallery/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simple-photo-gallery",
"version": "2.1.4",
"version": "2.1.5",
"description": "Simple Photo Gallery CLI",
"license": "MIT",
"author": "Vladimir Haltakov, Tomasz Rusin",
Expand Down Expand Up @@ -47,8 +47,8 @@
"prepublish": "yarn build"
},
"dependencies": {
"@simple-photo-gallery/common": "2.1.4",
"@simple-photo-gallery/theme-modern": "2.1.4",
"@simple-photo-gallery/common": "2.1.5",
"@simple-photo-gallery/theme-modern": "2.1.5",
"axios": "^1.12.2",
"blurhash": "^2.0.5",
"commander": "^12.0.0",
Expand Down
4 changes: 2 additions & 2 deletions gallery/src/modules/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,10 @@ export async function build(options: BuildOptions, ui: ConsolaInstance): Promise
} else if (error.message.includes('Theme directory not found') || error.message.includes('package.json not found')) {
ui.error(error.message);
} else {
ui.error('Error building gallery');
ui.error(`Error building gallery: ${error.message}`);
}
} else {
ui.error('Error building gallery');
ui.error(`Error building gallery: ${error}`);
}

throw error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"photoswipe": "^5.4.4"
},
"peerDependencies": {
"@simple-photo-gallery/common": "^2.1.4"
"@simple-photo-gallery/common": "^2.1.5"
},
"devDependencies": {
"@eslint/eslintrc": "^3.3.1",
Expand Down
4 changes: 2 additions & 2 deletions themes/modern/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@simple-photo-gallery/theme-modern",
"version": "2.1.4",
"version": "2.1.5",
"description": "Modern theme for Simple Photo Gallery",
"license": "MIT",
"author": "Vladimir Haltakov, Tomasz Rusin",
Expand Down Expand Up @@ -36,7 +36,7 @@
"devDependencies": {
"@eslint/eslintrc": "^3.3.1",
"@eslint/js": "^9.30.1",
"@simple-photo-gallery/common": "2.1.4",
"@simple-photo-gallery/common": "2.1.5",
"@types/photoswipe": "^4.1.6",
"@typescript-eslint/eslint-plugin": "^8.35.1",
"@typescript-eslint/parser": "^8.35.1",
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1652,7 +1652,7 @@ __metadata:
languageName: node
linkType: hard

"@simple-photo-gallery/common@npm:2.1.4, @simple-photo-gallery/common@workspace:common":
"@simple-photo-gallery/common@npm:2.1.5, @simple-photo-gallery/common@workspace:common":
version: 0.0.0-use.local
resolution: "@simple-photo-gallery/common@workspace:common"
dependencies:
Expand Down Expand Up @@ -1687,13 +1687,13 @@ __metadata:
languageName: unknown
linkType: soft

"@simple-photo-gallery/theme-modern@npm:2.1.4, @simple-photo-gallery/theme-modern@workspace:themes/modern":
"@simple-photo-gallery/theme-modern@npm:2.1.5, @simple-photo-gallery/theme-modern@workspace:themes/modern":
version: 0.0.0-use.local
resolution: "@simple-photo-gallery/theme-modern@workspace:themes/modern"
dependencies:
"@eslint/eslintrc": "npm:^3.3.1"
"@eslint/js": "npm:^9.30.1"
"@simple-photo-gallery/common": "npm:2.1.4"
"@simple-photo-gallery/common": "npm:2.1.5"
"@types/photoswipe": "npm:^4.1.6"
"@typescript-eslint/eslint-plugin": "npm:^8.35.1"
"@typescript-eslint/parser": "npm:^8.35.1"
Expand Down Expand Up @@ -8570,8 +8570,8 @@ __metadata:
dependencies:
"@eslint/eslintrc": "npm:^3.3.1"
"@eslint/js": "npm:^9.30.1"
"@simple-photo-gallery/common": "npm:2.1.4"
"@simple-photo-gallery/theme-modern": "npm:2.1.4"
"@simple-photo-gallery/common": "npm:2.1.5"
"@simple-photo-gallery/theme-modern": "npm:2.1.5"
"@types/fs-extra": "npm:^11.0.4"
"@types/jest": "npm:^30.0.0"
"@types/node": "npm:^24.0.10"
Expand Down