Skip to content

armgit / mimik

Public Imported from GitHub
0

🎬 A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots πŸ“–

feat: particle scatter notification on capture start

Luis Ortiz046f8d08e3f5
diff --git a/src/core/capture/start-notification.ts b/src/core/capture/start-notification.ts
new file mode 100644
index 0000000..2809780
--- /dev/null
+++ b/src/core/capture/start-notification.ts
@@ -0,0 +1,109 @@
+const ANIMATION_DURATION_MS = 3000;
+
+const STYLES = `
+ :host {
+ position: fixed;
+ inset: 0;
+ z-index: 2147483646;
+ pointer-events: none;
+ }
+
+ .wrap {
+ position: absolute;
+ inset: 0;
+ animation: show ${ANIMATION_DURATION_MS}ms ease forwards;
+ }
+
+ @keyframes show {
+ 0% { opacity: 1; }
+ 85% { opacity: 1; }
+ 100% { opacity: 0; }
+ }
+
+ .particle {
+ position: absolute;
+ width: 4px;
+ height: 4px;
+ border-radius: 50%;
+ background: #FBBF24;
+ top: 50%;
+ left: 50%;
+ transform: translate(-50%, -50%) scale(0);
+ }
+
+ .particle:nth-child(1) { animation: p1 1.2s cubic-bezier(0.16,1,0.3,1) forwards; }
+ .particle:nth-child(2) { animation: p2 1.2s cubic-bezier(0.16,1,0.3,1) 0.05s forwards; }
+ .particle:nth-child(3) { animation: p3 1.2s cubic-bezier(0.16,1,0.3,1) 0.1s forwards; }
+ .particle:nth-child(4) { animation: p4 1.2s cubic-bezier(0.16,1,0.3,1) 0.03s forwards; }
+ .particle:nth-child(5) { animation: p5 1.2s cubic-bezier(0.16,1,0.3,1) 0.08s forwards; }
+ .particle:nth-child(6) { animation: p6 1.2s cubic-bezier(0.16,1,0.3,1) 0.12s forwards; }
+ .particle:nth-child(7) { animation: p7 1.2s cubic-bezier(0.16,1,0.3,1) 0.02s forwards; }
+ .particle:nth-child(8) { animation: p8 1.2s cubic-bezier(0.16,1,0.3,1) 0.07s forwards; }
+ .particle:nth-child(9) { animation: p9 1.2s cubic-bezier(0.16,1,0.3,1) 0.06s forwards; }
+ .particle:nth-child(10) { animation: p10 1.2s cubic-bezier(0.16,1,0.3,1) 0.09s forwards; }
+
+ @keyframes p1 { 30% { transform: translate(80px, -60px) scale(1.5); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(0); opacity: 0; } }
+ @keyframes p2 { 30% { transform: translate(-70px, -80px) scale(1.2); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(0); opacity: 0; } }
+ @keyframes p3 { 30% { transform: translate(100px, 40px) scale(1.8); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(0); opacity: 0; } }
+ @keyframes p4 { 30% { transform: translate(-90px, 50px) scale(1.3); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(0); opacity: 0; } }
+ @keyframes p5 { 30% { transform: translate(50px, -90px) scale(1.6); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(0); opacity: 0; } }
+ @keyframes p6 { 30% { transform: translate(-40px, 80px) scale(1.1); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(0); opacity: 0; } }
+ @keyframes p7 { 30% { transform: translate(70px, 70px) scale(1.4); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(0); opacity: 0; } }
+ @keyframes p8 { 30% { transform: translate(-60px, -30px) scale(1.7); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(0); opacity: 0; } }
+ @keyframes p9 { 30% { transform: translate(-100px, -10px) scale(1.2); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(0); opacity: 0; } }
+ @keyframes p10 { 30% { transform: translate(30px, 90px) scale(1.5); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(0); opacity: 0; } }
+
+ .text {
+ position: absolute;
+ top: 50%;
+ left: 50%;
+ transform: translate(-50%, -50%) scale(0.8);
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
+ font-weight: 600;
+ font-size: 16px;
+ color: #FBBF24;
+ white-space: nowrap;
+ opacity: 0;
+ text-shadow: 0 2px 12px rgba(245, 158, 11, 0.4);
+ animation: textIn 0.4s cubic-bezier(0.16,1,0.3,1) 0.5s forwards,
+ textOut 0.3s ease 2.3s forwards;
+ }
+
+ @keyframes textIn { to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
+ @keyframes textOut { to { opacity: 0; transform: translate(-50%, -50%) scale(0.95); } }
+`;
+
+export function showStartNotification(): Promise<void> {
+ return new Promise((resolve) => {
+ const host = document.createElement('mimik-notification');
+ host.setAttribute('data-mimik-ignore', '');
+ const shadow = host.attachShadow({ mode: 'closed' });
+
+ const style = document.createElement('style');
+ style.textContent = STYLES;
+ shadow.appendChild(style);
+
+ const wrap = document.createElement('div');
+ wrap.className = 'wrap';
+
+ for (let i = 0; i < 10; i++) {
+ const particle = document.createElement('div');
+ particle.className = 'particle';
+ wrap.appendChild(particle);
+ }
+
+ const text = document.createElement('div');
+ text.className = 'text';
+ text.textContent = 'Recording started';
+ wrap.appendChild(text);
+
+ shadow.appendChild(wrap);
+ document.documentElement.appendChild(host);
+
+ wrap.addEventListener('animationend', (e) => {
+ if (e.target !== wrap) return;
+ host.remove();
+ resolve();
+ });
+ });
+}
diff --git a/src/entrypoints/background/index.ts b/src/entrypoints/background/index.ts
index 5958236..afde26d 100644
--- a/src/entrypoints/background/index.ts
+++ b/src/entrypoints/background/index.ts
@@ -1,6 +1,6 @@
import { defineBackground } from "#imports";
import { logger } from "@/lib/logger";
-import { setSidePanelBehavior } from "@/lib/browser-api";
+import { setSidePanelBehavior, getActiveTab } from "@/lib/browser-api";
import { onMessage } from "@/lib/messaging";
import { setupPortListener, broadcastStateToPanel } from "@/lib/port";
import { createGuide, saveRrwebChunk } from "@/core/guides/service";
@@ -11,7 +11,7 @@ import {
getStateUpdate,
waitUntilReady,
} from "./actor";
-import { broadcastStartCapture, broadcastStopCapture } from "./tab-manager";
+import { broadcastStartCapture, broadcastStopCapture, showNotificationOnTab } from "./tab-manager";
import { handleUserAction } from "./step-pipeline";
import { registerNavigationListeners } from "./navigation";
@@ -51,6 +51,11 @@ export default defineBackground(() => {
await createGuide(guideId);
+ const activeTab = await getActiveTab();
+ if (activeTab?.id) {
+ await showNotificationOnTab(activeTab.id);
+ }
+
await broadcastStartCapture(guideId);
logger.info("Recording started β†’ guideId:", guideId);
return { guideId };
diff --git a/src/entrypoints/background/tab-manager.ts b/src/entrypoints/background/tab-manager.ts
index 26a206a..87e418d 100644
--- a/src/entrypoints/background/tab-manager.ts
+++ b/src/entrypoints/background/tab-manager.ts
@@ -25,6 +25,14 @@ export async function injectContentScript(tabId: number): Promise<void> {
}
}
+export async function showNotificationOnTab(tabId: number): Promise<void> {
+ try {
+ await sendMessageToTab(tabId, { type: TabMessage.SHOW_NOTIFICATION });
+ } catch (err) {
+ logger.warn('showNotificationOnTab failed', err);
+ }
+}
+
export async function broadcastStartCapture(guideId: string): Promise<void> {
try {
const tabs = await queryTabs({});
diff --git a/src/ui/sidepanel/App.tsx b/src/ui/sidepanel/App.tsx
index 4eb99d9..a08e3f0 100644
--- a/src/ui/sidepanel/App.tsx
+++ b/src/ui/sidepanel/App.tsx
@@ -50,12 +50,6 @@ export default function App() {
onStateUpdate: (update) => {
if (update.state === CaptureState.RECORDING) {
setIsRecording(true);
- if (update.currentGuideId) {
- setView(prev => {
- if (prev.name === 'recording') return prev;
- return { name: 'recording', guideId: update.currentGuideId! };
- });
- }
} else {
setIsRecording(false);
}