Skip to content

Commit 6cdeed0

Browse files
sokraskipjack
authored andcommitted
feat(support): display supporters in categories (#1466)
Add `platinum`, `gold`, `silver`, and `bronze` rankings. Change logo size based on `rank`. Ignore all `support.jsx` element urls as some class changes broke the current ignore rules.
1 parent bba60b2 commit 6cdeed0

File tree

4 files changed

+77
-18
lines changed

4 files changed

+77
-18
lines changed

components/splash/splash.jsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,21 @@ export default props => {
3131

3232
<p>Through contributions, donations, and sponsorship, you allow webpack to thrive. Your donations directly support office hours, continued enhancements, and most importantly, great documentation and learning material!</p>
3333

34-
<h2>Sponsors</h2>
35-
<Support number={ 100 } type="sponsors" />
34+
<h2>Platinum Sponsors</h2>
35+
<Support type="sponsors" rank="platinum" />
36+
37+
<h2>Gold Sponsors</h2>
38+
<Support type="sponsors" rank="gold" />
39+
40+
<h2>Silver Sponsors</h2>
41+
<Support type="sponsors" rank="silver" />
42+
43+
<h2>Bronze Sponsors</h2>
44+
<Support type="sponsors" rank="bronze" />
3645

3746
<h2>Backers</h2>
38-
<Support number={ 130 } type="backers" />
47+
<Support type="backers" />
48+
3949
</Container>
4050
</div>
4151
</div>

components/support/support-style.scss

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,40 @@
88

99
&__item {
1010
position: relative;
11-
margin: 0 5px 5px 5px;
11+
margin: 0 2px 2px 2px;
1212
}
1313

1414
&__sponsors-avatar {
15-
height: 64px;
15+
&-bronze, &-normal {
16+
height: 32px;
17+
}
18+
&-silver {
19+
height: 64px;
20+
}
21+
&-gold {
22+
height: 96px;
23+
}
24+
&-platinum {
25+
height: 128px;
26+
}
1627
}
1728

18-
&__backers-avatar {
19-
width: 62px;
20-
height: 62px;
29+
&__backers-avatar-normal {
30+
width: 31px;
31+
height: 31px;
2132
border-radius: 50%;
22-
border: 2px solid white;
33+
border: 1px solid white;
2334
overflow: hidden;
2435
}
2536

2637
&__outline {
2738
position: absolute;
2839
top: 0;
29-
margin: -2px;
30-
width: calc(100% + 4px);
31-
height: calc(100% - 2px);
40+
margin: -1px;
41+
width: calc(100% + 2px);
42+
height: calc(100% - 4px);
3243
border-radius: 50%;
33-
border: 2px solid rgb(112, 202, 10);
44+
border: 1px solid rgb(112, 202, 10);
3445
}
3546

3647
&__bottom {

components/support/support.jsx

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,60 @@ import React from 'react';
22
import Additional from './support-additional.json';
33
import './support-style';
44

5+
const ranks = {
6+
bronze: {
7+
maximum: 2000
8+
},
9+
silver: {
10+
minimum: 2000,
11+
maximum: 10000
12+
},
13+
gold: {
14+
minimum: 10000,
15+
maximum: 50000
16+
},
17+
platinum: {
18+
minimum: 50000
19+
}
20+
};
21+
522
export default class Support extends React.Component {
623
render() {
7-
let { number, type } = this.props;
24+
let { rank, type } = this.props;
825
let supporters = require(`./support-${type}.json`);
926

1027
if (type === 'sponsors') {
28+
supporters = supporters.slice();
1129
supporters.push(...Additional);
1230
supporters.sort((a, b) => b.totalDonations - a.totalDonations);
1331
}
1432

33+
let minimum, maximum;
34+
35+
if (rank && ranks[rank]) {
36+
minimum = ranks[rank].minimum;
37+
maximum = ranks[rank].maximum;
38+
}
39+
40+
if (typeof minimum === 'number') {
41+
supporters = supporters.filter(item => item.totalDonations >= minimum * 100);
42+
}
43+
44+
if (typeof maximum === 'number') {
45+
supporters = supporters.filter(item => item.totalDonations < maximum * 100);
46+
}
47+
1548
return (
1649
<div className="support">
1750
{
18-
supporters.slice(0, number).map((supporter, index) => (
51+
supporters.map((supporter, index) => (
1952
<a key={ supporter.id || supporter.username || index }
2053
className="support__item"
2154
title={ `$${supporter.totalDonations / 100} by ${supporter.name || supporter.username}` }
2255
target="_blank"
2356
href={ supporter.website || `https://opencollective.com/${supporter.username}` }>
2457
{ supporter.avatar ? <img
25-
className={ `support__${type}-avatar` }
58+
className={ `support__${type}-avatar-${rank || 'normal'}` }
2659
src={ supporter.avatar }
2760
alt={ supporter.username ? `${supporter.username}'s avatar` : 'avatar' } /> :
2861
supporter.name }

scripts/check-links.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@ function checkLinks(args) {
2222
var name = null;
2323

2424
tap.on('complete', function(res) {
25-
const failures = res.failures.filter(failure => !failure.diag || !failure.diag.at ||
26-
!failure.diag.at.match(/class="(support__item|support__backers-avatar|support__sponsors-avatar)"/));
25+
const failures = res.failures.filter(failure => {
26+
return (
27+
!failure.diag ||
28+
!failure.diag.at ||
29+
!failure.diag.at.match(/class="support__[^"]*"/)
30+
);
31+
});
2732

2833
if (failures.length > 0) {
2934
console.log(formatFailures(failures));

0 commit comments

Comments
 (0)