Skip to content

Commit 8102291

Browse files
committed
Merge branch 'git-turns-20'
This little topic branch adds some fun sugar on top of Git's home page to celebrate its 20th anniversary. As a sneak-peak, the celebratory additions can be viewed by typing the digits "2" and "0" when viewing the page. Signed-off-by: Johannes Schindelin <[email protected]>
2 parents aa794fd + 838c87d commit 8102291

File tree

5 files changed

+195
-5
lines changed

5 files changed

+195
-5
lines changed

assets/js/application.js

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const baseURLPrefix = (() => {
3232
$(document).ready(function() {
3333
BrowserFallbacks.init();
3434
DarkMode.init();
35+
GitTurns20.init();
3536
Search.init();
3637
Dropdowns.init();
3738
Forms.init();
@@ -102,6 +103,56 @@ var BrowserFallbacks = {
102103

103104
}
104105

106+
var GitTurns20 = {
107+
keySequence: '20',
108+
keySequenceOffset: 0,
109+
110+
init: function() {
111+
const today = new Date();
112+
if (today.getFullYear() === 2025 && today.getMonth() === 3 && today.getDate() === 7) {
113+
this.celebrate();
114+
}
115+
},
116+
117+
keydown: function(e) {
118+
if (this.keySequenceOffset >= this.keySequence.length) return;
119+
if (this.keySequence[this.keySequenceOffset] === e.key) {
120+
if (++this.keySequenceOffset === this.keySequence.length) {
121+
this.celebrate();
122+
this.keySequenceOffset = 0;
123+
}
124+
}
125+
},
126+
127+
celebrate: function() {
128+
document.documentElement.dataset.celebration = 'git-turns-20';
129+
$("#tagline").html('<a href="https://discord.com/channels/1042895022950994071/1356927327388434564">--20th-anniversary</a>');
130+
if ($("#masthead").length) { // only do this on the front page
131+
(async () => {
132+
await import('https://cdn.jsdelivr.net/npm/[email protected]/dist/confetti.browser.min.js');
133+
const count = 200;
134+
const defaults = {
135+
origin: { y: 0.7 }
136+
};
137+
138+
for (const [particleRatio, opts] of [
139+
[0.25, { spread: 26, startVelocity: 55 }],
140+
[0.2, { spread: 60 }],
141+
[0.35, { spread: 100, decay: 0.91, scalar: 0.8 }],
142+
[0.1, { spread: 120, startVelocity: 25, decay: 0.92, scalar: 1.2 }],
143+
[0.1, { spread: 120, startVelocity: 45 }],
144+
]) {
145+
window.confetti({
146+
...defaults,
147+
...opts,
148+
particleCount: Math.floor(count * particleRatio)
149+
});
150+
}
151+
})().catch(console.error);
152+
}
153+
}
154+
};
155+
105156
var Search = {
106157
searching: false,
107158
currentSearch: '',
@@ -166,6 +217,7 @@ var Search = {
166217
e.preventDefault();
167218
$('form#search input').focus();
168219
}
220+
else if (e.target.tagName.toUpperCase() !== 'INPUT') GitTurns20.keydown(e);
169221
});
170222
},
171223

@@ -343,11 +395,11 @@ var Search = {
343395
(async () => {
344396
const pagefindURL =
345397
`${baseURLPrefix}pagefind/pagefind.js`
346-
// adjust the `baseURLPrefix` if it is relative: the `import`
347-
// is relative to the _script URL_ here, which is in /js/.
348-
// That is different from other uses of `baseURLPrefix`, which
349-
// replace `href` and `src` attributes which are relative to the
350-
// page itself that is outside of /js/.
398+
// adjust the `baseURLPrefix` if it is relative: the `import`
399+
// is relative to the _script URL_ here, which is in /js/.
400+
// That is different from other uses of `baseURLPrefix`, which
401+
// replace `href` and `src` attributes which are relative to the
402+
// page itself that is outside of /js/.
351403
.replace(/^\.\//, '../')
352404
Search.pagefind = await import(pagefindURL);
353405
const options = {

assets/sass/application.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ $baseurl: "{{ .Site.BaseURL }}{{ if (and (ne .Site.BaseURL "/") (ne .Site.BaseUR
2828
@import 'lists';
2929
@import 'about';
3030
@import 'dark-mode';
31+
@import 'git-turns-20';
3132

3233
code {
3334
display: inline;

assets/sass/git-turns-20.css

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@mixin logo20($infix: '') {
2+
img[alt="Git"] {
3+
filter: unset;
4+
content: url('./images/logo20' + $infix + '.svg');
5+
}
6+
}
7+
8+
:root[data-celebration="git-turns-20"] {
9+
@include logo20
10+
&[data-theme="dark"] {
11+
@include logo20($infix: '.dark-mode')
12+
}
13+
@media screen and (prefers-color-scheme: dark) {
14+
@include logo20
15+
&:not([data-theme="light"]) {
16+
@include logo20($infix: '.dark-mode')
17+
}
18+
}
19+
}

static/images/logo20.dark-mode.svg

Lines changed: 59 additions & 0 deletions
Loading

static/images/logo20.svg

Lines changed: 59 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)