Skip to content

Commit 249ba4f

Browse files
ildyriad7415
andauthored
Add option to hide photo action dock instead of transparency (#3804)
Co-authored-by: Martin Stone <[email protected]>
1 parent c7453ad commit 249ba4f

File tree

7 files changed

+131
-21
lines changed

7 files changed

+131
-21
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
/**
4+
* SPDX-License-Identifier: MIT
5+
* Copyright (c) 2017-2018 Tobias Reich
6+
* Copyright (c) 2018-2025 LycheeOrg.
7+
*/
8+
9+
namespace App\Http\Resources\Embed;
10+
11+
use App\Models\Album;
12+
use Spatie\LaravelData\Data;
13+
use Spatie\TypeScriptTransformer\Attributes\TypeScript;
14+
15+
/**
16+
* Resource for embedding album data on external websites.
17+
*
18+
* Provides minimal album information and photo collection optimized for
19+
* external embedding. Includes only publicly visible data.
20+
*/
21+
#[TypeScript()]
22+
class EmbedAlbumInfo extends Data
23+
{
24+
public function __construct(
25+
public string $id,
26+
public string $title,
27+
public ?string $description,
28+
public int $photo_count,
29+
public ?string $copyright,
30+
public ?string $license,
31+
) {
32+
}
33+
34+
/**
35+
* Create resource from Album model.
36+
*
37+
* @param Album $album The album model
38+
*
39+
* @return self
40+
*/
41+
public static function fromModel(Album $album): self
42+
{
43+
return new self(
44+
id: $album->id,
45+
title: $album->title,
46+
description: $album->description,
47+
photo_count: $album->photos_count ?? $album->photos->count(),
48+
copyright: $album->copyright,
49+
license: $album->license?->localization(),
50+
);
51+
}
52+
}

app/Http/Resources/Embed/EmbedAlbumResource.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,14 @@
2323
#[TypeScript()]
2424
class EmbedAlbumResource extends Data
2525
{
26-
/** @var array<string, mixed> */
27-
public array $album;
26+
public EmbedAlbumInfo $album;
2827
/** @var Collection<int, EmbedPhotoResource> */
2928
#[LiteralTypeScriptType('App.Http.Resources.Embed.EmbedPhotoResource[]')]
3029
public Collection $photos;
3130

3231
public function __construct(Album $album)
3332
{
34-
$this->album = [
35-
'id' => $album->id,
36-
'title' => $album->title,
37-
'description' => $album->description,
38-
'photo_count' => $album->photos_count ?? $album->photos->count(),
39-
'copyright' => $album->copyright,
40-
'license' => $album->license?->localization(),
41-
];
42-
33+
$this->album = EmbedAlbumInfo::fromModel($album);
4334
$this->photos = $album->photos->map(fn ($photo) => EmbedPhotoResource::fromModel($photo));
4435
}
4536

app/Http/Resources/GalleryConfigs/InitConfig.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ class InitConfig extends Data
4747
public bool $is_favourite_enabled;
4848
public SmallLargeType $photo_previous_next_size;
4949
public bool $is_details_links_enabled;
50+
public bool $is_desktop_dock_full_transparency_enabled;
51+
public bool $is_mobile_dock_full_transparency_enabled;
5052

5153
// Thumbs configuration
5254
public ThumbOverlayVisibilityType $display_thumb_album_overlay;
@@ -130,6 +132,8 @@ public function __construct()
130132
if (Configs::getValueAsBool('details_links_enabled')) {
131133
$this->is_details_links_enabled = !Auth::guest() || Configs::getValueAsBool('details_links_public');
132134
}
135+
$this->is_desktop_dock_full_transparency_enabled = Configs::getValueAsBool('desktop_dock_full_transparency_enabled');
136+
$this->is_mobile_dock_full_transparency_enabled = Configs::getValueAsBool('mobile_dock_full_transparency_enabled');
133137

134138
// Thumbs configuration
135139
$this->display_thumb_album_overlay = Configs::getValueAsEnum('display_thumb_album_overlay', ThumbOverlayVisibilityType::class);
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
/**
4+
* SPDX-License-Identifier: MIT
5+
* Copyright (c) 2017-2018 Tobias Reich
6+
* Copyright (c) 2018-2025 LycheeOrg.
7+
*/
8+
9+
use App\Models\Extensions\BaseConfigMigration;
10+
11+
return new class() extends BaseConfigMigration {
12+
public const MOD_GALLERY = 'Gallery';
13+
14+
/**
15+
* @return array<int,array{key:string,value:string,is_secret:bool,cat:string,type_range:string,description:string,order?:int,not_on_docker?:bool,is_expert?:bool}>
16+
*/
17+
public function getConfigs(): array
18+
{
19+
return [
20+
[
21+
'key' => 'desktop_dock_full_transparency_enabled',
22+
'value' => '0',
23+
'cat' => self::MOD_GALLERY,
24+
'type_range' => self::BOOL,
25+
'description' => 'Enable full dock transparency for desktop.',
26+
'details' => 'On the photo view, actions at the top of the page are slightly transparent. Enable this to have them fully transparent and only appear on hover.',
27+
'is_secret' => false,
28+
'is_expert' => true,
29+
'order' => 40,
30+
'not_on_docker' => false,
31+
'level' => 0,
32+
],
33+
[
34+
'key' => 'mobile_dock_full_transparency_enabled',
35+
'value' => '0',
36+
'cat' => self::MOD_GALLERY,
37+
'type_range' => self::BOOL,
38+
'description' => 'Enable full dock transparency for mobile.',
39+
'details' => '<span class="pi pi-exclamation-triangle text-orange-500"></span> This will impact usability on mobile. On the photo view, actions at the top of the page are slightly transparent. Enable this to have them fully transparent and only appear on tap.',
40+
'is_secret' => false,
41+
'is_expert' => true,
42+
'order' => 41,
43+
'not_on_docker' => false,
44+
'level' => 0,
45+
],
46+
];
47+
}
48+
};

resources/js/components/gallery/photoModule/Dock.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
v-if="photoStore.photo"
44
:class="{
55
'absolute top-0 w-full sm:w-1/2 left-1/2 -translate-x-1/2': true,
6-
'opacity-50 lg:opacity-20 lg:hover:opacity-100 transition-opacity duration-500 ease-in-out': !isTouchDevice(),
7-
'opacity-75': isTouchDevice(),
6+
'lg:hover:opacity-100 transition-opacity duration-500 ease-in-out': !isTouchDevice(),
7+
'opacity-50 lg:opacity-20': !isTouchDevice() && !lycheeStore.is_desktop_dock_full_transparency_enabled,
8+
'opacity-75': isTouchDevice() && !lycheeStore.is_mobile_dock_full_transparency_enabled,
9+
'opacity-0':
10+
(!isTouchDevice() && lycheeStore.is_desktop_dock_full_transparency_enabled) ||
11+
(isTouchDevice() && lycheeStore.is_mobile_dock_full_transparency_enabled),
812
'z-20 mt-14 sm:mt-0': true,
913
'sm:h-1/4': !props.isNarrowMenu,
1014
'h-14': props.isNarrowMenu,

resources/js/lychee.d.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -255,15 +255,16 @@ declare namespace App.Http.Resources.Editable {
255255
};
256256
}
257257
declare namespace App.Http.Resources.Embed {
258+
export type EmbedAlbumInfo = {
259+
id: string;
260+
title: string;
261+
description: string | null;
262+
photo_count: number;
263+
copyright: string | null;
264+
license: string | null;
265+
};
258266
export type EmbedAlbumResource = {
259-
album: {
260-
id: string;
261-
title: string;
262-
description: string | null;
263-
photo_count: number;
264-
copyright: string | null;
265-
license: string | null;
266-
};
267+
album: App.Http.Resources.Embed.EmbedAlbumInfo;
267268
photos: App.Http.Resources.Embed.EmbedPhotoResource[];
268269
};
269270
export type EmbedPhotoResource = {
@@ -273,6 +274,10 @@ declare namespace App.Http.Resources.Embed {
273274
size_variants: App.Http.Resources.Models.SizeVariantsResouce;
274275
exif: { [key: string]: string | null };
275276
};
277+
export type EmbedStreamResource = {
278+
site_title: string;
279+
photos: App.Http.Resources.Embed.EmbedPhotoResource[];
280+
};
276281
}
277282
declare namespace App.Http.Resources.Flow {
278283
export type FlowItemResource = {
@@ -360,6 +365,8 @@ declare namespace App.Http.Resources.GalleryConfigs {
360365
is_favourite_enabled: boolean;
361366
photo_previous_next_size: App.Enum.SmallLargeType;
362367
is_details_links_enabled: boolean;
368+
is_desktop_dock_full_transparency_enabled: boolean;
369+
is_mobile_dock_full_transparency_enabled: boolean;
363370
display_thumb_album_overlay: App.Enum.ThumbOverlayVisibilityType;
364371
display_thumb_photo_overlay: App.Enum.ThumbOverlayVisibilityType;
365372
album_subtitle_type: App.Enum.ThumbAlbumSubtitleType;

resources/js/stores/LycheeState.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ export const useLycheeStateStore = defineStore("lychee-store", {
3030
is_favourite_enabled: false,
3131
photo_previous_next_size: "small" as App.Enum.SmallLargeType,
3232
is_details_links_enabled: false,
33+
is_desktop_dock_full_transparency_enabled: false,
34+
is_mobile_dock_full_transparency_enabled: false,
3335

3436
// keybinding help
3537
show_keybinding_help_popup: false,
@@ -156,6 +158,8 @@ export const useLycheeStateStore = defineStore("lychee-store", {
156158
this.is_medium2x_download_enabled = data.is_medium2x_download_enabled;
157159
this.photo_previous_next_size = data.photo_previous_next_size;
158160
this.is_details_links_enabled = data.is_details_links_enabled;
161+
this.is_desktop_dock_full_transparency_enabled = data.is_desktop_dock_full_transparency_enabled;
162+
this.is_mobile_dock_full_transparency_enabled = data.is_mobile_dock_full_transparency_enabled;
159163

160164
this.is_registration_enabled = data.is_registration_enabled;
161165

0 commit comments

Comments
 (0)