diff --git a/app/Http/Requests/Admin/ValidatesPreregistrationPageInput.php b/app/Http/Requests/Admin/ValidatesPreregistrationPageInput.php index 6dceb65..2d28d69 100644 --- a/app/Http/Requests/Admin/ValidatesPreregistrationPageInput.php +++ b/app/Http/Requests/Admin/ValidatesPreregistrationPageInput.php @@ -23,6 +23,7 @@ trait ValidatesPreregistrationPageInput 'post_submit_redirect_url' => ['nullable', 'string', 'url:http,https', 'max:500'], 'background_overlay_color' => ['nullable', 'string', 'regex:/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/'], 'background_overlay_opacity' => ['nullable', 'integer', 'min:0', 'max:100'], + 'background_fixed' => ['sometimes', 'boolean'], 'page_background' => ['nullable', 'file', 'image', 'mimes:jpeg,png,jpg,webp', 'max:5120'], 'remove_page_background' => ['sometimes', 'boolean'], 'start_date' => ['required', 'date'], @@ -69,6 +70,7 @@ trait ValidatesPreregistrationPageInput $this->merge([ 'is_active' => $this->boolean('is_active'), + 'background_fixed' => $this->boolean('background_fixed'), 'remove_page_background' => $this->boolean('remove_page_background'), 'ticketshop_url' => $ticketshopNormalized, 'post_submit_redirect_url' => $redirectNormalized, diff --git a/app/Models/PreregistrationPage.php b/app/Models/PreregistrationPage.php index f307e96..e045e9f 100644 --- a/app/Models/PreregistrationPage.php +++ b/app/Models/PreregistrationPage.php @@ -32,6 +32,7 @@ class PreregistrationPage extends Model 'background_image', 'background_overlay_color', 'background_overlay_opacity', + 'background_fixed', 'logo_image', 'is_active', ]; @@ -42,6 +43,7 @@ class PreregistrationPage extends Model 'start_date' => 'datetime', 'end_date' => 'datetime', 'phone_enabled' => 'boolean', + 'background_fixed' => 'boolean', 'is_active' => 'boolean', ]; } diff --git a/database/migrations/2026_04_04_200000_add_background_fixed_to_preregistration_pages.php b/database/migrations/2026_04_04_200000_add_background_fixed_to_preregistration_pages.php new file mode 100644 index 0000000..6a16527 --- /dev/null +++ b/database/migrations/2026_04_04_200000_add_background_fixed_to_preregistration_pages.php @@ -0,0 +1,24 @@ +boolean('background_fixed')->default(false)->after('background_overlay_opacity'); + }); + } + + public function down(): void + { + Schema::table('preregistration_pages', function (Blueprint $table): void { + $table->dropColumn('background_fixed'); + }); + } +}; diff --git a/lang/nl.json b/lang/nl.json index 54c9fb0..560fb2f 100644 --- a/lang/nl.json +++ b/lang/nl.json @@ -22,5 +22,7 @@ "Subscriber removed.": "Abonnee verwijderd.", "Delete this subscriber? This cannot be undone.": "Deze abonnee verwijderen? Dit kan niet ongedaan worden gemaakt.", "Remove": "Verwijderen", - "Actions": "Acties" + "Actions": "Acties", + "Fix background to viewport": "Achtergrond vastzetten op het scherm", + "When enabled, the background image and overlay stay fixed while visitors scroll long content.": "Als dit aan staat, blijven de achtergrondafbeelding en de overlay stilstaan terwijl bezoekers door lange inhoud scrollen." } diff --git a/resources/views/admin/pages/_form.blade.php b/resources/views/admin/pages/_form.blade.php index 004dab1..99b7a98 100644 --- a/resources/views/admin/pages/_form.blade.php +++ b/resources/views/admin/pages/_form.blade.php @@ -98,6 +98,19 @@ @enderror +
+ +

{{ __('When enabled, the background image and overlay stay fixed while visitors scroll long content.') }}

+
diff --git a/resources/views/public/page.blade.php b/resources/views/public/page.blade.php index d13b248..de6c60b 100644 --- a/resources/views/public/page.blade.php +++ b/resources/views/public/page.blade.php @@ -20,6 +20,9 @@ $formButtonLabel = (string) (data_get($formContent, 'button_label') ?: __('public.register_button')); $formButtonColor = (string) data_get($formContent, 'button_color', '#F47B20'); $formButtonTextColor = (string) data_get($formContent, 'button_text_color', '#FFFFFF'); + $bgFixed = $page->background_fixed; + $bgLayerPosition = $bgFixed ? 'fixed inset-0 pointer-events-none z-0' : 'absolute inset-0'; + $overlayPosition = $bgFixed ? 'fixed inset-0 pointer-events-none z-[1]' : 'absolute inset-0'; @endphp @extends('layouts.public') @@ -28,19 +31,19 @@
@if ($bgUrl !== null) @else @endif diff --git a/tests/Feature/StorePreregistrationPageTest.php b/tests/Feature/StorePreregistrationPageTest.php index 8bf83b3..5996c5a 100644 --- a/tests/Feature/StorePreregistrationPageTest.php +++ b/tests/Feature/StorePreregistrationPageTest.php @@ -32,9 +32,31 @@ class StorePreregistrationPageTest extends TestCase $page = PreregistrationPage::query()->first(); $response->assertRedirect(route('admin.pages.edit', $page)); $this->assertSame('Summer Fest', $page?->title); + $this->assertFalse($page?->background_fixed); $this->assertGreaterThanOrEqual(4, PageBlock::query()->where('preregistration_page_id', $page?->id)->count()); } + public function test_store_can_enable_fixed_background(): void + { + $user = User::factory()->create(['role' => 'user']); + + $response = $this->actingAs($user)->post(route('admin.pages.store'), [ + 'title' => 'Winter Fest', + 'thank_you_message' => null, + 'expired_message' => null, + 'ticketshop_url' => null, + 'start_date' => '2026-06-01T10:00', + 'end_date' => '2026-06-30T18:00', + 'is_active' => true, + 'background_fixed' => true, + ]); + + $page = PreregistrationPage::query()->where('title', 'Winter Fest')->first(); + $response->assertRedirect(route('admin.pages.edit', $page)); + $this->assertNotNull($page); + $this->assertTrue($page->background_fixed); + } + public function test_validation_failure_redirects_back_with_input(): void { $user = User::factory()->create(['role' => 'user']);