Add support to display both count and percentage on reaction plugins

This commit is contained in:
lowlighter
2021-03-11 12:49:32 +01:00
parent a2215a0c52
commit d3103287f0
5 changed files with 34 additions and 19 deletions

View File

@@ -41,10 +41,23 @@
<% } %>
<% } %>
</svg>
<% if (plugins.reactions.details === "percentage") { %>
<span class="title"><%= Math.round(score*100) %><small>%</small></span>
<% } else if (plugins.reactions.details === "count") { %>
<span class="title"><%= count %></span>
<% if (plugins.reactions.details.length) { const [primary, secondary] = plugins.reactions.details %>
<span class="title">
<% if (primary === "count") { %>
<%= count %>
<% } else if (primary === "percentage") { %>
<%= Math.round(score*100) %><small>%</small>
<% } %>
<% if (secondary) { %>
<small>
<% if (secondary === "count") { %>
(<%= count %>)
<% } else if (secondary === "percentage") { %>
(<%= Math.round(score*100) %><small>%</small>)
<% } %>
</small>
<% } %>
</span>
<% } %>
</div>
<% } %>