Update comments design
This commit is contained in:
@@ -1,153 +1,253 @@
|
||||
<div>
|
||||
<div class="flex" id="comment-{{ $comment->id }}">
|
||||
<div class="flex-shrink-0 mr-4">
|
||||
<div id="comment-{{ $comment->id }}">
|
||||
|
||||
<div class="group flex gap-4">
|
||||
|
||||
{{-- Avatar --}}
|
||||
<div class="shrink-0">
|
||||
@if($comment->isDeletedByModerator())
|
||||
<img class="h-10 w-10 rounded-full" src="{{ asset('images/default-avatar.webp') }}" alt="Deleted comment">
|
||||
<img
|
||||
class="h-10 w-10 rounded-full object-cover opacity-60"
|
||||
src="{{ asset('images/default-avatar.webp') }}"
|
||||
alt="Deleted comment"
|
||||
>
|
||||
@else
|
||||
<img class="h-10 w-10 rounded-full" src="{{ $comment->user->getAvatar() }}" alt="{{ $comment->user->name }}">
|
||||
<img
|
||||
class="h-10 w-10 rounded-full object-cover ring-2 ring-white dark:ring-neutral-800"
|
||||
src="{{ $comment->user->getAvatar() }}"
|
||||
alt="{{ $comment->user->name }}"
|
||||
>
|
||||
@endif
|
||||
</div>
|
||||
<div class="flex-grow">
|
||||
<div class="flex gap-2">
|
||||
@if($comment->isDeletedByModerator())
|
||||
@if (Auth::check() && (Auth::user()->hasRole(\App\Enums\UserRole::ADMINISTRATOR) || Auth::user()->hasRole(\App\Enums\UserRole::MODERATOR)))
|
||||
<p class="font-medium text-gray-900 dark:text-gray-100">Deleted ({{ $comment->user->name }})</p>
|
||||
@else
|
||||
<p class="font-medium text-gray-900 dark:text-gray-100">Deleted</p>
|
||||
@endif
|
||||
@else
|
||||
<p class="font-medium text-gray-900 dark:text-gray-100">{{ $comment->user->name }}</p>
|
||||
@endif
|
||||
@if($comment->user->hasRole(\App\Enums\UserRole::ADMINISTRATOR))
|
||||
<a data-te-toggle="tooltip" title="Admin"><i class="fa-solid fa-crown text-yellow-600"></i></a>
|
||||
@endif
|
||||
@if($comment->user->hasRole(\App\Enums\UserRole::MODERATOR))
|
||||
<a data-te-toggle="tooltip" title="Admin" class="text-rose-600">Moderator</a>
|
||||
@endif
|
||||
@if($comment->user->hasRole(\App\Enums\UserRole::SUPPORTER))
|
||||
<a data-te-toggle="tooltip" title="Badge of appreciation for the horny people supporting us! :3"><i class="fa-solid fa-hand-holding-heart text-rose-600"></i></a>
|
||||
@endif
|
||||
</div>
|
||||
<div class="mt-1 flex-grow w-full">
|
||||
@if($comment->isDeletedByModerator())
|
||||
<div class="text-gray-700 dark:text-gray-200">Deleted by moderation.</div>
|
||||
@if (Auth::check() && (Auth::user()->hasRole(\App\Enums\UserRole::ADMINISTRATOR) || Auth::user()->hasRole(\App\Enums\UserRole::MODERATOR)))
|
||||
<div class="text-gray-700 dark:text-gray-300 pt-1">Original comment: {!! $comment->presenter()->markdownBody() !!}</div>
|
||||
@endif
|
||||
@else
|
||||
@if ($isEditing)
|
||||
<form wire:submit.prevent="editComment">
|
||||
<div>
|
||||
<label for="comment" class="sr-only">Comment body</label>
|
||||
<textarea id="comment" name="comment" rows="3"
|
||||
class="bg-white dark:bg-neutral-700 shadow-sm block w-full focus:ring-rose-500 focus:border-rose-500 border-gray-300 dark:border-gray-400/40 text-gray-900 dark:text-gray-200 placeholder:text-gray-400 rounded-md
|
||||
@error('editState.body') border-red-500 @enderror"
|
||||
placeholder="Write something" wire:model.defer="editState.body"></textarea>
|
||||
@error('editState.body')
|
||||
<p class="mt-2 text-sm text-red-500">{{ $message }}</p>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="mt-3 flex items-center justify-between">
|
||||
<button type="submit"
|
||||
class="inline-flex items-center justify-center px-4 py-2 border border-transparent font-medium rounded-md shadow-sm text-white bg-rose-600 hover:bg-rose-700 focus:outline-none focus:ring-2 focus:ring-rose-500">
|
||||
Edit
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
@else
|
||||
<div class="text-gray-700 dark:text-gray-200">{!! $comment->presenter()->markdownBody() !!}</div>
|
||||
@endif
|
||||
@endif
|
||||
</div>
|
||||
<div class="mt-2 space-x-2 flex flex-row">
|
||||
<span class="text-gray-500 dark:text-gray-300">
|
||||
{{ $comment->presenter()->relativeCreatedAt() }}
|
||||
</span>
|
||||
|
||||
@guest
|
||||
<span data-te-toggle="tooltip" title="Please login to like the episode" class="text-gray-800 cursor-pointer dark:text-gray-200">
|
||||
<i class="fa-regular fa-heart"></i> {{ $comment->likeCount() }}
|
||||
</span>
|
||||
@endguest
|
||||
{{-- Content --}}
|
||||
<div class="min-w-0 flex-1">
|
||||
|
||||
@auth
|
||||
<!-- Like Button -->
|
||||
<button class="text-gray-800 dark:text-gray-200 leading-tight cursor-pointer whitespace-nowrap" wire:click="like">
|
||||
@if ($liked)
|
||||
<i class="fa-solid fa-heart text-rose-600"></i> {{ $likeCount }}
|
||||
@else
|
||||
<i class="fa-solid fa-heart"></i> {{ $likeCount }}
|
||||
<div class="rounded-2xl border border-neutral-200 bg-white px-5 py-4 shadow-sm transition group-hover:border-neutral-300 dark:border-neutral-800 dark:bg-neutral-800 dark:group-hover:border-neutral-700">
|
||||
|
||||
{{-- Header --}}
|
||||
<div class="mb-3 flex flex-wrap items-center gap-2">
|
||||
|
||||
@if($comment->isDeletedByModerator())
|
||||
|
||||
<span class="font-semibold text-neutral-900 dark:text-neutral-100">
|
||||
@if (Auth::check() && (Auth::user()->hasRole(\App\Enums\UserRole::ADMINISTRATOR) || Auth::user()->hasRole(\App\Enums\UserRole::MODERATOR)))
|
||||
Deleted ({{ $comment->user->name }})
|
||||
@else
|
||||
Deleted
|
||||
@endif
|
||||
</span>
|
||||
|
||||
@else
|
||||
|
||||
<span class="font-semibold text-neutral-900 dark:text-neutral-100">
|
||||
{{ $comment->user->name }}
|
||||
</span>
|
||||
|
||||
@endif
|
||||
|
||||
{{-- Badges --}}
|
||||
@if($comment->user->hasRole(\App\Enums\UserRole::ADMINISTRATOR))
|
||||
<span class="inline-flex items-center rounded-full bg-yellow-100 px-2 py-0.5 text-xs font-medium text-yellow-700 dark:bg-yellow-500/10 dark:text-yellow-400">
|
||||
<i class="fa-solid fa-crown mr-1"></i>
|
||||
Admin
|
||||
</span>
|
||||
@endif
|
||||
|
||||
@if($comment->user->hasRole(\App\Enums\UserRole::MODERATOR))
|
||||
<span class="inline-flex items-center rounded-full bg-rose-100 px-2 py-0.5 text-xs font-medium text-rose-700 dark:bg-rose-500/10 dark:text-rose-400">
|
||||
Moderator
|
||||
</span>
|
||||
@endif
|
||||
|
||||
@if($comment->user->hasRole(\App\Enums\UserRole::SUPPORTER))
|
||||
<span class="inline-flex items-center rounded-full bg-pink-100 px-2 py-0.5 text-xs font-medium text-pink-700 dark:bg-pink-500/10 dark:text-pink-400">
|
||||
<i class="fa-solid fa-heart mr-1"></i>
|
||||
Supporter
|
||||
</span>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
|
||||
{{-- Body --}}
|
||||
<div class="prose prose-sm max-w-none dark:prose-invert">
|
||||
|
||||
@if($comment->isDeletedByModerator())
|
||||
|
||||
<p class="italic text-neutral-500 dark:text-neutral-400">
|
||||
Deleted by moderation.
|
||||
</p>
|
||||
|
||||
@if (Auth::check() && (Auth::user()->hasRole(\App\Enums\UserRole::ADMINISTRATOR) || Auth::user()->hasRole(\App\Enums\UserRole::MODERATOR)))
|
||||
<div class="mt-3 rounded-xl bg-neutral-100 p-3 text-sm dark:bg-neutral-800">
|
||||
{!! $comment->presenter()->markdownBody() !!}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@else
|
||||
|
||||
@if ($isEditing)
|
||||
|
||||
<form wire:submit.prevent="editComment" class="space-y-4">
|
||||
|
||||
<textarea
|
||||
rows="4"
|
||||
wire:model.defer="editState.body"
|
||||
class="w-full rounded-2xl border border-neutral-300 bg-white px-4 py-3 text-sm text-neutral-900 shadow-sm transition focus:border-rose-500 focus:outline-none focus:ring-4 focus:ring-rose-500/10 dark:border-neutral-700 dark:bg-neutral-950 dark:text-neutral-100 @error('editState.body') border-red-500 @enderror"
|
||||
></textarea>
|
||||
|
||||
@error('editState.body')
|
||||
<p class="text-sm text-red-500">
|
||||
{{ $message }}
|
||||
</p>
|
||||
@enderror
|
||||
|
||||
<div class="flex justify-end">
|
||||
<button
|
||||
type="submit"
|
||||
class="rounded-xl bg-rose-600 px-4 py-2 text-sm font-medium text-white transition hover:bg-rose-700"
|
||||
>
|
||||
Save Changes
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
@else
|
||||
<div class="text-gray-700 dark:text-gray-200">
|
||||
{!! $comment->presenter()->markdownBody() !!}
|
||||
</div>
|
||||
@endif
|
||||
</button>
|
||||
@endauth
|
||||
|
||||
@auth
|
||||
@if ($comment->depth() < 2)
|
||||
<button wire:click="$toggle('isReplying')" type="button" class="text-gray-900 dark:text-gray-100 font-medium">
|
||||
Reply
|
||||
</button>
|
||||
@endif
|
||||
|
||||
@can ('update', $comment)
|
||||
<button wire:click="$toggle('isEditing')" type="button" class="text-gray-900 dark:text-gray-100 font-medium">
|
||||
Edit
|
||||
</button>
|
||||
@endcan
|
||||
</div>
|
||||
|
||||
@can ('destroy', $comment)
|
||||
<button x-data="{
|
||||
confirmCommentDeletion () {
|
||||
if (window.confirm('Are you sure you want to delete this comment?')) {
|
||||
@this.call('deleteComment');
|
||||
}
|
||||
}
|
||||
}"
|
||||
@click="confirmCommentDeletion"
|
||||
type="button"
|
||||
class="text-gray-900 dark:text-gray-100 font-medium"
|
||||
>
|
||||
Delete
|
||||
</button>
|
||||
@endcan
|
||||
|
||||
@can ('restore', $comment)
|
||||
{{-- Footer --}}
|
||||
<div class="mt-4 flex flex-wrap items-center gap-4 text-sm">
|
||||
|
||||
<span class="text-neutral-500 dark:text-neutral-400">
|
||||
{{ $comment->presenter()->relativeCreatedAt() }}
|
||||
</span>
|
||||
|
||||
{{-- Like --}}
|
||||
@guest
|
||||
<span class="flex items-center gap-1 text-neutral-500 dark:text-neutral-400">
|
||||
<i class="fa-regular fa-heart"></i>
|
||||
{{ $comment->likeCount() }}
|
||||
</span>
|
||||
@endguest
|
||||
|
||||
@auth
|
||||
<button
|
||||
wire:click="restoreComment"
|
||||
type="button"
|
||||
class="text-gray-900 dark:text-gray-100 font-medium"
|
||||
wire:click="like"
|
||||
class="flex items-center gap-1 text-neutral-500 transition hover:text-rose-600 dark:text-neutral-400 dark:hover:text-rose-400"
|
||||
>
|
||||
Restore
|
||||
@if ($liked)
|
||||
<i class="fa-solid fa-heart text-rose-600"></i>
|
||||
@else
|
||||
<i class="fa-regular fa-heart"></i>
|
||||
@endif
|
||||
|
||||
{{ $likeCount }}
|
||||
</button>
|
||||
@endcan
|
||||
@endauth
|
||||
@endauth
|
||||
|
||||
{{-- Actions --}}
|
||||
@auth
|
||||
|
||||
@if ($comment->depth() < 2)
|
||||
<button
|
||||
wire:click="$toggle('isReplying')"
|
||||
class="font-medium text-neutral-600 transition hover:text-neutral-900 dark:text-neutral-400 dark:hover:text-neutral-100"
|
||||
>
|
||||
Reply
|
||||
</button>
|
||||
@endif
|
||||
|
||||
@can ('update', $comment)
|
||||
<button
|
||||
wire:click="$toggle('isEditing')"
|
||||
class="font-medium text-neutral-600 transition hover:text-neutral-900 dark:text-neutral-400 dark:hover:text-neutral-100"
|
||||
>
|
||||
Edit
|
||||
</button>
|
||||
@endcan
|
||||
|
||||
@can ('destroy', $comment)
|
||||
<button
|
||||
x-data="{
|
||||
confirmCommentDeletion () {
|
||||
if (window.confirm('Delete this comment?')) {
|
||||
@this.call('deleteComment');
|
||||
}
|
||||
}
|
||||
}"
|
||||
@click="confirmCommentDeletion"
|
||||
class="font-medium text-red-500 transition hover:text-red-600"
|
||||
>
|
||||
Delete
|
||||
</button>
|
||||
@endcan
|
||||
|
||||
@can ('restore', $comment)
|
||||
<button
|
||||
wire:click="restoreComment"
|
||||
class="font-medium text-emerald-600 transition hover:text-emerald-700"
|
||||
>
|
||||
Restore
|
||||
</button>
|
||||
@endcan
|
||||
|
||||
@endauth
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{{-- Reply Form --}}
|
||||
@if ($isReplying)
|
||||
|
||||
<div class="mt-4 ml-2">
|
||||
<form wire:submit.prevent="postReply" class="space-y-4">
|
||||
|
||||
<textarea
|
||||
rows="3"
|
||||
wire:model.defer="replyState.body"
|
||||
placeholder="Write a reply..."
|
||||
class="w-full rounded-2xl border border-neutral-300 bg-white px-4 py-3 text-sm text-neutral-900 shadow-sm transition focus:border-rose-500 focus:outline-none focus:ring-4 focus:ring-rose-500/10 dark:border-neutral-700 dark:bg-neutral-950 dark:text-neutral-100 @error('replyState.body') border-red-500 @enderror"
|
||||
></textarea>
|
||||
|
||||
@error('replyState.body')
|
||||
<p class="text-sm text-red-500">
|
||||
{{ $message }}
|
||||
</p>
|
||||
@enderror
|
||||
|
||||
<div class="flex justify-end">
|
||||
<button
|
||||
type="submit"
|
||||
class="rounded-xl bg-rose-600 px-4 py-2 text-sm font-medium text-white transition hover:bg-rose-700"
|
||||
>
|
||||
Reply
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@endif
|
||||
|
||||
{{-- Replies --}}
|
||||
@if ($comment->children->count())
|
||||
<div class="mt-2 space-y-2 border-l-2 border-neutral-200 pl-6 dark:border-neutral-700">
|
||||
@foreach ($comment->children as $child)
|
||||
<livewire:comment :comment="$child" :key="$child->id"/>
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="ml-14 mt-6">
|
||||
@if ($isReplying)
|
||||
<form wire:submit.prevent="postReply" class="my-4">
|
||||
<div>
|
||||
<label for="comment" class="sr-only">Reply body</label>
|
||||
<textarea id="comment" name="comment" rows="3"
|
||||
class="bg-white dark:bg-neutral-700 shadow-sm block w-full focus:ring-rose-500 focus:border-rose-500 border-gray-300 dark:border-gray-400/40 text-gray-900 dark:text-gray-200 placeholder:text-gray-400 rounded-md
|
||||
@error('replyState.body') border-red-500 @enderror"
|
||||
placeholder="Write something" wire:model.defer="replyState.body"></textarea>
|
||||
@error('replyState.body')
|
||||
<p class="mt-2 text-sm text-red-500">{{ $message }}</p>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="mt-3 flex items-center justify-between">
|
||||
<button type="submit"
|
||||
class="inline-flex items-center justify-center px-4 py-2 border border-transparent font-medium rounded-md shadow-sm text-white bg-rose-600 hover:bg-rose-700 focus:outline-none focus:ring-2 focus:ring-rose-500">
|
||||
Comment
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
@endif
|
||||
|
||||
@foreach ($comment->children as $child)
|
||||
<livewire:comment :comment="$child" :key="$child->id"/>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user