Skip to content

Commit 99ce5d9

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 fd92444 + d775b5a commit 99ce5d9

File tree

5 files changed

+202
-0
lines changed

5 files changed

+202
-0
lines changed

assets/js/application.js

+64
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,68 @@ 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+
} else {
115+
let start = 0
116+
let count = 0
117+
$("#tagline").click(e => {
118+
if (count === 0 || e.timeStamp > start + count * 1000) {
119+
start = e.timeStamp;
120+
count = 1;
121+
} else if (++count === 6) {
122+
this.celebrate();
123+
count = 0;
124+
}
125+
})
126+
}
127+
},
128+
129+
keydown: function(e) {
130+
if (this.keySequenceOffset >= this.keySequence.length) return;
131+
if (this.keySequence[this.keySequenceOffset] === e.key) {
132+
if (++this.keySequenceOffset === this.keySequence.length) {
133+
this.celebrate();
134+
this.keySequenceOffset = 0;
135+
}
136+
}
137+
},
138+
139+
celebrate: function() {
140+
document.documentElement.dataset.celebration = 'git-turns-20';
141+
$("#tagline").html('<a href="https://discord.com/channels/1042895022950994071/1356927327388434564">--20th-anniversary</a>');
142+
if ($("#masthead").length) { // only do this on the front page
143+
(async () => {
144+
await import('https://cdn.jsdelivr.net/npm/[email protected]/dist/confetti.browser.min.js');
145+
const count = 200;
146+
const defaults = {
147+
origin: { y: 0.7 }
148+
};
149+
150+
for (const [particleRatio, opts] of [
151+
[0.25, { spread: 26, startVelocity: 55 }],
152+
[0.2, { spread: 60 }],
153+
[0.35, { spread: 100, decay: 0.91, scalar: 0.8 }],
154+
[0.1, { spread: 120, startVelocity: 25, decay: 0.92, scalar: 1.2 }],
155+
[0.1, { spread: 120, startVelocity: 45 }],
156+
]) {
157+
window.confetti({
158+
...defaults,
159+
...opts,
160+
particleCount: Math.floor(count * particleRatio)
161+
});
162+
}
163+
})().catch(console.error);
164+
}
165+
}
166+
};
167+
105168
var Search = {
106169
searching: false,
107170
currentSearch: '',
@@ -166,6 +229,7 @@ var Search = {
166229
e.preventDefault();
167230
$('form#search input').focus();
168231
}
232+
else if (e.target.tagName.toUpperCase() !== 'INPUT') GitTurns20.keydown(e);
169233
});
170234
},
171235

assets/sass/application.scss

+1
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

+19
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

+59
Loading

static/images/logo20.svg

+59
Loading

0 commit comments

Comments
 (0)