Skip to content

Commit

Permalink
style: added anonymous avatar to anon replies
Browse files Browse the repository at this point in the history
  • Loading branch information
joonhoswe committed Feb 26, 2025
1 parent 46c4ad3 commit 29735f6
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
24 changes: 15 additions & 9 deletions nodebb-theme-harmony/templates/partials/topic/post.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
</div>
{{{ end }}}
<div class="d-flex align-items-start gap-3">


<div class="bg-body d-none d-sm-block rounded-circle" style="outline: 2px solid var(--bs-body-bg);">
<a class="d-inline-block position-relative text-decoration-none" href="{{{ if ./user.userslug }}}{config.relative_path}/user/{./user.userslug}{{{ else }}}#{{{ end }}}" aria-label="[[aria:user-avatar-for, {./user.username}]]">
{{{ if !posts.anonymous }}}
{{{ if posts.anonymous }}}
<div class="avatar avatar-rounded border" style="width: 48px; height: 48px; background-color: #e9ecef; display: flex; align-items: center; justify-content: center;">
<i class="fa fa-user-secret fa-2x"></i>
</div>
{{{ else }}}
{buildAvatar(posts.user, "48px", true, "", "user/picture")}
<span component="user/status" class="position-absolute translate-middle-y border border-white border-2 rounded-circle status {posts.user.status}"><span class="visually-hidden">[[global:{posts.user.status}]]</span></span>
{{{ end }}}
{{{ end }}}
</a>
</div>

Expand All @@ -28,20 +30,24 @@

<div class="bg-body d-sm-none">
<a class="d-inline-block position-relative text-decoration-none" href="{{{ if ./user.userslug }}}{config.relative_path}/user/{./user.userslug}{{{ else }}}#{{{ end }}}">
{{{ if !posts.anonymous }}}
{{{ if posts.anonymous }}}
<div class="avatar avatar-rounded border" style="width: 20px; height: 20px; background-color: #e9ecef; display: flex; align-items: center; justify-content: center;">
<i class="fa fa-user-secret"></i>
</div>
{{{ else }}}
{buildAvatar(posts.user, "20px", true, "", "user/picture")}
<span component="user/status" class="position-absolute translate-middle-y border border-white border-2 rounded-circle status {posts.user.status}"><span class="visually-hidden">[[global:{posts.user.status}]]</span></span>
{{{ end }}}
{{{ end }}}
</a>
</div>


<!-- changes here -->

{{{ if posts.anonymous }}}
<span>ANONYMOUS</span>
{{{ else }}}
<a class="fw-bold text-nowrap" href="{{{ if ./user.userslug }}}{config.relative_path}/user/{./user.userslug}{{{ else }}}#{{{ end }}}" data-username="{posts.user.username}" data-uid="{posts.user.uid}">{posts.user.displayname}</a>
<span class="fw-bold text-nowrap">Anonymous</span>
{{{ else }}}
<a class="fw-bold text-nowrap" href="{{{ if ./user.userslug }}}{config.relative_path}/user/{./user.userslug}{{{ else }}}#{{{ end }}}" data-username="{posts.user.username}" data-uid="{posts.user.uid}">{posts.user.displayname}</a>
{{{ end }}}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<div class="d-flex justify-content-end gap-2">
<button type="submit" component="topic/quickreply/expand" class="btn-ghost-sm border" title="[[topic:open-composer]]"><i class="fa fa-expand"></i></button>
<button type="submit" component="topic/quickreply/button" class="btn btn-sm btn-primary">[[topic:post-quick-reply]]</button>
<button type="submit" component="topic/quickreply/button2" class="btn btn-sm btn-primary">[[topic:post-quick-reply2]]</button>
<button type="submit" component="topic/quickreply/button2" class="btn btn-sm btn-secondary"><i class="fa fa-user-secret"></i> [[topic:post-quick-reply2]]</button>
</div>
</div>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</button>
<ul class="dropdown-menu dropdown-menu-end p-1 text-sm" role="menu">
<li><a class="dropdown-item rounded-1" href="#" component="topic/reply-as-topic" role="menuitem">[[topic:reply-as-topic]]</a></li>
<li><a class="dropdown-item rounded-1" href="#" component="topic/reply-as-topic" role="menuitem"> Reply anonymously </a></li>
<li><a class="dropdown-item rounded-1" href="#" component="topic/reply-anonymously" role="menuitem">[[topic:reply-anonymously]]</a></li>
</ul>
</div>
{{{ end }}}
Expand Down
12 changes: 12 additions & 0 deletions public/src/client/topic/postTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,18 @@ define('forum/topic/postTools', [
});
});

// Add anonymous reply handler
$('.topic').on('click', '[component="topic/reply-anonymously"]', function () {
showStaleWarning(async function () {
hooks.fire('action:composer.post.new', {
tid: tid,
handle: 1, // Set handle to 1 to mark as anonymous
title: ajaxify.data.titleRaw,
body: $('[component="topic/quickreply/text"]').val() || '',
});
});
});

postContainer.on('click', '[component="post/bookmark"]', function () {
return bookmarkPost($(this), getData($(this), 'data-pid'));
});
Expand Down

0 comments on commit 29735f6

Please sign in to comment.