Skip to content

Commit f8a4829

Browse files
committed
Display all contributors at the bottom, randomized
1 parent a61776d commit f8a4829

File tree

4 files changed

+130
-40
lines changed

4 files changed

+130
-40
lines changed

src/index.html

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -679,19 +679,14 @@ <h3>Additional File Formats</h3>
679679
<h2>Changelog</h2>
680680
</div>
681681

682+
<div class="container" id="contributors">
683+
<h2>Made possible by amazing people</h2>
684+
<p class="contributors-desc">Source 2 Viewer is open-source and built by volunteers. Every contribution helps make it better for everyone.</p>
685+
<div class="contributor-list" id="js-contributors"></div>
686+
</div>
687+
682688
<footer class="footer">
683-
<div class="container">
684-
<div class="footer-left">
685-
Available under the
686-
<a href="https://github.com/ValveResourceFormat/ValveResourceFormat/blob/master/LICENSE">MIT license</a>.<br>
687-
Created and maintained by <a href="https://github.com/ValveResourceFormat/ValveResourceFormat/graphs/contributors">various contributors</a>.
688-
</div>
689-
<div class="footer-right">
690-
This project is not affiliated with Valve Software.
691-
<br>
692-
Source 2 is a trademark and/or registered trademark of Valve Corporation.
693-
</div>
694-
</div>
689+
<div class="container">This project is not affiliated with Valve Software. Source 2 is a trademark and/or registered trademark of Valve Corporation.</div>
695690
</footer>
696691
</body>
697692
</html>

src/ru.html

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -373,16 +373,7 @@ <h3>Дополнительные форматы файлов</h3>
373373

374374
<footer class="footer">
375375
<div class="container">
376-
<div class="footer-left">
377-
Проект доступен по
378-
<a href="https://github.com/ValveResourceFormat/ValveResourceFormat/blob/master/LICENSE">лицензии MIT</a>.<br>
379-
Создается и поддерживается <a href="https://github.com/ValveResourceFormat/ValveResourceFormat/graphs/contributors">сообществом контрибьюторов</a>.
380-
</div>
381-
<div class="footer-right">
382-
Этот проект не связан с Valve Software.
383-
<br>
384-
Source 2 является товарным знаком и/или зарегистрированным товарным знаком Valve Corporation.
385-
</div>
376+
Этот проект не связан с Valve Software. Source 2 является товарным знаком и/или зарегистрированным товарным знаком Valve Corporation.
386377
</div>
387378
</footer>
388379
</body>

src/static/main.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,4 +295,69 @@ downloadBtn.addEventListener('click', () => {
295295
document.getElementById('js-thank-you')?.classList.add('visible');
296296
});
297297

298+
/** @param {HTMLElement} container */
299+
async function LoadContributors(container) {
300+
try {
301+
const response = await fetch(
302+
'https://api.github.com/repositories/42366054/contributors?per_page=100',
303+
);
304+
305+
if (!response.ok) {
306+
return;
307+
}
308+
309+
/** @type {{login: string, avatar_url: string, html_url: string, contributions: number, type: string}[]} */
310+
const contributors = await response.json();
311+
const shuffled = contributors.filter((c) => c.type !== 'Bot');
312+
313+
for (let i = shuffled.length - 1; i > 0; i--) {
314+
const j = Math.floor(Math.random() * (i + 1));
315+
[shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];
316+
}
317+
318+
const fragment = document.createDocumentFragment();
319+
320+
for (const c of shuffled) {
321+
const a = document.createElement('a');
322+
a.href = `https://github.com/ValveResourceFormat/ValveResourceFormat/commits?author=${c.login}`;
323+
a.target = '_blank';
324+
a.rel = 'noopener';
325+
a.className = 'contributor';
326+
327+
const img = document.createElement('img');
328+
img.src = `${c.avatar_url}&s=64`;
329+
img.alt = '';
330+
img.width = 32;
331+
img.height = 32;
332+
img.loading = 'lazy';
333+
334+
const name = document.createElement('span');
335+
name.className = 'contributor-name';
336+
name.textContent = c.login;
337+
338+
a.appendChild(img);
339+
a.appendChild(name);
340+
fragment.appendChild(a);
341+
}
342+
343+
container.appendChild(fragment);
344+
} catch (e) {
345+
console.error(e);
346+
}
347+
}
348+
298349
LoadReleases();
350+
351+
const contributorsContainer = document.getElementById('js-contributors');
352+
if (contributorsContainer) {
353+
const observer = new IntersectionObserver(
354+
(entries, obs) => {
355+
if (entries[0].isIntersecting) {
356+
obs.disconnect();
357+
LoadContributors(contributorsContainer);
358+
}
359+
},
360+
{ rootMargin: '400px' },
361+
);
362+
observer.observe(contributorsContainer);
363+
}

src/static/style.css

Lines changed: 57 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -622,33 +622,72 @@ a {
622622
}
623623
}
624624

625-
.footer {
626-
margin: 3rem auto;
627-
line-height: 1.75;
628-
color: #ccc;
625+
#contributors {
626+
padding: 2rem 0 3rem;
629627

630-
.container {
631-
display: flex;
632-
justify-content: space-between;
633-
align-items: end;
634-
gap: 1rem;
628+
h2 {
629+
font-size: 2.5rem;
630+
font-weight: 700;
631+
color: #fff;
632+
text-align: center;
633+
margin: 0 0 1.5rem 0;
635634
}
636635

637-
.footer-right {
638-
text-align: right;
636+
.contributors-desc {
637+
margin: -1rem 0 1.25rem;
638+
font-size: 0.9rem;
639+
color: rgb(255 255 255 / 70%);
640+
text-align: center;
639641
}
640642

641-
@media (max-width: 840px) {
642-
.container {
643-
flex-direction: column;
644-
align-items: unset;
643+
.contributor-list {
644+
display: flex;
645+
flex-wrap: wrap;
646+
gap: 0.5rem;
647+
justify-content: center;
648+
min-height: 200px;
649+
}
650+
651+
.contributor {
652+
display: flex;
653+
align-items: center;
654+
gap: 0.6rem;
655+
padding: 0.4rem 0.75rem 0.4rem 0.4rem;
656+
background: rgb(255 255 255 / 3%);
657+
border: 1px solid rgb(71 168 255 / 12%);
658+
border-radius: 0.5rem;
659+
text-decoration: none;
660+
color: inherit;
661+
transition:
662+
background 0.15s ease,
663+
border-color 0.15s ease;
664+
665+
img {
666+
border-radius: 50%;
667+
width: 32px;
668+
height: 32px;
669+
display: block;
670+
flex-shrink: 0;
645671
}
646672

647-
.footer-left,
648-
.footer-right {
649-
text-align: center;
673+
&:hover {
674+
background: rgb(71 168 255 / 8%);
675+
border-color: rgb(71 168 255 / 40%);
650676
}
651677
}
678+
679+
.contributor-name {
680+
font-size: 0.85rem;
681+
font-weight: 600;
682+
color: #fff;
683+
}
684+
}
685+
686+
.footer {
687+
margin: 3rem auto;
688+
line-height: 1.75;
689+
color: #ccc;
690+
text-align: center;
652691
}
653692

654693
.floating-nav {

0 commit comments

Comments
 (0)