Add achievements plugin (#182)

This commit is contained in:
Simon Lecoq
2021-03-12 14:33:07 +01:00
committed by GitHub
parent 161c0bd5bc
commit 7c43e871cd
16 changed files with 728 additions and 1 deletions

View File

@@ -23,5 +23,6 @@
"anilist",
"wakatime",
"skyline",
"stackoverflow"
"stackoverflow",
"achievements"
]

View File

@@ -0,0 +1,45 @@
<% if (plugins.achievements) { %>
<section>
<h2 class="field">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M8.5.75a.75.75 0 00-1.5 0v5.19L4.391 3.33a.75.75 0 10-1.06 1.061L5.939 7H.75a.75.75 0 000 1.5h5.19l-2.61 2.609a.75.75 0 101.061 1.06L7 9.561v5.189a.75.75 0 001.5 0V9.56l2.609 2.61a.75.75 0 101.06-1.061L9.561 8.5h5.189a.75.75 0 000-1.5H9.56l2.61-2.609a.75.75 0 00-1.061-1.06L8.5 5.939V.75z"></path></svg>
Achievements
</h2>
<div class="row">
<section>
<% 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, gh = NaN, progress = 0, unlock = null} of plugins.achievements.list) { %>
<div class="achievement <%= rank === "$" ? "secret" : rank.charAt(0).toLocaleLowerCase() %>">
<div class="icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52" width="44" height="44">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 120" width="50" height="50" class="gauge info">
<circle class="gauge-base" r="53" cx="60" cy="60"></circle>
<% if ((progress)||(rank !== "X")) { %>
<circle class="gauge-arc" transform="rotate(-90 60 60)" r="53" cx="60" cy="60" stroke-dasharray="<%= progress * 329 %> 329"></circle>
<% } %>
</svg>
<svg width="40" height="40" viewBox="0 0 56 56" x="5" y="5" xmlns="http://www.w3.org/2000/svg"><%- icon %></svg>
</svg>
</div>
<div class="info">
<div class="title">
<%= title %>
<% if ((Number.isFinite(gh))&&(gh < 100000)) { %>
<span class="gh">
Top <%= gh %>
</span>
<% } %>
</div>
<div class="text"><%= text %></div>
</div>
</div>
<% } %>
<% } %>
</section>
</div>
</section>
<% } %>

View File

@@ -836,6 +836,64 @@
width: 400px;
}
/* Achievements */
.achievement {
display: flex;
margin: 4px 0;
}
.achievement .icon {
margin: 0 4px;
width: 44px;
height: 44px;
}
.achievement .text {
font-size: 12px;
color: #666666;
}
.achievement .unlock {
font-size: 9px;
color: #666666;
}
.achievement .title {
font-size: 14px;
color: #58A6FF;
}
.achievement.x .title {
color: #666666;
}
.achievement.x .icon {
filter: grayscale(1) opacity(.5);
}
.achievement.b .title {
color: #9D8FFF;
}
.achievement.b .icon {
filter: hue-rotate(35deg);
}
.achievement.a .title {
color: #D79533;
}
.achievement.a .icon {
filter: sepia() saturate(2);
}
.achievement.s .title {
color: #FF0000;
}
.achievement.s .icon {
filter: sepia() saturate(100);
}
.achievement.secret .title{
color: #FF76CD;
}
.achievement.secret .icon {
filter: hue-rotate(100deg);
}
.achievement .gh {
border: 1px solid currentColor;
border-radius: 16px;
font-size: 10px;
padding: 0 5px;
}
/* Fade animation */
.af {