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..e32ae58 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> @@ -177,8 +204,9 @@ class extends Component { @else
@foreach($recipes as $recipe) -
-
+
+
+
@php($thumb = $recipe['icon_url'] ?? $recipe['screenshot_url']) @if($thumb) {{ $recipe['name'] }} @@ -191,9 +219,9 @@ class extends Component {
-

{{ $recipe['name'] }}

+ {{ $recipe['name'] }} @if(data_get($recipe, 'stats.installs')) -

Installs: {{ data_get($recipe, 'stats.installs') }} · Forks: {{ data_get($recipe, 'stats.forks') }}

+ Installs: {{ data_get($recipe, 'stats.installs') }} · Forks: {{ data_get($recipe, 'stats.forks') }} @endif
@@ -206,7 +234,7 @@ class extends Component {
@if($recipe['author_bio']) -

{{ $recipe['author_bio'] }}

+ {{ $recipe['author_bio'] }} @endif
@@ -218,6 +246,19 @@ class extends Component { @endif + @if($recipe['id']) + + + Preview + + + @endif + + + @if($recipe['detail_url'])
+
@endforeach
@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