Skip to content

Commit 19e39dd

Browse files
committed
Comments: Updated reply-to and general styling
Updated reply inidicator to fit with new nesting system, only showing on view when nest within nesting structure. Updated the general design to be a bit cleaner and better adapt on mobile. Tested on FF+Chrome, inc. dark mode.
1 parent 3bede42 commit 19e39dd

File tree

6 files changed

+98
-69
lines changed

6 files changed

+98
-69
lines changed

lang/en/entities.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@
365365
'comment_new' => 'New Comment',
366366
'comment_created' => 'commented :createDiff',
367367
'comment_updated' => 'Updated :updateDiff by :username',
368+
'comment_updated_indicator' => 'Updated',
368369
'comment_deleted_success' => 'Comment deleted',
369370
'comment_created_success' => 'Comment added',
370371
'comment_updated_success' => 'Comment updated',

resources/js/components/page-comment.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,22 @@ export class PageComment extends Component {
2525
}
2626

2727
setupListeners() {
28-
this.replyButton.addEventListener('click', () => this.$emit('reply', {
29-
id: this.commentLocalId,
30-
element: this.container,
31-
}));
32-
this.editButton.addEventListener('click', this.startEdit.bind(this));
33-
this.deleteButton.addEventListener('click', this.delete.bind(this));
34-
this.form.addEventListener('submit', this.update.bind(this));
35-
this.formCancel.addEventListener('click', () => this.toggleEditMode(false));
28+
if (this.replyButton) {
29+
this.replyButton.addEventListener('click', () => this.$emit('reply', {
30+
id: this.commentLocalId,
31+
element: this.container,
32+
}));
33+
}
34+
35+
if (this.editButton) {
36+
this.editButton.addEventListener('click', this.startEdit.bind(this));
37+
this.form.addEventListener('submit', this.update.bind(this));
38+
this.formCancel.addEventListener('click', () => this.toggleEditMode(false));
39+
}
40+
41+
if (this.deleteButton) {
42+
this.deleteButton.addEventListener('click', this.delete.bind(this));
43+
}
3644
}
3745

3846
toggleEditMode(show) {

resources/js/components/page-comments.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export class PageComments extends Component {
1616
this.formContainer = this.$refs.formContainer;
1717
this.form = this.$refs.form;
1818
this.formInput = this.$refs.formInput;
19+
this.formReplyLink = this.$refs.formReplyLink;
1920
this.addCommentButton = this.$refs.addCommentButton;
2021
this.hideFormButton = this.$refs.hideFormButton;
2122
this.removeReplyToButton = this.$refs.removeReplyToButton;
@@ -26,6 +27,7 @@ export class PageComments extends Component {
2627

2728
// Internal State
2829
this.parentId = null;
30+
this.formReplyText = this.formReplyLink.textContent;
2931

3032
this.setupListeners();
3133
}
@@ -86,13 +88,15 @@ export class PageComments extends Component {
8688

8789
resetForm() {
8890
this.formInput.value = '';
89-
this.removeReplyTo();
91+
this.parentId = null;
92+
this.replyToRow.toggleAttribute('hidden', true);
9093
this.container.append(this.formContainer);
9194
}
9295

9396
showForm() {
9497
this.formContainer.toggleAttribute('hidden', false);
9598
this.addButtonContainer.toggleAttribute('hidden', true);
99+
this.formContainer.scrollIntoView({behavior: 'smooth', block: 'nearest'});
96100
setTimeout(() => {
97101
this.formInput.focus();
98102
}, 100);
@@ -115,19 +119,20 @@ export class PageComments extends Component {
115119

116120
setReply(commentLocalId, commentElement) {
117121
const targetFormLocation = commentElement.closest('.comment-branch').querySelector('.comment-branch-children');
118-
this.showForm();
119122
targetFormLocation.append(this.formContainer);
120-
this.formContainer.scrollIntoView({behavior: 'smooth', block: 'nearest'});
123+
this.showForm();
121124
this.parentId = commentLocalId;
122125
this.replyToRow.toggleAttribute('hidden', false);
123126
const replyLink = this.replyToRow.querySelector('a');
124-
replyLink.textContent = `#${this.parentId}`;
127+
replyLink.textContent = this.formReplyText.replace('1234', this.parentId);
125128
replyLink.href = `#comment${this.parentId}`;
126129
}
127130

128131
removeReplyTo() {
129132
this.parentId = null;
130133
this.replyToRow.toggleAttribute('hidden', true);
134+
this.container.append(this.formContainer);
135+
this.showForm();
131136
}
132137

133138
}

resources/sass/_components.scss

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -691,26 +691,28 @@ body.flexbox-support #entity-selector-wrap .popup-body .form-group {
691691
.actions button:focus {
692692
outline: 1px dotted var(--color-primary);
693693
}
694+
@include smaller-than($m) {
695+
.actions {
696+
opacity: 1;
697+
}
698+
}
694699
}
695700

696701
.comment-box .header {
697-
.meta {
698-
img, a, span {
699-
display: inline-block;
700-
vertical-align: top;
701-
}
702-
a, span {
703-
padding: $-xxs 0 $-xxs 0;
704-
line-height: 1.6;
705-
}
706-
a { color: #666; }
707-
span {
708-
padding-inline-start: $-xxs;
709-
}
702+
border-bottom: 1px solid #DDD;
703+
@include lightDark(border-color, #DDD, #000);
704+
button {
705+
font-size: .8rem;
706+
}
707+
a {
708+
color: inherit;
710709
}
711710
.text-muted {
712711
color: #999;
713712
}
713+
.right-meta .text-muted {
714+
opacity: .8;
715+
}
714716
}
715717

716718
.comment-thread-indicator {
@@ -725,6 +727,14 @@ body.flexbox-support #entity-selector-wrap .popup-body .form-group {
725727
display: none;
726728
}
727729

730+
.comment-reply {
731+
display: none;
732+
}
733+
734+
.comment-branch .comment-branch .comment-branch .comment-branch .comment-reply {
735+
display: block;
736+
}
737+
728738
#tag-manager .drag-card {
729739
max-width: 500px;
730740
}

resources/views/comments/comment.blade.php

Lines changed: 46 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,63 +7,68 @@
77
id="comment{{$comment->local_id}}"
88
class="comment-box">
99
<div class="header p-s">
10-
<div class="grid half left-focus no-gap v-center">
11-
<div class="meta text-muted text-small">
12-
<a href="#comment{{$comment->local_id}}">#{{$comment->local_id}}</a>
13-
&nbsp;&nbsp;
10+
<div class="flex-container-row justify-space-between wrap">
11+
<div class="meta text-muted flex-container-row items-center">
1412
@if ($comment->createdBy)
15-
<img width="50" src="{{ $comment->createdBy->getAvatar(50) }}" class="avatar" alt="{{ $comment->createdBy->name }}">
13+
<img width="50" src="{{ $comment->createdBy->getAvatar(50) }}" class="avatar mx-xs" alt="{{ $comment->createdBy->name }}">
1614
&nbsp;
17-
<a href="{{ $comment->createdBy->getProfileUrl() }}">{{ $comment->createdBy->name }}</a>
15+
<a href="{{ $comment->createdBy->getProfileUrl() }}">{{ $comment->createdBy->getShortName(16) }}</a>
1816
@else
19-
<span>{{ trans('common.deleted_user') }}</span>
17+
{{ trans('common.deleted_user') }}
2018
@endif
21-
<span title="{{ $comment->created_at }}">{{ trans('entities.comment_created', ['createDiff' => $comment->created]) }}</span>
19+
<span title="{{ $comment->created_at }}">&nbsp;{{ trans('entities.comment_created', ['createDiff' => $comment->created]) }}</span>
2220
@if($comment->isUpdated())
23-
<span title="{{ $comment->updated_at }}">
24-
&bull;&nbsp;
25-
{{ trans('entities.comment_updated', ['updateDiff' => $comment->updated, 'username' => $comment->updatedBy? $comment->updatedBy->name : trans('common.deleted_user')]) }}
26-
</span>
21+
<span class="mx-xs">&bull;</span>
22+
<span title="{{ trans('entities.comment_updated', ['updateDiff' => $comment->updated_at, 'username' => $comment->updatedBy->name ?? trans('common.deleted_user')]) }}">
23+
{{ trans('entities.comment_updated_indicator') }}
24+
</span>
2725
@endif
2826
</div>
29-
<div class="actions text-right">
30-
@if(userCan('comment-update', $comment))
31-
<button refs="page-comment@edit-button" type="button" class="text-button icon p-xs" aria-label="{{ trans('common.edit') }}" title="{{ trans('common.edit') }}">@icon('edit')</button>
32-
@endif
33-
@if(userCan('comment-create-all'))
34-
<button refs="page-comment@reply-button" type="button" class="text-button icon p-xs" aria-label="{{ trans('common.reply') }}" title="{{ trans('common.reply') }}">@icon('reply')</button>
35-
@endif
36-
@if(userCan('comment-delete', $comment))
37-
<div component="dropdown" class="dropdown-container">
38-
<button type="button" refs="dropdown@toggle" aria-haspopup="true" aria-expanded="false" class="text-button icon p-xs" title="{{ trans('common.delete') }}">@icon('delete')</button>
39-
<ul refs="dropdown@menu" class="dropdown-menu" role="menu">
40-
<li class="px-m text-small text-muted pb-s">{{trans('entities.comment_delete_confirm')}}</li>
41-
<li>
42-
<button refs="page-comment@delete-button" type="button" class="text-button text-neg icon-item">
43-
@icon('delete')
44-
<div>{{ trans('common.delete') }}</div>
45-
</button>
46-
</li>
47-
</ul>
48-
</div>
49-
@endif
27+
<div class="right-meta flex-container-row justify-flex-end items-center px-s">
28+
<div class="actions mr-s">
29+
@if(userCan('comment-create-all'))
30+
<button refs="page-comment@reply-button" type="button" class="text-button text-muted hover-underline p-xs">@icon('reply') {{ trans('common.reply') }}</button>
31+
@endif
32+
@if(userCan('comment-update', $comment))
33+
<button refs="page-comment@edit-button" type="button" class="text-button text-muted hover-underline p-xs">@icon('edit') {{ trans('common.edit') }}</button>
34+
@endif
35+
@if(userCan('comment-delete', $comment))
36+
<div component="dropdown" class="dropdown-container">
37+
<button type="button" refs="dropdown@toggle" aria-haspopup="true" aria-expanded="false" class="text-button text-muted hover-underline p-xs">@icon('delete') {{ trans('common.delete') }}</button>
38+
<ul refs="dropdown@menu" class="dropdown-menu" role="menu">
39+
<li class="px-m text-small text-muted pb-s">{{trans('entities.comment_delete_confirm')}}</li>
40+
<li>
41+
<button refs="page-comment@delete-button" type="button" class="text-button text-neg icon-item">
42+
@icon('delete')
43+
<div>{{ trans('common.delete') }}</div>
44+
</button>
45+
</li>
46+
</ul>
47+
</div>
48+
@endif
49+
<span class="text-muted">
50+
&nbsp;&bull;&nbsp;
51+
</span>
52+
</div>
53+
<div>
54+
<a class="bold text-muted" href="#comment{{$comment->local_id}}">#{{$comment->local_id}}</a>
55+
</div>
5056
</div>
5157
</div>
5258

5359
</div>
5460

55-
@if ($comment->parent_id)
56-
<div class="reply-row primary-background-light text-muted px-s py-xs mb-s">
57-
{!! trans('entities.comment_in_reply_to', ['commentId' => '<a href="#comment'.$comment->parent_id.'">#'.$comment->parent_id.'</a>']) !!}
58-
</div>
59-
@endif
60-
61-
<div refs="page-comment@content-container" class="content px-s pb-s">
61+
<div refs="page-comment@content-container" class="content px-m py-s">
62+
@if ($comment->parent_id)
63+
<p class="comment-reply mb-xxs">
64+
<a class="text-muted text-small" href="#comment{{ $comment->parent_id }}">@icon('reply'){{ trans('entities.comment_in_reply_to', ['commentId' => '#' . $comment->parent_id]) }}</a>
65+
</p>
66+
@endif
6267
{!! $comment->html !!}
6368
</div>
6469

6570
@if(userCan('comment-update', $comment))
66-
<form novalidate refs="page-comment@form" hidden class="content px-s block">
71+
<form novalidate refs="page-comment@form" hidden class="content pt-s px-s block">
6772
<div class="form-group description-input">
6873
<textarea refs="page-comment@input" name="markdown" rows="3" placeholder="{{ trans('entities.comment_placeholder') }}">{{ $comment->text }}</textarea>
6974
</div>

resources/views/comments/create.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
<div class="comment-box">
33

44
<div class="header p-s">{{ trans('entities.comment_new') }}</div>
5-
<div refs="page-comments@reply-to-row" hidden class="primary-background-light text-muted px-s py-xs mb-s">
5+
<div refs="page-comments@reply-to-row" hidden class="primary-background-light text-muted px-s py-xs">
66
<div class="grid left-focus v-center">
77
<div>
8-
{!! trans('entities.comment_in_reply_to', ['commentId' => '<a href=""></a>']) !!}
8+
<a refs="page-comments@form-reply-link" href="#">{{ trans('entities.comment_in_reply_to', ['commentId' => '1234']) }}</a>
99
</div>
1010
<div class="text-right">
1111
<button refs="page-comments@remove-reply-to-button" class="text-button">{{ trans('common.remove') }}</button>
1212
</div>
1313
</div>
1414
</div>
1515

16-
<div class="content px-s">
16+
<div class="content px-s pt-s">
1717
<form refs="page-comments@form" novalidate>
1818
<div class="form-group description-input">
1919
<textarea refs="page-comments@form-input" name="markdown"

0 commit comments

Comments
 (0)