Skip to content

Commit

Permalink
[site] only show 20 avatars instead of current massive wall (#6974)
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann authored Dec 1, 2021
1 parent fe36911 commit c2149e8
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 31 deletions.
6 changes: 4 additions & 2 deletions site/scripts/get_contributors.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ if (!force && fs.existsSync(outputFile)) {
const base = `https://api.github.com/repos/sveltejs/svelte/contributors`;
const { GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET } = process.env;

const SIZE = 64;
const MAX = 20;
const SIZE = 128;

async function main() {
const contributors = [];
Expand All @@ -37,7 +38,8 @@ async function main() {

const authors = contributors
.filter(({ login }) => !login.includes('[bot]'))
.sort((a, b) => b.contributions - a.contributions);
.sort((a, b) => b.contributions - a.contributions)
.slice(0, MAX);

const sprite = new Jimp(SIZE * authors.length, SIZE);

Expand Down
10 changes: 6 additions & 4 deletions site/scripts/get_donors.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ if (!force && fs.existsSync(outputFile)) {
process.exit(0);
}

const SIZE = 64;
const MAX = 20;
const SIZE = 128;

async function main() {
const res = await fetch('https://opencollective.com/svelte/members/all.json');
Expand All @@ -28,12 +29,13 @@ async function main() {

let backers = [...unique.values()]
.filter(({ role }) => role === 'BACKER')
.sort((a, b) => b.totalAmountDonated - a.totalAmountDonated);
.sort((a, b) => b.totalAmountDonated - a.totalAmountDonated)
.slice(0, 3 * MAX);

const included = [];
for (let i = 0; i < backers.length; i += 1) {
for (let i = 0; included.length < MAX; i += 1) {
const backer = backers[i];
console.log(`${i} / ${backers.length}: ${backer.name}`);
console.log(`${included.length + 1} / ${MAX}: ${backer.name}`);

try {
const image_data = await fetch(backer.image);
Expand Down
30 changes: 19 additions & 11 deletions site/src/routes/_components/Contributors.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,32 @@
</script>

<style>
#contributors {
margin: 0.4em 0;
}
.contributor {
width: 2.4em;
height: 2.4em;
width: 4.2em;
height: 4.2em;
border-radius: 50%;
text-indent: -9999px;
display: inline-block;
background: no-repeat url(/contributors.jpg);
background-size: auto 102%;
margin: 0 0.5em 0.5em 0;
margin: 0 1.5em 1.5em 0;
border: 2px solid var(--second);
}
</style>

{#each contributors as contributor, i}
<a
class="contributor"
style="background-position: {(100 * i) / (contributors.length - 1)}% 0"
href="https://github.com/{contributor}">
{contributor}
</a>
{/each}
<div id="contributors">
{#each contributors as contributor, i}
<a
class="contributor"
style="background-position: {(100 * i) / (contributors.length - 1)}% 0"
href="https://github.com/{contributor}">
{contributor}
</a>
{/each}
</div>

<p>And so <a href="https://github.com/sveltejs/svelte/graphs/contributors">many more →</a></p>
32 changes: 20 additions & 12 deletions site/src/routes/_components/Donors.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,33 @@
</script>

<style>
#donors {
margin: 0.4em 0;
}
.donor {
width: 2.4em;
height: 2.4em;
width: 4.2em;
height: 4.2em;
border-radius: 50%;
text-indent: -9999px;
display: inline-block;
background: no-repeat url(/donors.jpg);
background-size: auto 102%;
margin: 0 0.5em 0.5em 0;
margin: 0 1.5em 1.5em 0;
border: 2px solid var(--second);
}
</style>

{#each donors as donor, i}
<a
class="donor"
style="background-position: {(100 * i) / (donors.length - 1)}% 0"
alt="{donor}"
href="https://opencollective.com/svelte">
{donor}
</a>
{/each}
<div id="donors">
{#each donors as donor, i}
<a
class="donor"
style="background-position: {(100 * i) / (donors.length - 1)}% 0"
alt="{donor}"
href="https://opencollective.com/svelte">
{donor}
</a>
{/each}
</div>

<p>And so <a href="https://opencollective.com/svelte">many more →</a></p>
4 changes: 2 additions & 2 deletions site/src/routes/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ npm run dev

<p>Svelte is free and open source software, made possible by the work of hundreds of volunteers and donors. <a href="https://github.com/sveltejs/svelte">Join us</a> or <a href="https://opencollective.com/svelte">give</a>!</p>

<h3>Contributors</h3>
<h4>Contributors</h4>

<Contributors/>

<p></p>

<h3>Donors</h3>
<h4>Donors</h4>

<Donors/>
</Section>

0 comments on commit c2149e8

Please sign in to comment.