Skip to content

Commit 14f14d9

Browse files
authored
feat(plugins/sponsors): add list support to plugin_sponsors_sections (lowlighter#1011) [skip ci]
1 parent a6104cb commit 14f14d9

File tree

4 files changed

+34
-22
lines changed

4 files changed

+34
-22
lines changed

source/plugins/sponsors/index.mjs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default async function({login, q, imports, data, graphql, queries, accoun
1414
const {[account]:{sponsorsListing:{fullDescription, activeGoal}}} = await graphql(queries.sponsors.description({login, account}))
1515
const about = await imports.markdown(fullDescription, {mode:"multiline"})
1616
const goal = activeGoal ? {progress:activeGoal.percentComplete, title:activeGoal.title, description:await imports.markdown(activeGoal.description)} : null
17-
const count = {active:{total:0, user:0, organization:0}, past:{total:0, user:0, organization:0}}
17+
const count = {total:{count:0, user:0, organization:0}, active:{total:0, user:0, organization:0}, past:{total:0, user:0, organization:0}}
1818

1919
//Query active sponsors
2020
let list = []
@@ -66,6 +66,11 @@ export default async function({login, q, imports, data, graphql, queries, accoun
6666
}
6767
}
6868

69+
//Update counters
70+
count.total.count = count.active.total + count.past.total
71+
count.total.user = count.active.user + count.past.user
72+
count.total.organization = count.active.organization + count.past.organization
73+
6974
//Results
7075
list = list.sort((a, b) => a.past === b.past ? b.amount - a.amount : a.past - b.past)
7176
return {sections, about, list, count, goal}

source/plugins/sponsors/metadata.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ inputs:
3131
values:
3232
- goal
3333
- about
34+
- list
3435

3536
plugin_sponsors_past:
3637
description: |

source/templates/classic/partials/sponsors.ejs

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,41 @@
1414
</section>
1515
</div>
1616
<% } else { %>
17-
<% for (const section of plugins.sponsors.sections) { %>
18-
<% if ((section === "goal")&&(plugins.sponsors.goal)) { %>
17+
<% for (const section of plugins.sponsors.sections) { if ((plugins.sponsors.sections.includes("goal"))&&(plugins.sponsors.sections.includes("list"))&&(section === "list")) continue%>
18+
<% if ((section === "goal")||(section === "list")) { %>
1919
<div class="fill-width">
2020
<section class="sponsors goal">
21-
<div class="markdown">
22-
<%= plugins.sponsors.goal.description %>
23-
</div>
24-
<% { const width = 440 * (1 + large) %>
25-
<div class="center horizontal-wrap ">
26-
<svg class="bar" xmlns="http://www.w3.org/2000/svg" width="<%= width %>" height="8">
27-
<mask id="project-bar">
28-
<rect x="0" y="0" width="<%= width %>" height="8" fill="white" rx="5"/>
29-
</mask>
30-
<rect mask="url(#project-bar)" x="0" y="0" width="<%= (plugins.sponsors.goal.progress/100)*width %>" height="8" fill="#ec6cb9"/>
31-
<rect mask="url(#project-bar)" x="<%= (plugins.sponsors.goal.progress/100)*width %>" y="0" width="<%= ((100-plugins.sponsors.goal.progress)/100)*width %>" height="8" fill="#d1d5da"/>
32-
</svg>
21+
<% if ((section === "goal")&&(plugins.sponsors.goal)) { %>
22+
<div class="markdown">
23+
<%= plugins.sponsors.goal.description %>
3324
</div>
25+
<% { const width = 440 * (1 + large) %>
26+
<div class="center horizontal-wrap ">
27+
<svg class="bar" xmlns="http://www.w3.org/2000/svg" width="<%= width %>" height="8">
28+
<mask id="project-bar">
29+
<rect x="0" y="0" width="<%= width %>" height="8" fill="white" rx="5"/>
30+
</mask>
31+
<rect mask="url(#project-bar)" x="0" y="0" width="<%= (plugins.sponsors.goal.progress/100)*width %>" height="8" fill="#ec6cb9"/>
32+
<rect mask="url(#project-bar)" x="<%= (plugins.sponsors.goal.progress/100)*width %>" y="0" width="<%= ((100-plugins.sponsors.goal.progress)/100)*width %>" height="8" fill="#d1d5da"/>
33+
</svg>
34+
</div>
35+
<% } %>
3436
<% } %>
3537
<div class="goal-text">
3638
<span>
3739
<% if (plugins.sponsors.count.active.total) { %>
3840
<%= plugins.sponsors.count.active.total %> sponsor<%= plugins.sponsors.count.active.total !== 1 ? "s are" : " is" %> funding <%= user.login %>'s work
3941
<% } %>
4042
</span>
41-
<span><%= plugins.sponsors.goal.title %></span>
42-
</div>
43-
<div class="row">
44-
<% 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="" /><% } %>
43+
<% if ((section === "goal")&&(plugins.sponsors.goal)) { %>
44+
<span><%= plugins.sponsors.goal.title %></span>
45+
<% } %>
4546
</div>
47+
<% if ((section === "list")||(plugins.sponsors.sections.includes("list"))) { %>
48+
<div class="row">
49+
<% 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="" /><% } %>
50+
</div>
51+
<% } %>
4652
</section>
4753
</div>
4854
<% } else if (section === "about") { %>

source/templates/classic/style.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@
147147
border-radius: 50%;
148148
margin: 0 6px;
149149
}
150+
.avatar.past {
151+
filter: opacity(0.5);
152+
}
150153

151154
.organization.avatar {
152155
border-radius: 15%;
@@ -1076,9 +1079,6 @@
10761079
.sponsors .avatar {
10771080
margin: 2px;
10781081
}
1079-
.sponsors .avatar.past {
1080-
opacity: 0.3;
1081-
}
10821082

10831083
/* Stackoverflow */
10841084
.stackoverflow {

0 commit comments

Comments
 (0)