dev-wrapped 0.0.0-stage → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +136 -3
- package/bin/git-wrapped.js +183 -0
- package/package.json +45 -6
- package/src/archetypes.js +128 -0
- package/src/fonts/Geist-Variable.woff2 +0 -0
- package/src/fonts/GeistMono-Variable.woff2 +0 -0
- package/src/fonts/OFL.txt +92 -0
- package/src/git.js +124 -0
- package/src/github.js +192 -0
- package/src/html.js +51 -0
- package/src/icons.js +48 -0
- package/src/stats.js +226 -0
- package/src/story/app.js +447 -0
- package/src/story/style.css +141 -0
- package/src/terminal.js +288 -0
package/src/story/app.js
ADDED
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
/* global S, ICONS */
|
|
2
|
+
const A = S.archetype;
|
|
3
|
+
const G = S.github;
|
|
4
|
+
const $ = (s, el = document) => el.querySelector(s);
|
|
5
|
+
const esc = (t) => String(t).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
6
|
+
const fmt = (n) => Math.round(n).toLocaleString('en-US');
|
|
7
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
8
|
+
const ic = (name, size = 16) =>
|
|
9
|
+
`<svg class="ic" width="${size}" height="${size}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${ICONS[name]}"/></svg>`;
|
|
10
|
+
|
|
11
|
+
// Apple system colors (dark appearance): [glow A, glow B, accent]
|
|
12
|
+
const PAL = {
|
|
13
|
+
indigo: ['#5e5ce6', '#bf5af2', '#b4b2ff'],
|
|
14
|
+
green: ['#30d158', '#64d2ff', '#9af0b4'],
|
|
15
|
+
orange: ['#ff9f0a', '#ff375f', '#ffc970'],
|
|
16
|
+
cyan: ['#64d2ff', '#5e5ce6', '#a8e6ff'],
|
|
17
|
+
pink: ['#ff375f', '#bf5af2', '#ff9fb4'],
|
|
18
|
+
yellow: ['#ffd60a', '#ff9f0a', '#ffe680'],
|
|
19
|
+
teal: ['#40c8e0', '#30d158', '#9eeefa'],
|
|
20
|
+
purple: ['#bf5af2', '#5e5ce6', '#e0b3ff'],
|
|
21
|
+
};
|
|
22
|
+
const ARCH = [A.palette[1], A.palette[2], A.palette[3]];
|
|
23
|
+
|
|
24
|
+
const label = (icon, text) => `<div class="label">${ic(icon, 15)}<span>${text}</span></div>`;
|
|
25
|
+
const stat = (icon, value, text) => `<div class="stat glass">${ic(icon, 18)}<b>${value}</b><span>${text}</span></div>`;
|
|
26
|
+
const chip = (icon, text) => `<span class="chip glass">${ic(icon, 14)}${text}</span>`;
|
|
27
|
+
|
|
28
|
+
// ---------- slides ----------
|
|
29
|
+
const slides = [];
|
|
30
|
+
const add = (html, pal, opts = {}) => slides.push({ html, pal, ...opts });
|
|
31
|
+
const first = esc(S.name.split(' ')[0]);
|
|
32
|
+
|
|
33
|
+
add(`${label('commit', `${S.year} in review`)}
|
|
34
|
+
<div class="title">Hey ${first}.<br><span class="dim">${S.year} was quite a year.</span></div>
|
|
35
|
+
<div class="sub">You wrote code. A lot of it.<br>Let's look back at what you built.</div>`, PAL.indigo);
|
|
36
|
+
|
|
37
|
+
add(`${label('commit', 'This year you made')}
|
|
38
|
+
<div class="num" data-count="${S.commits}">0</div>
|
|
39
|
+
<div class="title">commits</div>
|
|
40
|
+
<div class="chips">${chip('folder', `${S.repos} repo${S.repos > 1 ? 's' : ''}`)}${chip('calendar', `${S.activeDays} active days`)}${chip('timer', `~${fmt(S.hoursCoding)}h of code`)}</div>`, PAL.green);
|
|
41
|
+
|
|
42
|
+
if (G) {
|
|
43
|
+
add(`${label('star', 'Your year on GitHub')}
|
|
44
|
+
<div class="num" data-count="${G.contributions}">0</div>
|
|
45
|
+
<div class="title">contributions</div>
|
|
46
|
+
<div class="row">${stat('pr', fmt(G.prs), 'pull requests')}${stat('eye', fmt(G.reviews), 'reviews')}${stat('issue', fmt(G.issues), 'issues')}</div>
|
|
47
|
+
<div class="chips">${G.topRepos.slice(0, 3).map((r) => chip('folder', `${esc(r.name)} · ${r.count}`)).join('')}</div>`, PAL.purple);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
add(`${label('doc', 'Lines of code')}
|
|
51
|
+
<div class="row">${stat('plus', `<span data-count="${S.added}">0</span>`, 'lines added')}${stat('minus', `<span data-count="${S.removed}">0</span>`, 'lines removed')}</div>
|
|
52
|
+
<div class="sub">Printed out, that's about</div>
|
|
53
|
+
<div class="title">${fmt(S.book.pages)} pages.</div>
|
|
54
|
+
<div class="sub">${ic('book', 16)} That's ${S.book.times >= 1 ? `<b>${S.book.times.toFixed(1)}×</b> ` : `<b>${Math.round(S.book.times * 100)}%</b> of `}<i>${esc(S.book.title)}</i>.</div>`, PAL.orange);
|
|
55
|
+
|
|
56
|
+
const late = S.latest && (S.latest.hour < 5 || S.latest.hour >= 23);
|
|
57
|
+
add(`${label('clock', 'Your clock')}
|
|
58
|
+
<svg id="clock" viewBox="-110 -110 220 220"></svg>
|
|
59
|
+
<div class="title">Peak hour<br><span class="dim">${pad(S.peakHour)}:00</span></div>
|
|
60
|
+
${late
|
|
61
|
+
? `<div class="quote glass">"${esc(S.latest.subject)}"<small>Latest commit · ${pad(S.latest.hour)}:${pad(S.latest.minute)} · ${S.latest.day}</small></div>`
|
|
62
|
+
: `<div class="sub">Favorite day of the week: <b>${S.peakWeekday}</b>.</div>`}`, PAL.cyan, { onShow: drawClock });
|
|
63
|
+
|
|
64
|
+
add(`${label('calendar', 'Your year at a glance')}
|
|
65
|
+
<div id="cal" class="glass"></div>
|
|
66
|
+
<div class="row">${stat('flame', `${S.longestStreak.length} days`, 'longest streak')}${stat('bolt', S.busiest ? S.busiest.count : 0, S.busiest ? `commits on ${S.busiest.day.slice(5)}` : 'busiest day')}</div>
|
|
67
|
+
<div class="sub">Your busiest day of the week was <b>${S.peakWeekday}</b>.</div>`, PAL.pink, { onShow: drawCal });
|
|
68
|
+
|
|
69
|
+
if (S.languages.length) {
|
|
70
|
+
const top = S.languages[0].share;
|
|
71
|
+
add(`${label('chart', 'You spoke')}
|
|
72
|
+
<div class="title">${esc(S.languages[0].name)}<br><span class="dim">fluently.</span></div>
|
|
73
|
+
<div class="bars">${S.languages.map((l) => `<div class="bar"><header><span>${esc(l.name)}</span><span>${Math.round(l.share * 100)}%</span></header><div class="track"><div class="fill" style="--w:${(l.share / top) * 100}%"></div></div></div>`).join('')}</div>`, PAL.yellow);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const facts = [`${ic('wrench')}<span>You fixed things <b>${S.fixes}</b> times.</span>`];
|
|
77
|
+
if (S.wip) facts.push(`${ic('hourglass')}<span><b>${S.wip}</b> commits just said "WIP".</span>`);
|
|
78
|
+
if (S.rage) facts.push(`${ic('warning')}<span><b>${S.rage}</b> commits were written in pure frustration.</span>`);
|
|
79
|
+
if (S.topFiles[0]) facts.push(`${ic('doc')}<span>You couldn't stop touching <b>${esc(S.topFiles[0].name.split('/').pop())}</b> (${S.topFiles[0].count}×).</span>`);
|
|
80
|
+
if (S.shortestMsg && S.shortestMsg.subject.length <= 4) facts.push(`${ic('bubble')}<span>Most eloquent message: <b>"${esc(S.shortestMsg.subject)}"</b></span>`);
|
|
81
|
+
add(`${label('bubble', 'Your commit messages')}
|
|
82
|
+
<div id="cloud"></div>
|
|
83
|
+
<div class="list">${facts.map((f) => `<div>${f}</div>`).join('')}</div>`, PAL.teal, { onShow: drawCloud });
|
|
84
|
+
|
|
85
|
+
if (S.teammates.length) {
|
|
86
|
+
add(`${label('people', "You didn't build alone")}
|
|
87
|
+
<div class="title">Partner in crime<br><span class="dim">${esc(S.teammates[0].name)}</span></div>
|
|
88
|
+
<div class="chips">${S.teammates.map((t) => chip('people', `${esc(t.name)} · ${t.count}`)).join('')}</div>`, PAL.indigo);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
add(`<div class="label" style="justify-content:center">Your developer personality</div>
|
|
92
|
+
<div class="tile">${ic(A.icon, 64)}</div>
|
|
93
|
+
<div class="title" style="text-align:center">${esc(A.name)}</div>
|
|
94
|
+
<div class="sub" style="text-align:center">${esc(A.tagline)}</div>
|
|
95
|
+
<div class="sub" style="text-align:center;color:var(--muted);font-size:15px">${esc(A.description)}</div>`, ARCH, { duration: 9000, onShow: () => setTimeout(() => confetti(160), 2400) });
|
|
96
|
+
|
|
97
|
+
add(`<div class="label" style="justify-content:center">Your ${S.year} card</div>
|
|
98
|
+
<img id="card" alt="Your Git Wrapped card">
|
|
99
|
+
<div class="btns"><button class="cta" id="dl">${ic('download', 17)}Save image</button><a class="cta ghost" id="tw" target="_blank" rel="noopener">${ic('share', 17)}Share</a><button class="cta ghost" id="again" aria-label="Replay">${ic('replay', 17)}</button></div>`, ARCH, { duration: Infinity, last: true, onShow: showCard });
|
|
100
|
+
|
|
101
|
+
// ---------- engine ----------
|
|
102
|
+
const slidesEl = $('#slides');
|
|
103
|
+
const barsEl = $('#bars');
|
|
104
|
+
for (const s of slides) {
|
|
105
|
+
const el = document.createElement('section');
|
|
106
|
+
el.className = 'slide' + (s.last ? ' last' : '');
|
|
107
|
+
el.innerHTML = s.html;
|
|
108
|
+
slidesEl.appendChild(el);
|
|
109
|
+
s.el = el;
|
|
110
|
+
barsEl.appendChild(Object.assign(document.createElement('div'), { innerHTML: '<i></i>' }));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
let cur = -1;
|
|
114
|
+
let t0 = 0;
|
|
115
|
+
let paused = false;
|
|
116
|
+
let pausedAt = 0;
|
|
117
|
+
function setPal(p) {
|
|
118
|
+
const r = document.documentElement.style;
|
|
119
|
+
r.setProperty('--a', p[0]);
|
|
120
|
+
r.setProperty('--b', p[1]);
|
|
121
|
+
r.setProperty('--c', p[2]);
|
|
122
|
+
}
|
|
123
|
+
function go(i) {
|
|
124
|
+
if (i < 0 || i >= slides.length) return;
|
|
125
|
+
if (cur >= 0) slides[cur].el.classList.remove('on');
|
|
126
|
+
cur = i;
|
|
127
|
+
const s = slides[i];
|
|
128
|
+
setPal(s.pal);
|
|
129
|
+
void s.el.offsetWidth;
|
|
130
|
+
s.el.classList.add('on');
|
|
131
|
+
[...barsEl.children].forEach((b, j) => (b.firstChild.style.width = j < i ? '100%' : '0'));
|
|
132
|
+
t0 = performance.now();
|
|
133
|
+
s.el.querySelectorAll('[data-count]').forEach(countUp);
|
|
134
|
+
if (s.onShow) s.onShow(s.el);
|
|
135
|
+
blip(i);
|
|
136
|
+
}
|
|
137
|
+
function tick(now) {
|
|
138
|
+
const s = slides[cur];
|
|
139
|
+
if (s && !paused && s.duration !== Infinity) {
|
|
140
|
+
const p = Math.min(1, (now - t0) / (s.duration || 6500));
|
|
141
|
+
barsEl.children[cur].firstChild.style.width = p * 100 + '%';
|
|
142
|
+
if (p >= 1) go(cur + 1);
|
|
143
|
+
}
|
|
144
|
+
requestAnimationFrame(tick);
|
|
145
|
+
}
|
|
146
|
+
document.querySelectorAll('.nav').forEach((n) => {
|
|
147
|
+
let down = 0;
|
|
148
|
+
n.addEventListener('pointerdown', () => {
|
|
149
|
+
down = performance.now();
|
|
150
|
+
paused = true;
|
|
151
|
+
pausedAt = down;
|
|
152
|
+
});
|
|
153
|
+
n.addEventListener('pointerup', () => {
|
|
154
|
+
paused = false;
|
|
155
|
+
t0 += performance.now() - pausedAt;
|
|
156
|
+
if (performance.now() - down < 250) go(cur + Number(n.dataset.d));
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
addEventListener('keydown', (e) => {
|
|
160
|
+
if (e.key === 'ArrowRight' || e.key === ' ') go(cur + 1);
|
|
161
|
+
if (e.key === 'ArrowLeft') go(cur - 1);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
function countUp(el) {
|
|
165
|
+
const target = Number(el.dataset.count);
|
|
166
|
+
const start = performance.now() + 350;
|
|
167
|
+
(function f(now) {
|
|
168
|
+
const p = Math.max(0, Math.min(1, (now - start) / 1900));
|
|
169
|
+
el.textContent = fmt(target * (1 - Math.pow(1 - p, 4)));
|
|
170
|
+
if (p < 1) requestAnimationFrame(f);
|
|
171
|
+
})(start);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// ---------- visuals ----------
|
|
175
|
+
function drawClock() {
|
|
176
|
+
const max = Math.max(1, ...S.hours);
|
|
177
|
+
let h = `<circle r="36" fill="none" stroke="rgba(255,255,255,.1)"/>`;
|
|
178
|
+
S.hours.forEach((v, i) => {
|
|
179
|
+
const a = (i / 24) * Math.PI * 2 - Math.PI / 2;
|
|
180
|
+
const len = 5 + (v / max) * 58;
|
|
181
|
+
const [x1, y1] = [Math.cos(a) * 44, Math.sin(a) * 44];
|
|
182
|
+
const [x2, y2] = [Math.cos(a) * (44 + len), Math.sin(a) * (44 + len)];
|
|
183
|
+
const peak = i === S.peakHour;
|
|
184
|
+
const anim = (attr, to) => `<animate attributeName="${attr}" to="${to}" dur="1.1s" begin="${0.5 + i * 0.035}s" fill="freeze" calcMode="spline" keySplines=".22 1 .36 1"/>`;
|
|
185
|
+
h += `<line x1="${x1}" y1="${y1}" x2="${x1}" y2="${y1}" stroke="${peak ? 'var(--c)' : 'rgba(255,255,255,.5)'}" stroke-width="${peak ? 6 : 4.5}" stroke-linecap="round">${anim('x2', x2)}${anim('y2', y2)}</line>`;
|
|
186
|
+
});
|
|
187
|
+
[0, 6, 12, 18].forEach((i) => {
|
|
188
|
+
const a = (i / 24) * Math.PI * 2 - Math.PI / 2;
|
|
189
|
+
h += `<text x="${Math.cos(a) * 24}" y="${Math.sin(a) * 24 + 3.5}" fill="rgba(255,255,255,.55)" font-family="Geist Mono, monospace" font-size="9" text-anchor="middle">${pad(i)}</text>`;
|
|
190
|
+
});
|
|
191
|
+
$('#clock').innerHTML = h;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function drawCal() {
|
|
195
|
+
const firstDow = (new Date(Date.UTC(S.year, 0, 1)).getUTCDay() + 6) % 7;
|
|
196
|
+
const max = Math.max(1, ...S.calendar);
|
|
197
|
+
let h = '<i style="visibility:hidden"></i>'.repeat(firstDow);
|
|
198
|
+
S.calendar.forEach((v, i) => {
|
|
199
|
+
const o = v ? 0.3 + 0.7 * (v / max) : 0;
|
|
200
|
+
const bg = v ? `background:color-mix(in srgb, var(--c) ${Math.round(o * 100)}%, transparent);` : '';
|
|
201
|
+
h += `<i style="${bg}transition-delay:${(0.6 + i * 0.005).toFixed(3)}s"></i>`;
|
|
202
|
+
});
|
|
203
|
+
$('#cal').innerHTML = h;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function drawCloud() {
|
|
207
|
+
const c = $('#cloud');
|
|
208
|
+
const ws = S.words.slice(0, 9);
|
|
209
|
+
if (!ws.length) return void (c.style.display = 'none');
|
|
210
|
+
const max = ws[0].count;
|
|
211
|
+
const spots = [[50, 46], [24, 18], [74, 16], [22, 76], [76, 78], [50, 92], [50, 6], [12, 47], [88, 47]];
|
|
212
|
+
c.innerHTML = ws
|
|
213
|
+
.map((w, i) => `<span style="left:${spots[i][0]}%;top:${spots[i][1]}%;font-size:${Math.round(15 + (w.count / max) * 38)}px;--o:${(1 - i * 0.08).toFixed(2)};color:${i === 0 ? 'var(--c)' : '#f5f5f7'};transition-delay:${(0.5 + i * 0.1).toFixed(2)}s">${esc(w.word)}</span>`)
|
|
214
|
+
.join('');
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// ---------- confetti (thin, elegant) ----------
|
|
218
|
+
const fx = $('#fx');
|
|
219
|
+
const fctx = fx.getContext('2d');
|
|
220
|
+
let parts = [];
|
|
221
|
+
function confetti(n) {
|
|
222
|
+
const r = fx.getBoundingClientRect();
|
|
223
|
+
const d = devicePixelRatio;
|
|
224
|
+
fx.width = r.width * d;
|
|
225
|
+
fx.height = r.height * d;
|
|
226
|
+
const cols = [...ARCH, '#f5f5f7'];
|
|
227
|
+
for (let i = 0; i < n; i++) {
|
|
228
|
+
parts.push({ x: fx.width / 2, y: fx.height * 0.42, vx: (Math.random() - 0.5) * 22 * d, vy: (-Math.random() * 18 - 5) * d, s: (3 + Math.random() * 5) * d, r: Math.random() * 6, vr: (Math.random() - 0.5) * 0.3, c: cols[i % cols.length], life: 1 });
|
|
229
|
+
}
|
|
230
|
+
if (parts.length === n) requestAnimationFrame(stepFx);
|
|
231
|
+
}
|
|
232
|
+
function stepFx() {
|
|
233
|
+
fctx.clearRect(0, 0, fx.width, fx.height);
|
|
234
|
+
parts = parts.filter((p) => p.life > 0 && p.y < fx.height + 40);
|
|
235
|
+
for (const p of parts) {
|
|
236
|
+
p.vy += 0.5 * devicePixelRatio;
|
|
237
|
+
p.vx *= 0.985;
|
|
238
|
+
p.x += p.vx;
|
|
239
|
+
p.y += p.vy;
|
|
240
|
+
p.r += p.vr;
|
|
241
|
+
p.life -= 0.007;
|
|
242
|
+
fctx.save();
|
|
243
|
+
fctx.translate(p.x, p.y);
|
|
244
|
+
fctx.rotate(p.r);
|
|
245
|
+
fctx.globalAlpha = Math.min(1, p.life * 2);
|
|
246
|
+
fctx.fillStyle = p.c;
|
|
247
|
+
fctx.fillRect(-p.s / 2, -p.s / 6, p.s, p.s / 3);
|
|
248
|
+
fctx.restore();
|
|
249
|
+
}
|
|
250
|
+
if (parts.length) requestAnimationFrame(stepFx);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// ---------- sound (off by default) ----------
|
|
254
|
+
let audio = null;
|
|
255
|
+
const snd = $('#sound');
|
|
256
|
+
snd.innerHTML = ic('mute', 18);
|
|
257
|
+
snd.onclick = (e) => {
|
|
258
|
+
e.stopPropagation();
|
|
259
|
+
audio = audio ? (audio.close(), null) : new AudioContext();
|
|
260
|
+
snd.innerHTML = ic(audio ? 'speaker' : 'mute', 18);
|
|
261
|
+
};
|
|
262
|
+
function blip(i) {
|
|
263
|
+
if (!audio) return;
|
|
264
|
+
const notes = [523.3, 659.3, 784, 1046.5];
|
|
265
|
+
[0, 1].forEach((k) => {
|
|
266
|
+
const o = audio.createOscillator();
|
|
267
|
+
const g = audio.createGain();
|
|
268
|
+
const t = audio.currentTime + k * 0.07;
|
|
269
|
+
o.type = 'sine';
|
|
270
|
+
o.frequency.value = notes[(i + k) % notes.length];
|
|
271
|
+
g.gain.setValueAtTime(0.0001, t);
|
|
272
|
+
g.gain.exponentialRampToValueAtTime(0.08, t + 0.015);
|
|
273
|
+
g.gain.exponentialRampToValueAtTime(0.0001, t + 0.5);
|
|
274
|
+
o.connect(g).connect(audio.destination);
|
|
275
|
+
o.start(t);
|
|
276
|
+
o.stop(t + 0.55);
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// ---------- share card (1080×1350) ----------
|
|
281
|
+
const SANS = 'Geist, -apple-system, "SF Pro Display", system-ui, sans-serif';
|
|
282
|
+
const MONO = '"Geist Mono", "SF Mono", ui-monospace, Menlo, monospace';
|
|
283
|
+
function rr(x, X, Y, w, h, r) {
|
|
284
|
+
x.beginPath();
|
|
285
|
+
if (x.roundRect) x.roundRect(X, Y, w, h, r);
|
|
286
|
+
else x.rect(X, Y, w, h);
|
|
287
|
+
}
|
|
288
|
+
function drawIcon(x, name, X, Y, size, color, width = 1.75) {
|
|
289
|
+
x.save();
|
|
290
|
+
x.translate(X, Y);
|
|
291
|
+
x.scale(size / 24, size / 24);
|
|
292
|
+
x.lineWidth = width;
|
|
293
|
+
x.lineCap = 'round';
|
|
294
|
+
x.lineJoin = 'round';
|
|
295
|
+
x.strokeStyle = color;
|
|
296
|
+
x.stroke(new Path2D(ICONS[name]));
|
|
297
|
+
x.restore();
|
|
298
|
+
}
|
|
299
|
+
function mono(x, text, X, Y, size, alpha = 0.55, align = 'left') {
|
|
300
|
+
x.font = `500 ${size}px ${MONO}`;
|
|
301
|
+
x.fillStyle = `rgba(245,245,247,${alpha})`;
|
|
302
|
+
x.textAlign = align;
|
|
303
|
+
if ('letterSpacing' in x) x.letterSpacing = `${size * 0.14}px`;
|
|
304
|
+
x.fillText(text.toUpperCase(), X, Y);
|
|
305
|
+
if ('letterSpacing' in x) x.letterSpacing = '0px';
|
|
306
|
+
x.textAlign = 'left';
|
|
307
|
+
}
|
|
308
|
+
function renderCard() {
|
|
309
|
+
const W = 1080;
|
|
310
|
+
const H = 1350;
|
|
311
|
+
const c = document.createElement('canvas');
|
|
312
|
+
c.width = W;
|
|
313
|
+
c.height = H;
|
|
314
|
+
const x = c.getContext('2d');
|
|
315
|
+
const [ga, gb, acc] = ARCH;
|
|
316
|
+
x.fillStyle = '#000';
|
|
317
|
+
x.fillRect(0, 0, W, H);
|
|
318
|
+
const glow = (cx, cy, r, col, a) => {
|
|
319
|
+
const g = x.createRadialGradient(cx, cy, 0, cx, cy, r);
|
|
320
|
+
g.addColorStop(0, col);
|
|
321
|
+
g.addColorStop(1, 'transparent');
|
|
322
|
+
x.globalAlpha = a;
|
|
323
|
+
x.fillStyle = g;
|
|
324
|
+
x.fillRect(0, 0, W, H);
|
|
325
|
+
x.globalAlpha = 1;
|
|
326
|
+
};
|
|
327
|
+
glow(120, 80, 820, ga, 0.55);
|
|
328
|
+
glow(1040, 1300, 860, gb, 0.45);
|
|
329
|
+
// dot grid
|
|
330
|
+
x.fillStyle = 'rgba(255,255,255,.07)';
|
|
331
|
+
for (let gx = 30; gx < W; gx += 36) for (let gy = 30; gy < H; gy += 36) x.fillRect(gx, gy, 2, 2);
|
|
332
|
+
x.textBaseline = 'alphabetic';
|
|
333
|
+
|
|
334
|
+
// header
|
|
335
|
+
drawIcon(x, 'commit', 78, 72, 34, '#f5f5f7', 2);
|
|
336
|
+
mono(x, G ? `git wrapped · @${G.login}` : 'git wrapped', 126, 99, 22, 0.7);
|
|
337
|
+
mono(x, String(S.year), W - 80, 99, 22, 0.7, 'right');
|
|
338
|
+
|
|
339
|
+
// big number
|
|
340
|
+
const num = fmt(S.commits);
|
|
341
|
+
x.font = `700 200px ${SANS}`;
|
|
342
|
+
if ('letterSpacing' in x) x.letterSpacing = '-7px';
|
|
343
|
+
const g = x.createLinearGradient(0, 170, 0, 420);
|
|
344
|
+
g.addColorStop(0.3, '#ffffff');
|
|
345
|
+
g.addColorStop(1, acc);
|
|
346
|
+
x.fillStyle = g;
|
|
347
|
+
x.fillText(num, 68, 345);
|
|
348
|
+
if ('letterSpacing' in x) x.letterSpacing = '0px';
|
|
349
|
+
mono(x, `commits in ${S.year}`, 82, 400, 24, 0.6);
|
|
350
|
+
|
|
351
|
+
// archetype
|
|
352
|
+
rr(x, 80, 450, W - 160, 200, 36);
|
|
353
|
+
x.fillStyle = 'rgba(255,255,255,.06)';
|
|
354
|
+
x.fill();
|
|
355
|
+
x.strokeStyle = 'rgba(255,255,255,.12)';
|
|
356
|
+
x.lineWidth = 2;
|
|
357
|
+
x.stroke();
|
|
358
|
+
const tg = x.createLinearGradient(110, 480, 250, 620);
|
|
359
|
+
tg.addColorStop(0, ga);
|
|
360
|
+
tg.addColorStop(1, gb);
|
|
361
|
+
rr(x, 112, 482, 136, 136, 32);
|
|
362
|
+
x.fillStyle = tg;
|
|
363
|
+
x.fill();
|
|
364
|
+
drawIcon(x, A.icon, 136, 506, 88, '#ffffff', 1.9);
|
|
365
|
+
x.fillStyle = '#f5f5f7';
|
|
366
|
+
x.font = `600 54px ${SANS}`;
|
|
367
|
+
if ('letterSpacing' in x) x.letterSpacing = '-2px';
|
|
368
|
+
x.fillText(A.name, 282, 548);
|
|
369
|
+
if ('letterSpacing' in x) x.letterSpacing = '0px';
|
|
370
|
+
x.font = `400 28px ${SANS}`;
|
|
371
|
+
x.fillStyle = 'rgba(245,245,247,.68)';
|
|
372
|
+
wrap(x, A.tagline, 282, 596, W - 400, 36);
|
|
373
|
+
|
|
374
|
+
// stats
|
|
375
|
+
const cells = [
|
|
376
|
+
['plus', '+' + fmt(S.added), 'lines added'],
|
|
377
|
+
['flame', `${S.longestStreak.length} days`, 'longest streak'],
|
|
378
|
+
['clock', `${pad(S.peakHour)}:00`, 'peak hour'],
|
|
379
|
+
['chart', S.languages[0] ? S.languages[0].name : '—', 'top language'],
|
|
380
|
+
];
|
|
381
|
+
cells.forEach(([icon, v, l], i) => {
|
|
382
|
+
const cx = 80 + (i % 2) * 470;
|
|
383
|
+
const cy = 680 + Math.floor(i / 2) * 190;
|
|
384
|
+
rr(x, cx, cy, 450, 170, 30);
|
|
385
|
+
x.fillStyle = 'rgba(255,255,255,.05)';
|
|
386
|
+
x.fill();
|
|
387
|
+
x.strokeStyle = 'rgba(255,255,255,.1)';
|
|
388
|
+
x.stroke();
|
|
389
|
+
drawIcon(x, icon, cx + 32, cy + 28, 30, acc, 2);
|
|
390
|
+
x.fillStyle = '#f5f5f7';
|
|
391
|
+
x.font = `600 ${v.length > 10 ? 40 : 52}px ${SANS}`;
|
|
392
|
+
if ('letterSpacing' in x) x.letterSpacing = '-2px';
|
|
393
|
+
x.fillText(v, cx + 30, cy + 112);
|
|
394
|
+
if ('letterSpacing' in x) x.letterSpacing = '0px';
|
|
395
|
+
mono(x, l, cx + 32, cy + 146, 18, 0.5);
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
// heatmap
|
|
399
|
+
const firstDow = (new Date(Date.UTC(S.year, 0, 1)).getUTCDay() + 6) % 7;
|
|
400
|
+
const max = Math.max(1, ...S.calendar);
|
|
401
|
+
const cs = 14.4;
|
|
402
|
+
const gap = 2.9;
|
|
403
|
+
S.calendar.forEach((v, i) => {
|
|
404
|
+
const k = i + firstDow;
|
|
405
|
+
x.globalAlpha = v ? 0.3 + (0.7 * v) / max : 1;
|
|
406
|
+
x.fillStyle = v ? acc : 'rgba(255,255,255,.07)';
|
|
407
|
+
rr(x, 80 + Math.floor(k / 7) * (cs + gap), 1075 + (k % 7) * (cs + gap), cs, cs, 3);
|
|
408
|
+
x.fill();
|
|
409
|
+
});
|
|
410
|
+
x.globalAlpha = 1;
|
|
411
|
+
mono(x, `${S.activeDays} active days · ${S.repos} repo${S.repos > 1 ? 's' : ''} · ~${fmt(S.hoursCoding)}h`, 80, 1235, 19, 0.5);
|
|
412
|
+
mono(x, `npx dev-wrapped${G ? ' --github' : ''}`, 80, 1282, 22, 0.85);
|
|
413
|
+
return c;
|
|
414
|
+
}
|
|
415
|
+
function wrap(x, text, tx, ty, maxW, lh) {
|
|
416
|
+
let line = '';
|
|
417
|
+
let y = ty;
|
|
418
|
+
for (const w of text.split(' ')) {
|
|
419
|
+
if (x.measureText(line + w).width > maxW && line) {
|
|
420
|
+
x.fillText(line.trim(), tx, y);
|
|
421
|
+
line = '';
|
|
422
|
+
y += lh;
|
|
423
|
+
}
|
|
424
|
+
line += w + ' ';
|
|
425
|
+
}
|
|
426
|
+
x.fillText(line.trim(), tx, y);
|
|
427
|
+
}
|
|
428
|
+
let cardUrl = null;
|
|
429
|
+
async function showCard(el) {
|
|
430
|
+
if (!cardUrl) {
|
|
431
|
+
try {
|
|
432
|
+
await Promise.all([document.fonts.load(`700 200px Geist`), document.fonts.load(`600 54px Geist`), document.fonts.load(`500 22px "Geist Mono"`)]);
|
|
433
|
+
} catch {
|
|
434
|
+
/* fall back to system fonts */
|
|
435
|
+
}
|
|
436
|
+
cardUrl = renderCard().toDataURL('image/png');
|
|
437
|
+
}
|
|
438
|
+
$('#card', el).src = cardUrl;
|
|
439
|
+
$('#dl', el).onclick = () => Object.assign(document.createElement('a'), { href: cardUrl, download: `git-wrapped-${S.year}.png` }).click();
|
|
440
|
+
const txt = `My ${S.year} Git Wrapped: ${fmt(S.commits)} commits, a ${S.longestStreak.length}-day streak, and apparently I'm ${A.name}.\n\nGet yours: npx dev-wrapped`;
|
|
441
|
+
$('#tw', el).href = 'https://twitter.com/intent/tweet?text=' + encodeURIComponent(txt);
|
|
442
|
+
$('#again', el).onclick = () => go(0);
|
|
443
|
+
confetti(90);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
go(0);
|
|
447
|
+
requestAnimationFrame(tick);
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--a: #5e5ce6; /* glow A */
|
|
3
|
+
--b: #bf5af2; /* glow B */
|
|
4
|
+
--c: #a5b4fc; /* accent */
|
|
5
|
+
--ink: #f5f5f7;
|
|
6
|
+
--muted: rgba(245, 245, 247, 0.56);
|
|
7
|
+
--hair: rgba(255, 255, 255, 0.1);
|
|
8
|
+
--glass: rgba(255, 255, 255, 0.055);
|
|
9
|
+
--sans: 'Geist', -apple-system, 'SF Pro Display', system-ui, 'Helvetica Neue', Arial, sans-serif;
|
|
10
|
+
--mono: 'Geist Mono', 'SF Mono', ui-monospace, Menlo, Consolas, monospace;
|
|
11
|
+
--ease: cubic-bezier(0.22, 1, 0.36, 1);
|
|
12
|
+
}
|
|
13
|
+
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
14
|
+
html, body {
|
|
15
|
+
height: 100%;
|
|
16
|
+
background: #000;
|
|
17
|
+
color: var(--ink);
|
|
18
|
+
font-family: var(--sans);
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
-webkit-font-smoothing: antialiased;
|
|
21
|
+
font-feature-settings: 'ss01', 'tnum';
|
|
22
|
+
}
|
|
23
|
+
#stage { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
|
|
24
|
+
#story {
|
|
25
|
+
position: relative;
|
|
26
|
+
width: min(100vw, calc(100vh * 9 / 16));
|
|
27
|
+
height: min(100vh, calc(100vw * 16 / 9));
|
|
28
|
+
overflow: hidden;
|
|
29
|
+
background: #000;
|
|
30
|
+
}
|
|
31
|
+
@media (min-width: 600px) {
|
|
32
|
+
#story { border-radius: 28px; box-shadow: 0 0 0 1px var(--hair), 0 40px 120px rgba(0, 0, 0, 0.8); }
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* aurora + grid */
|
|
36
|
+
.glow { position: absolute; border-radius: 50%; filter: blur(70px); opacity: 0.55; transition: background 1.2s var(--ease); will-change: transform; }
|
|
37
|
+
.g1 { width: 90%; aspect-ratio: 1; background: var(--a); top: -35%; left: -30%; animation: drift1 18s ease-in-out infinite; }
|
|
38
|
+
.g2 { width: 80%; aspect-ratio: 1; background: var(--b); bottom: -40%; right: -35%; animation: drift2 22s ease-in-out infinite; }
|
|
39
|
+
@keyframes drift1 { 50% { transform: translate(25%, 20%) scale(1.15); } }
|
|
40
|
+
@keyframes drift2 { 50% { transform: translate(-20%, -25%) scale(0.9); } }
|
|
41
|
+
.grid {
|
|
42
|
+
position: absolute; inset: 0; pointer-events: none;
|
|
43
|
+
background-image: radial-gradient(rgba(255, 255, 255, 0.16) 1px, transparent 1px);
|
|
44
|
+
background-size: 22px 22px;
|
|
45
|
+
-webkit-mask-image: radial-gradient(ellipse 80% 65% at 50% 45%, #000 20%, transparent 80%);
|
|
46
|
+
mask-image: radial-gradient(ellipse 80% 65% at 50% 45%, #000 20%, transparent 80%);
|
|
47
|
+
opacity: 0.5;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/* chrome */
|
|
51
|
+
#bars { position: absolute; top: 14px; left: 16px; right: 16px; display: flex; gap: 4px; z-index: 5; }
|
|
52
|
+
#bars div { flex: 1; height: 2px; border-radius: 2px; background: rgba(255, 255, 255, 0.18); overflow: hidden; }
|
|
53
|
+
#bars i { display: block; height: 100%; width: 0; background: #fff; }
|
|
54
|
+
#top { position: absolute; top: 28px; left: 18px; right: 12px; z-index: 6; display: flex; align-items: center; justify-content: space-between; }
|
|
55
|
+
.brand { display: flex; align-items: center; gap: 8px; font: 500 12px/1 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
|
|
56
|
+
.brand .ic { color: var(--ink); }
|
|
57
|
+
#sound { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; display: flex; }
|
|
58
|
+
#sound:hover { color: var(--ink); }
|
|
59
|
+
|
|
60
|
+
/* slides */
|
|
61
|
+
.slide { position: absolute; inset: 0; padding: 84px 28px 48px; display: flex; flex-direction: column; justify-content: center; gap: 16px; opacity: 0; pointer-events: none; transition: opacity 0.6s var(--ease); z-index: 2; }
|
|
62
|
+
.slide.on { opacity: 1; pointer-events: auto; }
|
|
63
|
+
.slide > * { opacity: 0; transform: translateY(18px); filter: blur(10px); }
|
|
64
|
+
.slide.on > * { animation: rise 1s var(--ease) forwards; }
|
|
65
|
+
.slide.on > *:nth-child(1) { animation-delay: 0.1s; }
|
|
66
|
+
.slide.on > *:nth-child(2) { animation-delay: 0.4s; }
|
|
67
|
+
.slide.on > *:nth-child(3) { animation-delay: 0.75s; }
|
|
68
|
+
.slide.on > *:nth-child(4) { animation-delay: 1.1s; }
|
|
69
|
+
.slide.on > *:nth-child(5) { animation-delay: 1.45s; }
|
|
70
|
+
.slide.on > *:nth-child(6) { animation-delay: 1.8s; }
|
|
71
|
+
.slide.on > *:nth-child(7) { animation-delay: 2.15s; }
|
|
72
|
+
@keyframes rise { to { opacity: 1; transform: none; filter: none; } }
|
|
73
|
+
|
|
74
|
+
.label { display: flex; align-items: center; gap: 8px; font: 500 12px/1.2 var(--mono); letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
|
|
75
|
+
.label .ic { color: var(--c); }
|
|
76
|
+
.title { font-weight: 600; font-size: clamp(32px, 9vmin, 46px); line-height: 1.04; letter-spacing: -0.045em; }
|
|
77
|
+
.title .dim { color: var(--muted); }
|
|
78
|
+
.num {
|
|
79
|
+
font-weight: 700; font-size: clamp(84px, 27vmin, 156px); line-height: 0.92; letter-spacing: -0.065em;
|
|
80
|
+
background: linear-gradient(180deg, #fff 35%, var(--c) 140%);
|
|
81
|
+
-webkit-background-clip: text; background-clip: text; color: transparent;
|
|
82
|
+
padding-bottom: 0.06em;
|
|
83
|
+
}
|
|
84
|
+
.sub { font-size: clamp(16px, 4.3vmin, 19px); line-height: 1.45; letter-spacing: -0.012em; color: rgba(245, 245, 247, 0.72); }
|
|
85
|
+
.sub b { color: var(--ink); font-weight: 600; }
|
|
86
|
+
.center { text-align: center; align-items: center; }
|
|
87
|
+
|
|
88
|
+
.glass { background: var(--glass); border: 1px solid var(--hair); border-radius: 20px; -webkit-backdrop-filter: blur(24px) saturate(160%); backdrop-filter: blur(24px) saturate(160%); }
|
|
89
|
+
.row { display: flex; gap: 10px; flex-wrap: wrap; }
|
|
90
|
+
.stat { flex: 1; min-width: 110px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
|
|
91
|
+
.stat .ic { color: var(--c); }
|
|
92
|
+
.stat b { font-size: 28px; font-weight: 600; letter-spacing: -0.04em; line-height: 1; }
|
|
93
|
+
.stat > span { font: 500 11px/1.2 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
|
|
94
|
+
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
|
|
95
|
+
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: 99px; font: 500 12.5px/1 var(--mono); letter-spacing: 0.02em; color: rgba(245, 245, 247, 0.85); }
|
|
96
|
+
.chip .ic { color: var(--c); }
|
|
97
|
+
.quote { padding: 16px 18px; font: 500 15px/1.45 var(--mono); color: var(--ink); word-break: break-word; }
|
|
98
|
+
.quote small { display: block; margin-top: 8px; color: var(--muted); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; }
|
|
99
|
+
|
|
100
|
+
#clock { width: min(76%, 290px); align-self: center; overflow: visible; }
|
|
101
|
+
#cal { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 2px; width: 100%; padding: 14px; }
|
|
102
|
+
#cal i { aspect-ratio: 1; border-radius: 2px; background: rgba(255, 255, 255, 0.07); transform: scale(0); transition: transform 0.4s var(--ease); }
|
|
103
|
+
.slide.on #cal i { transform: scale(1); }
|
|
104
|
+
|
|
105
|
+
.bars { display: flex; flex-direction: column; gap: 14px; }
|
|
106
|
+
.bar { display: flex; flex-direction: column; gap: 7px; }
|
|
107
|
+
.bar header { display: flex; justify-content: space-between; font-size: 16px; font-weight: 500; letter-spacing: -0.02em; }
|
|
108
|
+
.bar header span:last-child { font: 500 13px var(--mono); color: var(--muted); }
|
|
109
|
+
.bar .track { height: 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
|
|
110
|
+
.bar .fill { height: 100%; width: var(--w); border-radius: 6px; background: linear-gradient(90deg, var(--a), var(--c)); transform-origin: left; transform: scaleX(0); transition: transform 1.4s var(--ease); }
|
|
111
|
+
.slide.on .bar .fill { transform: scaleX(1); }
|
|
112
|
+
|
|
113
|
+
#cloud { position: relative; height: 38%; min-height: 190px; }
|
|
114
|
+
#cloud span { position: absolute; font-weight: 600; letter-spacing: -0.04em; white-space: nowrap; transform: translate(-50%, -50%) scale(0.6); opacity: 0; transition: transform 0.9s var(--ease), opacity 0.9s var(--ease); }
|
|
115
|
+
.slide.on #cloud span { transform: translate(-50%, -50%) scale(1); opacity: var(--o); }
|
|
116
|
+
.list { display: flex; flex-direction: column; gap: 10px; }
|
|
117
|
+
.list div { display: flex; gap: 12px; align-items: flex-start; font-size: 15.5px; line-height: 1.4; letter-spacing: -0.012em; color: rgba(245, 245, 247, 0.78); }
|
|
118
|
+
.list .ic { flex: none; color: var(--c); margin-top: 1px; }
|
|
119
|
+
.list b { color: var(--ink); font-weight: 600; }
|
|
120
|
+
|
|
121
|
+
.tile {
|
|
122
|
+
width: 128px; height: 128px; border-radius: 30px; align-self: center;
|
|
123
|
+
display: flex; align-items: center; justify-content: center; color: #fff;
|
|
124
|
+
background: linear-gradient(145deg, var(--a), var(--b));
|
|
125
|
+
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 24px 80px -10px var(--a);
|
|
126
|
+
}
|
|
127
|
+
.slide.on .tile { animation: tile 1.4s var(--ease) 1.6s forwards; }
|
|
128
|
+
@keyframes tile { 0% { opacity: 0; transform: scale(0.4) rotate(-12deg); filter: blur(12px); } 100% { opacity: 1; transform: none; filter: none; } }
|
|
129
|
+
|
|
130
|
+
#card { width: 100%; max-height: 60%; object-fit: contain; border-radius: 16px; box-shadow: 0 0 0 1px var(--hair), 0 30px 80px rgba(0, 0, 0, 0.6); }
|
|
131
|
+
.btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
|
|
132
|
+
.cta { display: inline-flex; align-items: center; gap: 8px; border: 0; cursor: pointer; padding: 12px 18px; border-radius: 99px; font: 600 15px/1 var(--sans); letter-spacing: -0.01em; background: #f5f5f7; color: #000; text-decoration: none; transition: transform 0.2s var(--ease); }
|
|
133
|
+
.cta:active { transform: scale(0.96); }
|
|
134
|
+
.cta.ghost { background: var(--glass); color: var(--ink); border: 1px solid var(--hair); }
|
|
135
|
+
|
|
136
|
+
.nav { position: absolute; top: 0; bottom: 0; width: 35%; z-index: 3; cursor: pointer; }
|
|
137
|
+
.nav.l { left: 0; } .nav.r { right: 0; }
|
|
138
|
+
.slide.last.on { z-index: 4; }
|
|
139
|
+
#fx { position: absolute; inset: 0; pointer-events: none; z-index: 7; }
|
|
140
|
+
.hint { position: absolute; bottom: 16px; width: 100%; text-align: center; font: 500 10.5px var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: rgba(245, 245, 247, 0.35); z-index: 5; }
|
|
141
|
+
@media (prefers-reduced-motion: reduce) { .glow { animation: none; } }
|