Skip to content

Commit eea88c9

Browse files
Enhance trivia shortcode view and logic for improved display and functionality
1 parent f460fee commit eea88c9

File tree

2 files changed

+82
-5
lines changed

2 files changed

+82
-5
lines changed

resources/views/trivia.blade.php

+73-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,74 @@
1-
<div class="not-prose">
2-
<livewire:trivia :id="$id"/>
1+
<div class="relative w-full overflow-hidden transition-all duration-300 bg-white shadow-xl not-prose rounded-xl group">
2+
{{-- Link assoluto con play button sempre visibile --}}
3+
<a href="{{ $trivia->route }}" class="absolute inset-0 z-30 hover:!bg-transparent">
4+
<div
5+
class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-[100%] md:-translate-y-1/2
6+
bg-red-500 text-white px-6 py-3 rounded-full shadow-xl group-hover:scale-110 transition-transform duration-300">
7+
<span class="text-lg font-bold whitespace-nowrap">Gioca ora!</span>
8+
</div>
9+
</a>
10+
11+
<div class="relative">
12+
<div class="absolute inset-0 z-10 bg-gradient-to-t from-black/80 via-black/40 to-transparent"></div>
13+
<img src="{{ $trivia->cover_image }}" alt="{{ $trivia->topic }}"
14+
class="w-full aspect-[9/12] md:aspect-[16/9] object-cover group-hover:scale-105 group-hover:translate-y-1 transition-all duration-500">
15+
16+
{{-- Timer Badge --}}
17+
<div class="absolute z-20 space-y-1 top-4 right-4 text-end">
18+
<div
19+
class="inline-flex items-center gap-2 px-3 py-1 text-sm font-semibold text-white bg-red-500 rounded-full">
20+
<svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4" fill="none" viewBox="0 0 24 24"
21+
stroke="currentColor">
22+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
23+
d="M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
24+
</svg>
25+
{{ $trivia->answers_count }} domande
26+
</div>
27+
28+
@if ($trivia->timer)
29+
<div
30+
class="flex items-center gap-1 px-3 py-1 text-sm font-semibold text-white rounded-full bg-white/20 backdrop-blur-sm">
31+
<svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4" fill="none" viewBox="0 0 24 24"
32+
stroke="currentColor">
33+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
34+
d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z" />
35+
</svg>
36+
{{ $trivia->timer }}s per domanda
37+
</div>
38+
@endif
39+
40+
</div>
41+
42+
43+
{{-- Content --}}
44+
<div
45+
class="absolute bottom-0 left-0 right-0 z-20 p-8 text-white bg-gradient-to-t from-black/80 via-black/40 to-transparent">
46+
@if ($trivia->close_date)
47+
<div class="flex items-center gap-2 mb-3">
48+
<span class="px-2 py-1 text-xs border rounded-md bg-white/20 backdrop-blur-sm border-white/10">
49+
Si chiuderà {{ Carbon\Carbon::parse($trivia->close_date)->diffForHumans() }}
50+
</span>
51+
</div>
52+
@endif
53+
54+
<div class="flex flex-col gap-4">
55+
<h2
56+
class="text-3xl md:text-4xl font-bold after:!hidden !m-0 leading-tight transition-transform duration-300">
57+
{{ $trivia->topic }}
58+
</h2>
59+
60+
<div class="flex items-center gap-4 text-sm text-white/70">
61+
<span>Metti alla prova le tue conoscenze!</span>
62+
<span class="flex items-center gap-1 pl-4 border-l border-white/10">
63+
<svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4" fill="none" viewBox="0 0 24 24"
64+
stroke="currentColor">
65+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
66+
d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z" />
67+
</svg>
68+
{{ $trivia->played_count ?? 0 }} partecipazioni
69+
</span>
70+
</div>
71+
</div>
72+
</div>
73+
</div>
374
</div>

src/Shortcodes/TriviaShortcode.php

+9-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22

33
namespace Murdercode\LaravelShortcodePlus\Shortcodes;
44

5+
use The3labsTeam\NovaTriviaPackage\App\Models\Trivia;
6+
57
class TriviaShortcode
68
{
79
public function register($shortcode): string
810
{
9-
$id = $shortcode->id ?? '';
11+
$trivia = Trivia::find($shortcode->id);
12+
13+
if (!$trivia) {
14+
return '';
15+
}
1016

11-
return view('shortcode-plus::trivia', compact('id'))->render();
17+
return view('shortcode-plus::trivia', compact('trivia'))->render();
1218
}
13-
}
19+
}

0 commit comments

Comments
 (0)