Files
relaticle-comments/resources/views/livewire/comments.blade.php
manukminasyan 2ace8bfdd4 feat: make comment form sticky at bottom of slide-over
Pin the comment editor to the bottom of the slide-over panel so it's
always visible while scrolling through comments. Uses CSS sticky
positioning with border separator and background color.
2026-03-27 21:26:28 +04:00

105 lines
6.2 KiB
PHP

<div class="space-y-4"
@if (!\Relaticle\Comments\CommentsConfig::isBroadcastingEnabled())
wire:poll.{{ \Relaticle\Comments\CommentsConfig::getPollingInterval() }}
@endif
>
{{-- Sort toggle --}}
<div class="flex items-center justify-between">
<h3 class="text-sm font-medium text-gray-700 dark:text-gray-300">
Comments ({{ $this->totalCount }})
</h3>
@auth
<div class="flex items-center gap-3">
<button wire:click="toggleSubscription" type="button"
class="flex items-center gap-1 text-xs {{ $this->isSubscribed ? 'text-primary-600 dark:text-primary-400' : 'text-gray-400 dark:text-gray-500' }} hover:text-primary-500">
@if ($this->isSubscribed)
{{-- Bell icon (solid) --}}
<svg class="h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M10 2a6 6 0 00-6 6c0 1.887-.454 3.665-1.257 5.234a.75.75 0 00.515 1.076 32.91 32.91 0 003.256.508 3.5 3.5 0 006.972 0 32.903 32.903 0 003.256-.508.75.75 0 00.515-1.076A11.448 11.448 0 0116 8a6 6 0 00-6-6zm0 14.5a2 2 0 01-1.95-1.557 33.146 33.146 0 003.9 0A2 2 0 0110 16.5z" clip-rule="evenodd"/>
</svg>
Subscribed
@else
{{-- Bell icon (outline) --}}
<svg class="h-4 w-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M14.857 17.082a23.848 23.848 0 005.454-1.31A8.967 8.967 0 0118 9.75v-.7V9A6 6 0 006 9v.75a8.967 8.967 0 01-2.312 6.022c1.733.64 3.56 1.085 5.455 1.31m5.714 0a24.255 24.255 0 01-5.714 0m5.714 0a3 3 0 11-5.714 0"/>
</svg>
Subscribe
@endif
</button>
<button wire:click="toggleSort" type="button"
class="text-xs text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200">
{{ $sortDirection === 'asc' ? 'Oldest first' : 'Newest first' }}
</button>
</div>
@else
<button wire:click="toggleSort" type="button"
class="text-xs text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200">
{{ $sortDirection === 'asc' ? 'Oldest first' : 'Newest first' }}
</button>
@endauth
</div>
{{-- Comment list --}}
<div class="space-y-4">
@foreach ($this->comments as $comment)
<livewire:comment-item :comment="$comment" :key="'comment-'.$comment->id" />
@endforeach
</div>
{{-- Load more button --}}
@if ($this->hasMore)
<div class="text-center">
<button wire:click="loadMore" type="button"
class="text-sm text-primary-600 hover:text-primary-500 dark:text-primary-400">
Load more comments
<span wire:loading wire:target="loadMore" class="ml-1">...</span>
</button>
</div>
@endif
{{-- New comment form - sticky at bottom of slide-over --}}
@auth
@can('create', \Relaticle\Comments\CommentsConfig::getCommentModel())
<div class="sticky bottom-0 z-10 -mx-4 -mb-4 border-t border-gray-200 bg-white px-4 pb-4 pt-3 dark:border-gray-700 dark:bg-gray-900">
{{ $this->commentForm }}
@if (\Relaticle\Comments\CommentsConfig::areAttachmentsEnabled())
<div class="mt-2">
<label class="flex cursor-pointer items-center gap-2 text-xs text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200">
<svg class="h-4 w-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="m18.375 12.739-7.693 7.693a4.5 4.5 0 0 1-6.364-6.364l10.94-10.94A3 3 0 1 1 19.5 7.372L8.552 18.32m.009-.01-.01.01m5.699-9.941-7.81 7.81a1.5 1.5 0 0 0 2.112 2.13" />
</svg>
Attach files
<input type="file" wire:model="attachments" multiple class="hidden" accept="{{ implode(',', \Relaticle\Comments\CommentsConfig::getAttachmentAllowedTypes()) }}" />
</label>
</div>
@if (!empty($attachments))
<div class="mt-2 flex flex-wrap gap-2">
@foreach ($attachments as $index => $file)
<div class="flex items-center gap-1 rounded bg-gray-100 px-2 py-1 text-xs text-gray-600 dark:bg-gray-700 dark:text-gray-300">
<span>{{ $file->getClientOriginalName() }}</span>
<button type="button" wire:click="removeAttachment({{ $index }})" class="text-gray-400 hover:text-danger-500 dark:text-gray-500 dark:hover:text-danger-400">&times;</button>
</div>
@endforeach
</div>
@endif
@error('attachments.*')
<p class="mt-1 text-sm text-danger-600 dark:text-danger-400">{{ $message }}</p>
@enderror
@endif
<div class="mt-2 flex justify-end">
<button type="button" wire:click="addComment"
class="inline-flex items-center rounded-lg bg-primary-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-primary-500 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 dark:bg-primary-500 dark:hover:bg-primary-400 dark:focus:ring-offset-gray-800"
wire:loading.attr="disabled" wire:target="addComment">
<span wire:loading.remove wire:target="addComment">Comment</span>
<span wire:loading wire:target="addComment">Posting...</span>
</button>
</div>
</div>
@endcan
@endauth
</div>