feat: adds compatibility with TRMNL Design Framework v2

This commit is contained in:
Benjamin Nussbaum 2025-09-14 18:57:17 +02:00
parent f20977a822
commit 12c82e02d7
7 changed files with 27 additions and 12 deletions

View file

@ -24,4 +24,13 @@ final class DeviceModel extends Model
'offset_y' => 'integer', 'offset_y' => 'integer',
'published_at' => 'datetime', 'published_at' => 'datetime',
]; ];
public function getColorDepthAttribute(): ?string
{
if (! $this->bit_depth){
return null;
}
return $this->bit_depth . 'bit';
}
} }

View file

@ -278,7 +278,7 @@ class Plugin extends Model
* *
* @throws LiquidException * @throws LiquidException
*/ */
public function render(string $size = 'full', bool $standalone = true): string public function render(string $size = 'full', bool $standalone = true, ?Device $device = null): string
{ {
if ($this->render_markup) { if ($this->render_markup) {
$renderedContent = ''; $renderedContent = '';
@ -344,6 +344,7 @@ class Plugin extends Model
if ($standalone) { if ($standalone) {
return view('trmnl-layouts.single', [ return view('trmnl-layouts.single', [
'colorDepth' => $device?->deviceModel?->color_depth,
'slot' => $renderedContent, 'slot' => $renderedContent,
])->render(); ])->render();
} }
@ -354,6 +355,7 @@ class Plugin extends Model
if ($this->render_markup_view) { if ($this->render_markup_view) {
if ($standalone) { if ($standalone) {
return view('trmnl-layouts.single', [ return view('trmnl-layouts.single', [
'colorDepth' => $device?->deviceModel?->color_depth,
'slot' => view($this->render_markup_view, [ 'slot' => view($this->render_markup_view, [
'size' => $size, 'size' => $size,
'data' => $this->data_payload, 'data' => $this->data_payload,

View file

@ -13,7 +13,7 @@
"php": "^8.2", "php": "^8.2",
"ext-imagick": "*", "ext-imagick": "*",
"ext-zip": "*", "ext-zip": "*",
"bnussbau/laravel-trmnl-blade": "1.2.*", "bnussbau/laravel-trmnl-blade": "2.0.*",
"intervention/image": "^3.11", "intervention/image": "^3.11",
"keepsuit/laravel-liquid": "^0.5.2", "keepsuit/laravel-liquid": "^0.5.2",
"laravel/framework": "^12.1", "laravel/framework": "^12.1",

14
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "ecbc891180c22676e2d03b6c8a02b6e3", "content-hash": "349a46b94103f479caae00ca7e6a99c2",
"packages": [ "packages": [
{ {
"name": "aws/aws-crt-php", "name": "aws/aws-crt-php",
@ -159,16 +159,16 @@
}, },
{ {
"name": "bnussbau/laravel-trmnl-blade", "name": "bnussbau/laravel-trmnl-blade",
"version": "1.2.1", "version": "2.0.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/bnussbau/laravel-trmnl-blade.git", "url": "https://github.com/bnussbau/laravel-trmnl-blade.git",
"reference": "fe11d1d7d896d6f0ea44664c1c6b5f00f1bdab36" "reference": "3b60522bea8ae5dbca94834706247339e1e53582"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/bnussbau/laravel-trmnl-blade/zipball/fe11d1d7d896d6f0ea44664c1c6b5f00f1bdab36", "url": "https://api.github.com/repos/bnussbau/laravel-trmnl-blade/zipball/3b60522bea8ae5dbca94834706247339e1e53582",
"reference": "fe11d1d7d896d6f0ea44664c1c6b5f00f1bdab36", "reference": "3b60522bea8ae5dbca94834706247339e1e53582",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -223,7 +223,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/bnussbau/laravel-trmnl-blade/issues", "issues": "https://github.com/bnussbau/laravel-trmnl-blade/issues",
"source": "https://github.com/bnussbau/laravel-trmnl-blade/tree/1.2.1" "source": "https://github.com/bnussbau/laravel-trmnl-blade/tree/2.0.0"
}, },
"funding": [ "funding": [
{ {
@ -239,7 +239,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2025-08-11T16:14:12+00:00" "time": "2025-09-14T07:54:31+00:00"
}, },
{ {
"name": "brick/math", "name": "brick/math",

View file

@ -1,3 +1,7 @@
<x-trmnl::screen> @props([
'colorDepth' => '1bit',
])
<x-trmnl::screen colorDepth="{{$colorDepth}}">
{!! $slot !!} {!! $slot !!}
</x-trmnl::screen> </x-trmnl::screen>

View file

@ -3,7 +3,7 @@
'darkMode' => false, 'darkMode' => false,
'deviceVariant' => 'og', 'deviceVariant' => 'og',
'deviceOrientation' => null, 'deviceOrientation' => null,
'colorDepth' => '2bit', 'colorDepth' => '1bit',
'scaleLevel' => null, 'scaleLevel' => null,
]) ])

View file

@ -85,7 +85,7 @@ Route::get('/display', function (Request $request) {
// Check and update stale data if needed // Check and update stale data if needed
if ($plugin->isDataStale() || $plugin->current_image === null) { if ($plugin->isDataStale() || $plugin->current_image === null) {
$plugin->updateDataPayload(); $plugin->updateDataPayload();
$markup = $plugin->render(); $markup = $plugin->render(device: $device);
GenerateScreenJob::dispatchSync($device->id, $plugin->id, $markup); GenerateScreenJob::dispatchSync($device->id, $plugin->id, $markup);
} }