From b1467204f89456d7ced83d70415ad916b83a1816 Mon Sep 17 00:00:00 2001 From: andrzejskowron Date: Wed, 26 Nov 2025 13:13:33 +0100 Subject: [PATCH] add preview import list --- .../views/livewire/catalog/index.blade.php | 137 +++++++++++++++ .../views/livewire/catalog/trmnl.blade.php | 157 ++++++++++++++++++ 2 files changed, 294 insertions(+) diff --git a/resources/views/livewire/catalog/index.blade.php b/resources/views/livewire/catalog/index.blade.php index 201ee7e..83a34fc 100644 --- a/resources/views/livewire/catalog/index.blade.php +++ b/resources/views/livewire/catalog/index.blade.php @@ -14,6 +14,8 @@ new class extends Component { public array $catalogPlugins = []; public string $installingPlugin = ''; + public string $previewingPlugin = ''; + public array $previewData = []; public function mount(): void { @@ -117,6 +119,31 @@ class extends Component { $this->installingPlugin = ''; } } + + public function previewPlugin(string $pluginId): void + { + $plugin = collect($this->catalogPlugins)->firstWhere('id', $pluginId); + + if (!$plugin) { + $this->addError('preview', 'Plugin not found.'); + return; + } + + $this->previewingPlugin = $pluginId; + $this->previewData = $plugin; + + // Store scroll position for restoration later + $this->dispatch('store-scroll-position'); + } + + public function closePreview(): void + { + $this->previewingPlugin = ''; + $this->previewData = []; + + // Restore scroll position when returning to catalog + $this->dispatch('restore-scroll-position'); + } }; ?>
@@ -174,6 +201,17 @@ class extends Component { Install + + + Preview + + + + + @if($plugin['learn_more_url']) @endif + + + + @if($previewingPlugin && !empty($previewData)) +
+ Preview {{ $previewData['name'] ?? 'Plugin' }} +
+ +
+ @if($previewData['screenshot_url']) +
+ Preview of {{ $previewData['name'] }} +
+ @elseif($previewData['logo_url']) +
+ {{ $previewData['name'] }} logo +

No preview image available

+
+ @else +
+ +

No preview available

+
+ @endif + + @if($previewData['description']) +
+

Description

+

{{ $previewData['description'] }}

+
+ @endif + +
+ + + Install Plugin + + +
+
+ @endif +
+ +@script + +@endscript diff --git a/resources/views/livewire/catalog/trmnl.blade.php b/resources/views/livewire/catalog/trmnl.blade.php index 8e9c7af..8a2d72c 100644 --- a/resources/views/livewire/catalog/trmnl.blade.php +++ b/resources/views/livewire/catalog/trmnl.blade.php @@ -14,6 +14,8 @@ class extends Component { public array $recipes = []; public string $search = ''; public bool $isSearching = false; + public string $previewingRecipe = ''; + public array $previewData = []; public function mount(): void { @@ -125,6 +127,31 @@ class extends Component { } } + public function previewRecipe(string $recipeId): void + { + $recipe = collect($this->recipes)->firstWhere('id', $recipeId); + + if (!$recipe) { + $this->addError('preview', 'Recipe not found.'); + return; + } + + $this->previewingRecipe = $recipeId; + $this->previewData = $recipe; + + // Store scroll position for restoration later + $this->dispatch('store-scroll-position'); + } + + public function closePreview(): void + { + $this->previewingRecipe = ''; + $this->previewData = []; + + // Restore scroll position when returning to catalog + $this->dispatch('restore-scroll-position'); + } + /** * @param array> $items * @return array> @@ -218,6 +245,19 @@ class extends Component { @endif + @if($recipe['id']) + + + Preview + + + @endif + + + @if($recipe['detail_url']) @endif + + + + @if($previewingRecipe && !empty($previewData)) +
+ Preview {{ $previewData['name'] ?? 'Recipe' }} +
+ +
+ @if($previewData['screenshot_url']) +
+ Preview of {{ $previewData['name'] }} +
+ @elseif($previewData['icon_url']) +
+ {{ $previewData['name'] }} icon +

No preview image available

+
+ @else +
+ +

No preview available

+
+ @endif + + @if($previewData['author_bio']) +
+

Description

+

{{ $previewData['author_bio'] }}

+
+ @endif + + @if(data_get($previewData, 'stats.installs')) +
+

Statistics

+

+ Installs: {{ data_get($previewData, 'stats.installs') }} ยท + Forks: {{ data_get($previewData, 'stats.forks') }} +

+
+ @endif + +
+ @if($previewData['detail_url']) + + View on TRMNL + + @endif + + + Install Recipe + + +
+
+ @endif +
+ +@script + +@endscript