fix(#103): add recipe options to remove bleed margin and enable dark mode
Some checks failed
tests / ci (push) Has been cancelled

This commit is contained in:
Benjamin Nussbaum 2025-10-30 15:13:50 +01:00
parent 38e1b6f2a6
commit 80e2e8058a
4 changed files with 66 additions and 3 deletions

View file

@ -38,6 +38,8 @@ class Plugin extends Model
'markup_language' => 'string', 'markup_language' => 'string',
'configuration' => 'json', 'configuration' => 'json',
'configuration_template' => 'json', 'configuration_template' => 'json',
'no_bleed' => 'boolean',
'dark_mode' => 'boolean',
]; ];
protected static function boot() protected static function boot()
@ -407,8 +409,8 @@ class Plugin extends Model
'plugin_settings' => [ 'plugin_settings' => [
'instance_name' => $this->name, 'instance_name' => $this->name,
'strategy' => $this->data_strategy, 'strategy' => $this->data_strategy,
'dark_mode' => 'no', 'dark_mode' => $this->dark_mode ? 'yes' : 'no',
'no_screen_padding' => 'no', 'no_screen_padding' => $this->no_bleed ? 'yes' : 'no',
'polling_headers' => $this->polling_header, 'polling_headers' => $this->polling_header,
'polling_url' => $this->polling_url, 'polling_url' => $this->polling_url,
'custom_fields_values' => [ 'custom_fields_values' => [
@ -432,6 +434,8 @@ class Plugin extends Model
return view('trmnl-layouts.single', [ return view('trmnl-layouts.single', [
'colorDepth' => $device?->colorDepth(), 'colorDepth' => $device?->colorDepth(),
'deviceVariant' => $device?->deviceVariant() ?? 'og', 'deviceVariant' => $device?->deviceVariant() ?? 'og',
'noBleed' => $this->no_bleed,
'darkMode' => $this->dark_mode,
'scaleLevel' => $device?->scaleLevel(), 'scaleLevel' => $device?->scaleLevel(),
'slot' => $renderedContent, 'slot' => $renderedContent,
])->render(); ])->render();
@ -441,6 +445,7 @@ class Plugin extends Model
'mashupLayout' => $this->getPreviewMashupLayoutForSize($size), 'mashupLayout' => $this->getPreviewMashupLayoutForSize($size),
'colorDepth' => $device?->colorDepth(), 'colorDepth' => $device?->colorDepth(),
'deviceVariant' => $device?->deviceVariant() ?? 'og', 'deviceVariant' => $device?->deviceVariant() ?? 'og',
'darkMode' => $this->dark_mode,
'scaleLevel' => $device?->scaleLevel(), 'scaleLevel' => $device?->scaleLevel(),
'slot' => $renderedContent, 'slot' => $renderedContent,
])->render(); ])->render();
@ -455,6 +460,8 @@ class Plugin extends Model
return view('trmnl-layouts.single', [ return view('trmnl-layouts.single', [
'colorDepth' => $device?->colorDepth(), 'colorDepth' => $device?->colorDepth(),
'deviceVariant' => $device?->deviceVariant() ?? 'og', 'deviceVariant' => $device?->deviceVariant() ?? 'og',
'noBleed' => $this->no_bleed,
'darkMode' => $this->dark_mode,
'scaleLevel' => $device?->scaleLevel(), 'scaleLevel' => $device?->scaleLevel(),
'slot' => view($this->render_markup_view, [ 'slot' => view($this->render_markup_view, [
'size' => $size, 'size' => $size,

View file

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('plugins', function (Blueprint $table): void {
if (! Schema::hasColumn('plugins', 'no_bleed')) {
$table->boolean('no_bleed')->default(false)->after('configuration_template');
}
if (! Schema::hasColumn('plugins', 'dark_mode')) {
$table->boolean('dark_mode')->default(false)->after('no_bleed');
}
});
}
public function down(): void
{
Schema::table('plugins', function (Blueprint $table): void {
if (Schema::hasColumn('plugins', 'dark_mode')) {
$table->dropColumn('dark_mode');
}
if (Schema::hasColumn('plugins', 'no_bleed')) {
$table->dropColumn('no_bleed');
}
});
}
};

View file

@ -15,6 +15,8 @@ new class extends Component {
public string|null $markup_language; public string|null $markup_language;
public string $name; public string $name;
public bool $no_bleed = false;
public bool $dark_mode = false;
public int $data_stale_minutes; public int $data_stale_minutes;
public string $data_strategy; public string $data_strategy;
public string|null $polling_url; public string|null $polling_url;
@ -66,6 +68,10 @@ new class extends Component {
$this->markup_language = $this->plugin->markup_language ?? 'blade'; $this->markup_language = $this->plugin->markup_language ?? 'blade';
} }
// Initialize screen settings from the model
$this->no_bleed = (bool) ($this->plugin->no_bleed ?? false);
$this->dark_mode = (bool) ($this->plugin->dark_mode ?? false);
$this->fillformFields(); $this->fillformFields();
$this->data_payload_updated_at = $this->plugin->data_payload_updated_at; $this->data_payload_updated_at = $this->plugin->data_payload_updated_at;
} }
@ -109,6 +115,8 @@ new class extends Component {
'device_weekdays' => 'array', 'device_weekdays' => 'array',
'device_active_from' => 'array', 'device_active_from' => 'array',
'device_active_until' => 'array', 'device_active_until' => 'array',
'no_bleed' => 'boolean',
'dark_mode' => 'boolean',
]; ];
public function editSettings() public function editSettings()
@ -1024,6 +1032,22 @@ HTML;
<flux:text class="mb-2">Enter static JSON data in the Data Payload field.</flux:text> <flux:text class="mb-2">Enter static JSON data in the Data Payload field.</flux:text>
@endif @endif
<div class="mb-4">
<flux:label>Screen Settings</flux:label>
<div class="mt-2 space-y-2">
<flux:checkbox
wire:model="no_bleed"
label="Remove bleed margin?"
description="If selected, padding around your markup will be removed."
/>
<flux:checkbox
wire:model="dark_mode"
label="Enable Dark Mode?"
description="Inverts black/white pixels for the entire screen. Add class 'image' to img tags as needed."
/>
</div>
</div>
<div class="flex"> <div class="flex">
<flux:spacer/> <flux:spacer/>
<flux:button type="submit" variant="primary" class="w-full">Save</flux:button> <flux:button type="submit" variant="primary" class="w-full">Save</flux:button>

View file

@ -14,7 +14,7 @@
{!! $slot !!} {!! $slot !!}
</x-trmnl::screen> </x-trmnl::screen>
@else @else
<x-trmnl::screen colorDepth="{{$colorDepth}}"> <x-trmnl::screen colorDepth="{{$colorDepth}}" no-bleed="{{$noBleed}}" dark-mode="{{$darkMode}}">
{!! $slot !!} {!! $slot !!}
</x-trmnl::screen> </x-trmnl::screen>
@endif @endif