feat(plugins/sponsors): add list support to plugin_sponsors_sections (#1011) [skip ci]

This commit is contained in:
Simon Lecoq
2022-04-23 22:00:47 +02:00
committed by GitHub
parent a6104cb98c
commit 14f14d9f4d
4 changed files with 34 additions and 22 deletions

View File

@@ -14,7 +14,7 @@ export default async function({login, q, imports, data, graphql, queries, accoun
const {[account]:{sponsorsListing:{fullDescription, activeGoal}}} = await graphql(queries.sponsors.description({login, account})) const {[account]:{sponsorsListing:{fullDescription, activeGoal}}} = await graphql(queries.sponsors.description({login, account}))
const about = await imports.markdown(fullDescription, {mode:"multiline"}) const about = await imports.markdown(fullDescription, {mode:"multiline"})
const goal = activeGoal ? {progress:activeGoal.percentComplete, title:activeGoal.title, description:await imports.markdown(activeGoal.description)} : null const goal = activeGoal ? {progress:activeGoal.percentComplete, title:activeGoal.title, description:await imports.markdown(activeGoal.description)} : null
const count = {active:{total:0, user:0, organization:0}, past:{total:0, user:0, organization:0}} const count = {total:{count:0, user:0, organization:0}, active:{total:0, user:0, organization:0}, past:{total:0, user:0, organization:0}}
//Query active sponsors //Query active sponsors
let list = [] let list = []
@@ -66,6 +66,11 @@ export default async function({login, q, imports, data, graphql, queries, accoun
} }
} }
//Update counters
count.total.count = count.active.total + count.past.total
count.total.user = count.active.user + count.past.user
count.total.organization = count.active.organization + count.past.organization
//Results //Results
list = list.sort((a, b) => a.past === b.past ? b.amount - a.amount : a.past - b.past) list = list.sort((a, b) => a.past === b.past ? b.amount - a.amount : a.past - b.past)
return {sections, about, list, count, goal} return {sections, about, list, count, goal}

View File

@@ -31,6 +31,7 @@ inputs:
values: values:
- goal - goal
- about - about
- list
plugin_sponsors_past: plugin_sponsors_past:
description: | description: |

View File

@@ -14,10 +14,11 @@
</section> </section>
</div> </div>
<% } else { %> <% } else { %>
<% for (const section of plugins.sponsors.sections) { %> <% for (const section of plugins.sponsors.sections) { if ((plugins.sponsors.sections.includes("goal"))&&(plugins.sponsors.sections.includes("list"))&&(section === "list")) continue%>
<% if ((section === "goal")&&(plugins.sponsors.goal)) { %> <% if ((section === "goal")||(section === "list")) { %>
<div class="fill-width"> <div class="fill-width">
<section class="sponsors goal"> <section class="sponsors goal">
<% if ((section === "goal")&&(plugins.sponsors.goal)) { %>
<div class="markdown"> <div class="markdown">
<%= plugins.sponsors.goal.description %> <%= plugins.sponsors.goal.description %>
</div> </div>
@@ -32,17 +33,22 @@
</svg> </svg>
</div> </div>
<% } %> <% } %>
<% } %>
<div class="goal-text"> <div class="goal-text">
<span> <span>
<% if (plugins.sponsors.count.active.total) { %> <% if (plugins.sponsors.count.active.total) { %>
<%= plugins.sponsors.count.active.total %> sponsor<%= plugins.sponsors.count.active.total !== 1 ? "s are" : " is" %> funding <%= user.login %>'s work <%= plugins.sponsors.count.active.total %> sponsor<%= plugins.sponsors.count.active.total !== 1 ? "s are" : " is" %> funding <%= user.login %>'s work
<% } %> <% } %>
</span> </span>
<% if ((section === "goal")&&(plugins.sponsors.goal)) { %>
<span><%= plugins.sponsors.goal.title %></span> <span><%= plugins.sponsors.goal.title %></span>
<% } %>
</div> </div>
<% if ((section === "list")||(plugins.sponsors.sections.includes("list"))) { %>
<div class="row"> <div class="row">
<% for (const user of plugins.sponsors.list) { %><img class="avatar <%= user.type === "organization" ? "organization" : "" %> <%= user.past ? "past" : "" %>" src="<%= user.avatar %>" width="24" height="24" alt="" /><% } %> <% for (const user of plugins.sponsors.list) { %><img class="avatar <%= user.type === "organization" ? "organization" : "" %> <%= user.past ? "past" : "" %>" src="<%= user.avatar %>" width="24" height="24" alt="" /><% } %>
</div> </div>
<% } %>
</section> </section>
</div> </div>
<% } else if (section === "about") { %> <% } else if (section === "about") { %>

View File

@@ -147,6 +147,9 @@
border-radius: 50%; border-radius: 50%;
margin: 0 6px; margin: 0 6px;
} }
.avatar.past {
filter: opacity(0.5);
}
.organization.avatar { .organization.avatar {
border-radius: 15%; border-radius: 15%;
@@ -1076,9 +1079,6 @@
.sponsors .avatar { .sponsors .avatar {
margin: 2px; margin: 2px;
} }
.sponsors .avatar.past {
opacity: 0.3;
}
/* Stackoverflow */ /* Stackoverflow */
.stackoverflow { .stackoverflow {