Skip to content

Commit ae4a5aa

Browse files
committed
fix: Corrections. Moved conditional code to partials. Updated error messages for attachments
1 parent 12dec04 commit ae4a5aa

13 files changed

Lines changed: 175 additions & 111 deletions

‎resources/css/commentions.css‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
display: none;
1111
}
1212

13+
.commentions-error {
14+
@apply comm:text-red-600 comm:hover:text-red-400 comm:dark:text-red-400 comm:dark:hover:text-red-300;
15+
}
16+
1317
.tiptap {
1418
@apply comm:text-sm comm:leading-normal;
1519
}

‎resources/dist/commentions.css‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎resources/dist/commentions.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎resources/js/commentions.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ document.addEventListener('alpine:init', () => {
111111
isEmpty: ! content,
112112

113113
init() {
114+
if (this.$refs.element.dataset.tiptapInitialized) {
115+
return;
116+
}
117+
118+
this.$refs.element.dataset.tiptapInitialized = true;
119+
114120
const _this = this
115121
const targetComponent = componentAlias ?? `commentions::${component}`
116122

‎resources/lang/ro/comments.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
'comment' => 'Comentariu',
2323
'add_reaction' => 'Adaugă reacție',
2424
'attach_files' => 'Atașează fișiere',
25-
'uploading' => 'Se încarcă…',
25+
'uploading' => 'Se încarcă fișierele…',
2626
'show_more' => 'Afișează mai multe',
2727

2828
'rating_input_label' => 'Notă',

‎resources/views/comment.blade.php‎

Lines changed: 11 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
@php
22
$toolbarButtons = $this->getToolbarButtons();
3-
$hasToolBar = filled($toolbarButtons);
3+
$hasToolBar = is_array($toolbarButtons);
44
@endphp
55

6-
<div class="comm:flex comm:items-start comm:gap-x-4 comm:border comm:border-gray-300 comm:dark:border-gray-700 comm:p-4 comm:rounded-lg comm:shadow-sm comm:mb-2" id="filament-comment-{{ $comment->getId() }}">
6+
<div
7+
class="comm:flex comm:items-start comm:gap-x-4 comm:border comm:border-gray-300 comm:dark:border-gray-700 comm:p-4 comm:rounded-lg comm:shadow-sm comm:mb-2"
8+
id="filament-comment-{{ $comment->getId() }}"
9+
>
710
@if ($avatar = $comment->getAuthorAvatar())
811
<img
912
src="{{ $comment->getAuthorAvatar() }}"
@@ -58,7 +61,7 @@ class="comm:mt-2"
5861
x-data="editor(@js($commentBody), @js($mentionables), 'comment', null, @js($hasToolBar), @js($this->getTipTapCssClasses()), @js($commentionsComponentPrefix . 'comment'), @js(['prompt' => __('commentions::comments.toolbar.link_prompt'), 'invalid' => __('commentions::comments.toolbar.link_invalid')]))"
5962
>
6063
@if ($this->ratingsAreEnabled())
61-
@include('commentions::partials.rating-input', ['maxRating' => $this->getMaxRating()])
64+
@include('commentions::partials.ratings.rating-input', ['maxRating' => $this->getMaxRating()])
6265
@endif
6366
{{-- tiptap editor --}}
6467
<div @class([
@@ -90,56 +93,16 @@ class="comm:mt-2"
9093
</div>
9194
</div>
9295
@else
93-
@if ($comment->isComment() && $comment->rating)
94-
<div
95-
class="comm:mt-1 comm:flex comm:items-center comm:gap-0.5"
96-
role="img"
97-
title="{{ $comment->rating }}/{{ $this->getMaxRating() }}"
98-
aria-label="{{ __('commentions::comments.rating_display_label', ['rating' => $comment->rating, 'max' => $this->getMaxRating()]) }}"
99-
>
100-
@for ($ratingStar = 1; $ratingStar <= $this->getMaxRating(); $ratingStar++)
101-
<x-filament::icon
102-
icon="heroicon-s-star"
103-
@class([
104-
'comm:h-4 comm:w-4',
105-
'comm:text-amber-400' => $ratingStar <= $comment->rating,
106-
'comm:text-gray-300 comm:dark:text-gray-600' => $ratingStar > $comment->rating,
107-
])
108-
/>
109-
@endfor
110-
</div>
111-
@endif
96+
@include('commentions::partials.ratings.show-comment-rating', ['comment' => $comment])
11297

11398
<div @class([
11499
'comm:mt-1 comm:space-y-6 comm:text-sm comm:text-gray-800 comm:dark:text-gray-200 commentions-comment-body comm:break-words',
115100
'tip-tap-toolbar-enabled' => config('commentions.toolbar.enabled', true),
116101
])>{!! $comment->getParsedBody() !!}</div>
117102

118-
@if ($comment->isComment() && $comment->attachments->isNotEmpty())
119-
<div class="comm:mt-2 comm:flex comm:flex-wrap comm:gap-2">
120-
@foreach ($comment->attachments as $attachment)
121-
@if ($attachment->isImage())
122-
<a href="{{ $attachment->getUrl() }}" target="_blank" rel="noopener">
123-
<img
124-
src="{{ $attachment->getUrl() }}"
125-
alt="{{ $attachment->filename }}"
126-
class="comm:h-20 comm:w-20 comm:rounded-lg comm:border comm:border-gray-200 comm:dark:border-gray-700 comm:object-cover"
127-
/>
128-
</a>
129-
@else
130-
<a
131-
href="{{ $attachment->getUrl() }}"
132-
target="_blank"
133-
rel="noopener"
134-
class="comm:inline-flex comm:items-center comm:gap-1 comm:rounded-lg comm:border comm:border-gray-200 comm:dark:border-gray-700 comm:px-2 comm:py-1 comm:text-xs comm:text-gray-700 comm:dark:text-gray-200 comm:hover:bg-gray-100 comm:dark:hover:bg-gray-800"
135-
>
136-
<x-filament::icon icon="heroicon-s-paper-clip" class="comm:h-4 comm:w-4" />
137-
<span class="comm:max-w-[12rem] comm:truncate">{{ $attachment->filename }}</span>
138-
</a>
139-
@endif
140-
@endforeach
141-
</div>
142-
@endif
103+
@include('commentions::partials.attachments.show-comment-attachments', [
104+
'comment' => $comment,
105+
])
143106

144107
@if ($comment->isComment())
145108
<livewire:dynamic-component
@@ -151,5 +114,5 @@ class="comm:inline-flex comm:items-center comm:gap-1 comm:rounded-lg comm:border
151114
@endif
152115
</div>
153116

154-
<x-filament-actions::modals />
117+
<x-filament-actions::modals/>
155118
</div>

0 commit comments

Comments
 (0)