Achievements plugin: add option to change display style (#473)

This commit is contained in:
Simon Lecoq
2021-08-12 19:09:13 +02:00
committed by GitHub
parent 2429c60723
commit 8c241b81cd
7 changed files with 89 additions and 11 deletions

View File

@@ -5,14 +5,14 @@
Achievements
</h2>
<div class="row">
<section class="largeable-flex-wrap">
<section class="achievements <%= plugins.achievements?.display ?? "" %> largeable-flex-wrap">
<% if (plugins.achievements.error) { %>
<div class="field error">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M2.343 13.657A8 8 0 1113.657 2.343 8 8 0 012.343 13.657zM6.03 4.97a.75.75 0 00-1.06 1.06L6.94 8 4.97 9.97a.75.75 0 101.06 1.06L8 9.06l1.97 1.97a.75.75 0 101.06-1.06L9.06 8l1.97-1.97a.75.75 0 10-1.06-1.06L8 6.94 6.03 4.97z"></path></svg>
<%= plugins.achievements.error.message %>
</div>
<% } else { %>
<% for (const {title, text, icon, rank, leaderboard = null, progress = 0, unlock = null} of plugins.achievements.list) { %>
<% for (const {prefix, title, text, icon, rank, value, leaderboard = null, progress = 0, unlock = null} of plugins.achievements.list) { %>
<div class="achievement <%= rank === "$" ? "secret" : rank.charAt(0).toLocaleLowerCase() %> largeable-width-half">
<div class="icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60" height="44" width="44">
@@ -32,12 +32,19 @@
</div>
<div class="info">
<div class="title">
<%= title %>
<span class="prefix"><%= prefix %></span> <%= prefix.length ? title.toLocaleLowerCase() : title %>
<% if (leaderboard) { %>
<span class="gh">
ranked <%= f(leaderboard.user) %> out of <%= f(leaderboard.total) %> <%= leaderboard.type %>
</span>
<% } %>
<% if (plugins.achievements.display === "compact") { %>
<div class="value-wrapper">
<div class="value">
<%= typeof value === "number" ? Math.floor(value) : value ? "☆" : "?" %>
</div>
</div>
<% } %>
</div>
<div class="text"><%= text %></div>
</div>