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',
'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
*/
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) {
$renderedContent = '';
@ -344,6 +344,7 @@ class Plugin extends Model
if ($standalone) {
return view('trmnl-layouts.single', [
'colorDepth' => $device?->deviceModel?->color_depth,
'slot' => $renderedContent,
])->render();
}
@ -354,6 +355,7 @@ class Plugin extends Model
if ($this->render_markup_view) {
if ($standalone) {
return view('trmnl-layouts.single', [
'colorDepth' => $device?->deviceModel?->color_depth,
'slot' => view($this->render_markup_view, [
'size' => $size,
'data' => $this->data_payload,

View file

@ -13,7 +13,7 @@
"php": "^8.2",
"ext-imagick": "*",
"ext-zip": "*",
"bnussbau/laravel-trmnl-blade": "1.2.*",
"bnussbau/laravel-trmnl-blade": "2.0.*",
"intervention/image": "^3.11",
"keepsuit/laravel-liquid": "^0.5.2",
"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",
"This file is @generated automatically"
],
"content-hash": "ecbc891180c22676e2d03b6c8a02b6e3",
"content-hash": "349a46b94103f479caae00ca7e6a99c2",
"packages": [
{
"name": "aws/aws-crt-php",
@ -159,16 +159,16 @@
},
{
"name": "bnussbau/laravel-trmnl-blade",
"version": "1.2.1",
"version": "2.0.0",
"source": {
"type": "git",
"url": "https://github.com/bnussbau/laravel-trmnl-blade.git",
"reference": "fe11d1d7d896d6f0ea44664c1c6b5f00f1bdab36"
"reference": "3b60522bea8ae5dbca94834706247339e1e53582"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/bnussbau/laravel-trmnl-blade/zipball/fe11d1d7d896d6f0ea44664c1c6b5f00f1bdab36",
"reference": "fe11d1d7d896d6f0ea44664c1c6b5f00f1bdab36",
"url": "https://api.github.com/repos/bnussbau/laravel-trmnl-blade/zipball/3b60522bea8ae5dbca94834706247339e1e53582",
"reference": "3b60522bea8ae5dbca94834706247339e1e53582",
"shasum": ""
},
"require": {
@ -223,7 +223,7 @@
],
"support": {
"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": [
{
@ -239,7 +239,7 @@
"type": "github"
}
],
"time": "2025-08-11T16:14:12+00:00"
"time": "2025-09-14T07:54:31+00:00"
},
{
"name": "brick/math",

View file

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

View file

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

View file

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