TypeScript
feat(web): celebrate a GitHub star with confetti (#29987)
Theo Brownecefb544af3c9
diff --git a/apps/web/package.json b/apps/web/package.jsonindex 3cb58dec9cd..1d79dc07cd2 100644--- a/apps/web/package.json+++ b/apps/web/package.json@@ -54,6 +54,7 @@"@tiptap/pm": "^3.31.3","@tiptap/react": "^3.31.3","@tiptap/starter-kit": "^3.31.3",+ "canvas-confetti": "1.9.4","class-variance-authority": "^0.7.1","culori": "^4.0.2","dompurify": "^3.4.16",@@ -97,6 +98,7 @@"@effect/vitest": "catalog:","@tailwindcss/vite": "^4.0.0","@tanstack/router-plugin": "^1.161.0",+ "@types/canvas-confetti": "1.9.0","@types/compression": "^1.8.1","@types/culori": "^4.0.1","@types/hast": "^3.0.4",diff --git a/apps/web/src/components/GitHubStarPrompt.test.ts b/apps/web/src/components/GitHubStarPrompt.test.tsindex f45229d5ce8..f748ec8b822 100644--- a/apps/web/src/components/GitHubStarPrompt.test.ts+++ b/apps/web/src/components/GitHubStarPrompt.test.ts@@ -165,11 +165,12 @@ describe("recordPromptSent", () => {vi.unstubAllGlobals();});it("stars on click, opens GitHub when starring fails, and asks for a click once the click expired", async () => {- setup({ sent: 5 });+ const store = setup({ sent: 5 });await (await startSession()).send();click(add.mock.lastCall?.[0].actionProps);await vi.advanceTimersByTimeAsync(0);- expect(add.mock.lastCall?.[0].title).toBe("Thanks for the star!");+ expect(update.mock.lastCall?.[1]).toMatchObject({ title: "Thanks for the star!" });+ expect(store.get("t3code:github-star-prompt:dismissed")).toBe("true");expect(openExternal).not.toHaveBeenCalled();setup({ sent: 5 });diff --git a/apps/web/src/components/GitHubStarPrompt.tsx b/apps/web/src/components/GitHubStarPrompt.tsxindex f79714d7a89..679d61b1f35 100644--- a/apps/web/src/components/GitHubStarPrompt.tsx+++ b/apps/web/src/components/GitHubStarPrompt.tsx@@ -38,8 +38,17 @@ function showStarPrompt(environmentId: EnvironmentId) {const starInPlace = async () => {toastManager.update(id, { actionProps: { children: "Starring…", disabled: true } });if (await starRepository(environmentId)) {- close();- toastManager.add({ type: "success", title: "Thanks for the star!", timeout: 4_000 });+ // Thank them in place: a closing and opening toast would slide under the confetti.+ dismiss();+ toastManager.update(id, {+ type: "success",+ title: "Thanks for the star!",+ description: "It really helps T3 Code grow.",+ timeout: 5_000,+ actionProps: undefined,+ data: {},+ });+ celebrate();return;}// Browsers block new tabs once the click's activation expires; desktop opens through its bridge.@@ -62,6 +71,23 @@ function showStarPrompt(environmentId: EnvironmentId) {});}+// One burst out of the toast. The library loads only here, and its canvas stops when done.+function celebrate() {+ void import("canvas-confetti")+ .then(({ default: confetti }) =>+ confetti({+ particleCount: 160,+ spread: 360,+ startVelocity: 38,+ gravity: 1.6,+ ticks: 140,+ origin: { x: 0.83, y: 0.15 },+ disableForReducedMotion: true,+ }),+ )+ .catch(() => undefined);+}+// Resolves after IDLE_MS without input while this window has focus.function waitForIdle() {return new Promise<void>((resolve) => {diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 84a19021c78..755f2f95c2e 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -1143,6 +1143,9 @@ importers:'@tiptap/starter-kit':specifier: ^3.31.3version: 3.31.3+ canvas-confetti:+ specifier: 1.9.4+ version: 1.9.4class-variance-authority:specifier: ^0.7.1version: 0.7.1@@ -1267,6 +1270,9 @@ importers:'@tanstack/router-plugin':specifier: ^1.161.0version: 1.168.13(@tanstack/[email protected]([email protected]([email protected]))([email protected]))(@voidzero-dev/[email protected](@tsc-rs/[email protected])(@types/[email protected])(@volar/[email protected](@tsc-rs/[email protected]))([email protected])([email protected])([email protected])([email protected])([email protected]))([email protected])+ '@types/canvas-confetti':+ specifier: 1.9.0+ version: 1.9.0'@types/compression':specifier: ^1.8.1version: 1.8.1@@ -7008,6 +7014,9 @@ packages:'@types/[email protected]':resolution: {integrity: sha512-IQ3EbTzGxIigb1I3qPZc1rWJnH0BmSKv5QYTalEwweFvyBDLSAe24zP0le/hyi7ecGfZVlIVAg4BZqb8WBwKqw==}+ '@types/[email protected]':+ resolution: {integrity: sha512-aBGj/dULrimR1XDZLtG9JwxX1b4HPRF6CX9Yfwh3NvstZEm1ZL7RBnel4keCPSqs1ANRu1u2Aoz9R+VmtjYuTg==}+'@types/[email protected]':resolution: {integrity: sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==}@@ -7947,6 +7956,9 @@ packages:resolution: {integrity: sha512-TITQPUkaz+aVk5GL6NhOdwk1aEaNTSDPsGFWrTuhKGtjTF70jL/Oht2W4c6rXUe5fu7Ie19VIahAXHIIiWWNeg==}+ resolution: {integrity: sha512-yxQbJkAVrFXWNbTUjPqjF7G+g6pDotOUHGbkZq2NELZUMDpiJ85rIEazVb8GTaAptNW2miJAXbs1BtioA251Pw==}+resolution: {integrity: sha512-pqhhnRqGfDdgHa+rz4JVO9j1jnkyqsHRYrD4RBtIwxCknYSRG7Mjs+x3IRfd20u+ZGS0IhW2L7cDv9ZcIkCYhQ==}hasBin: true@@ -16574,6 +16586,8 @@ snapshots:'@types/node': 24.12.4'@types/responselike': 1.0.3+ '@types/[email protected]': {}+'@types/[email protected]':dependencies:'@types/deep-eql': 4.0.2@@ -17735,6 +17749,8 @@ snapshots:+ [email protected]: {}+[email protected](@tsc-rs/[email protected]):optionalDependencies:typescript: '@tsc-rs/[email protected]'