|
| 1 | +<div class="relative mt-2 pt-2 border-t border-gray-200 dark:border-gray-700 flex items-center gap-x-1 flex-wrap"> |
| 2 | + {{-- Inline buttons for existing reactions --}} |
| 3 | + @foreach ($this->reactionSummary as $reactionData) |
| 4 | + <span wire:key="inline-reaction-button-{{ $reactionData['reaction'] }}-{{ $comment->getId() }}"> |
| 5 | + <button |
| 6 | + x-cloak |
| 7 | + wire:click="handleReactionToggle('{{ $reactionData['reaction'] }}')" |
| 8 | + type="button" |
| 9 | + class="inline-flex items-center justify-center gap-1 rounded-full border px-2 py-1 text-sm font-medium transition hover:bg-gray-100 dark:hover:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed |
| 10 | + {{ $reactionData['reacted_by_current_user'] |
| 11 | + ? 'bg-primary-100 dark:bg-primary-800 border-primary-300 dark:border-primary-600 text-primary-700 dark:text-primary-200' |
| 12 | + : 'bg-white dark:bg-gray-900 border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-200' }}" |
| 13 | + title="{{ $reactionData['reaction'] }}" |
| 14 | + |
| 15 | + > |
| 16 | + <span>{{ $reactionData['reaction'] }}</span> |
| 17 | + <span wire:key="inline-reaction-count-{{ $reactionData['reaction'] }}-{{ $comment->getId() }}">{{ $reactionData['count'] }}</span> |
| 18 | + </button> |
| 19 | + </span> |
| 20 | + @endforeach |
| 21 | + |
| 22 | + {{-- Add Reaction Button --}} |
| 23 | + <div class="relative" x-data="{ open: false }" wire:ignore.self> |
| 24 | + <button |
| 25 | + x-on:click="open = !open" |
| 26 | + type="button" |
| 27 | + @disabled(! auth()->check()) |
| 28 | + class="inline-flex items-center justify-center gap-1 rounded-full border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-900 px-2 py-1 text-sm font-medium text-gray-700 dark:text-gray-200 transition hover:bg-gray-100 dark:hover:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed" |
| 29 | + title="Add Reaction" |
| 30 | + wire:key="add-reaction-button-{{ $comment->getId() }}" |
| 31 | + > |
| 32 | + <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"> |
| 33 | + <path stroke-linecap="round" stroke-linejoin="round" d="M14.828 14.828a4 4 0 01-5.656 0M9 10h.01M15 10h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /> |
| 34 | + </svg> |
| 35 | + </button> |
| 36 | + |
| 37 | + {{-- Reaction Popup --}} |
| 38 | + <div |
| 39 | + x-show="open" |
| 40 | + x-cloak |
| 41 | + x-on:click.away="open = false" |
| 42 | + class="absolute bottom-full mb-2 z-10 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg shadow-lg p-2 flex flex-wrap gap-1 w-max max-w-xs" |
| 43 | + > |
| 44 | + @foreach ($allowedReactions as $reactionEmoji) |
| 45 | + @php |
| 46 | + $reactionData = $this->reactionSummary[$reactionEmoji] ?? ['count' => 0, 'reacted_by_current_user' => false]; |
| 47 | + @endphp |
| 48 | + |
| 49 | + <button |
| 50 | + wire:click="handleReactionToggle('{{ $reactionEmoji }}')" |
| 51 | + x-on:click="open = false" |
| 52 | + type="button" |
| 53 | + @disabled(! auth()->check()) |
| 54 | + class="inline-flex items-center justify-center gap-1 rounded-full border px-2 py-1 text-sm font-medium transition hover:bg-gray-100 dark:hover:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed |
| 55 | + {{ $reactionData['reacted_by_current_user'] |
| 56 | + ? 'bg-primary-100 dark:bg-primary-800 border-primary-300 dark:border-primary-600 text-primary-700 dark:text-primary-200' |
| 57 | + : 'bg-white dark:bg-gray-900 border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-200' }}" |
| 58 | + title="{{ $reactionEmoji }}" |
| 59 | + wire:key="popup-reaction-button-{{ $reactionEmoji }}-{{ $comment->getId() }}" |
| 60 | + > |
| 61 | + <span>{{ $reactionEmoji }}</span> |
| 62 | + </button> |
| 63 | + @endforeach |
| 64 | + </div> |
| 65 | + </div> |
| 66 | + |
| 67 | + {{-- Display summary of reactions not explicitly in the allowed list --}} |
| 68 | + @foreach ($this->reactionSummary as $reactionEmoji => $data) |
| 69 | + @if (! in_array($reactionEmoji, $allowedReactions) && $data['count'] > 0) |
| 70 | + <span |
| 71 | + wire:key="reaction-extra-{{ $reactionEmoji }}-{{ $comment->getId() }}" |
| 72 | + class="inline-flex items-center justify-center gap-1 rounded-full border border-gray-300 dark:border-gray-600 bg-gray-100 dark:bg-gray-800 px-2 py-1 text-sm font-medium text-gray-600 dark:text-gray-300" |
| 73 | + title="{{ $reactionEmoji }}" |
| 74 | + > |
| 75 | + <span>{{ $reactionEmoji }}</span> |
| 76 | + <span>{{ $data['count'] }}</span> |
| 77 | + </span> |
| 78 | + @endif |
| 79 | + @endforeach |
| 80 | +</div> |
0 commit comments