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 📖

refactor: share the step source labels and number the card's step as number

Luis Ortiz74d1b7933f4e
diff --git a/apps/desktop/scripts/check-overlay.ts b/apps/desktop/scripts/check-overlay.ts
index 0656041..4d5e701 100644
--- a/apps/desktop/scripts/check-overlay.ts
+++ b/apps/desktop/scripts/check-overlay.ts
@@ -235,7 +235,7 @@ app.whenReady().then(async () => {
`badge ${badgeWhileRecording.badge}, paused tip ${resting.tip}, mascot shown ${resting.intro}`,
);
- overlay.showStep({ id: 'one', index: 1, title: 'Click "Save"', action: 'click', src, source: 'heuristic', pending: false, app: 'Explorer' });
+ overlay.showStep({ id: 'one', number: 1, title: 'Click "Save"', action: 'click', src, source: 'heuristic', pending: false, app: 'Explorer' });
await settle();
const step = await card(
"intro: getComputedStyle(document.querySelector('#intro')).display, title: document.querySelector('#stepTitle').textContent, source: document.querySelector('#source').textContent, meta: document.querySelector('#metaText').textContent",
@@ -246,12 +246,12 @@ app.whenReady().then(async () => {
`intro display: ${step.intro}, title: ${step.title}, source: ${step.source}, meta: ${step.meta}`,
);
- overlay.showStep({ id: 'one', index: 1, title: 'Click "Save"', action: 'click', src, source: 'heuristic', pending: true, app: 'Explorer' });
+ overlay.showStep({ id: 'one', number: 1, title: 'Click "Save"', action: 'click', src, source: 'heuristic', pending: true, app: 'Explorer' });
await settle();
const pendingStep = await card(
"title: document.querySelector('#stepTitle').textContent, source: document.querySelector('#source').textContent, loaders: document.querySelectorAll('#writing, #skeleton, #pillWriting').length",
);
- overlay.showStep({ id: 'one', index: 1, title: 'Save the file', action: 'click', src, source: 'ai', pending: false, app: 'Explorer' });
+ overlay.showStep({ id: 'one', number: 1, title: 'Save the file', action: 'click', src, source: 'ai', pending: false, app: 'Explorer' });
await settle();
const rewritten = await card("source: document.querySelector('#source').textContent, title: document.querySelector('#stepTitle').textContent");
check(
@@ -264,7 +264,7 @@ app.whenReady().then(async () => {
`while pending: ${pendingStep.source} "${pendingStep.title}", ${pendingStep.loaders} writing loaders; then ${rewritten.source} "${rewritten.title}"`,
);
- overlay.showStep({ id: 'one', index: 1, title: 'Press ⌃S on "Search"', action: 'keydown:⌃S', src, source: 'heuristic', pending: false, app: 'Chrome' });
+ overlay.showStep({ id: 'one', number: 1, title: 'Press ⌃S on "Search"', action: 'keydown:⌃S', src, source: 'heuristic', pending: false, app: 'Chrome' });
await settle();
const keyed = await card(
"key: document.querySelector('#stepTitle kbd')?.textContent ?? null, title: document.querySelector('#stepTitle').textContent",
@@ -338,13 +338,13 @@ app.whenReady().then(async () => {
aimed.src === src,
`before: marker ${unaimed.aim}, developing ${unaimed.developing}; after: marker ${aimed.aim} at ${aimed.left}, developing ${aimed.developing}`,
);
- overlay.showStep({ id: 'two', index: 2, title: 'Click "Open"', action: 'click', src, source: 'heuristic', pending: true, app: 'Explorer' });
+ overlay.showStep({ id: 'two', number: 2, title: 'Click "Open"', action: 'click', src, source: 'heuristic', pending: true, app: 'Explorer' });
overlay.setBusy(false);
await settle();
const describing = await card(
"printer: !document.querySelector('#printer').hidden, title: getComputedStyle(document.querySelector('#stepTitle')).visibility",
);
- overlay.showStep({ id: 'two', index: 2, title: 'Open the file', action: 'click', src, source: 'ai', pending: false, app: 'Explorer' });
+ overlay.showStep({ id: 'two', number: 2, title: 'Open the file', action: 'click', src, source: 'ai', pending: false, app: 'Explorer' });
await new Promise((resolve) => setTimeout(resolve, 900));
await settle();
const aiLanded = await card(
@@ -360,10 +360,10 @@ app.whenReady().then(async () => {
`while describing: printer ${describing.printer}, title ${describing.title}; landed: printer ${aiLanded.printer}, ${aiLanded.source} "${aiLanded.title}"`,
);
const shortTitle = await card("height: document.body.scrollHeight, preview: document.querySelector('#preview').offsetHeight");
- overlay.showStep({ id: 'one', index: 1, title: 'Click '.repeat(40), action: 'click', src, source: 'ai', pending: false, app: 'Explorer' });
+ overlay.showStep({ id: 'one', number: 1, title: 'Click '.repeat(40), action: 'click', src, source: 'ai', pending: false, app: 'Explorer' });
await settle();
const longTitle = await card("height: document.body.scrollHeight, preview: document.querySelector('#preview').offsetHeight");
- overlay.showStep({ id: 'one', index: 1, title: 'Save the file', action: 'click', src, source: 'ai', pending: false, app: 'Explorer' });
+ overlay.showStep({ id: 'one', number: 1, title: 'Save the file', action: 'click', src, source: 'ai', pending: false, app: 'Explorer' });
await settle();
check(
'the card keeps its height when a step lands, and a long title takes it from the screenshot',
diff --git a/apps/desktop/src/main/index.ts b/apps/desktop/src/main/index.ts
index e4d5aa8..bed318b 100644
--- a/apps/desktop/src/main/index.ts
+++ b/apps/desktop/src/main/index.ts
@@ -481,7 +481,7 @@ if (!app.requestSingleInstanceLock()) {
if (reply?.stepId && reply.title) {
const step: OverlayStep = {
id: reply.stepId,
- index: steps.length + 1 + (insert?.afterStep ?? 0),
+ number: steps.length + 1 + (insert?.afterStep ?? 0),
title: reply.title,
action: request.action,
src: request.image?.src ?? '',
diff --git a/apps/desktop/src/main/overlay/index.ts b/apps/desktop/src/main/overlay/index.ts
index 8509048..78d3d4b 100644
--- a/apps/desktop/src/main/overlay/index.ts
+++ b/apps/desktop/src/main/overlay/index.ts
@@ -8,6 +8,7 @@ import {
type PauseReason,
} from '@mimik/core/capture/machine';
import type { VoiceErrorReason } from '@mimik/core/capture/voice/voice-update';
+import type { DescriptionSource } from '@mimik/core/guides/types';
import { app, BrowserWindow, ipcMain, screen } from 'electron';
import type { Actor } from 'xstate';
import { clampToDisplays, loadRegion, type Region, saveRegion } from '../capture/region';
@@ -32,11 +33,11 @@ export type OverlayCommand =
export interface OverlayStep {
id: string;
- index: number;
+ number: number;
title: string;
action: string;
src: string;
- source: 'heuristic' | 'ai' | 'narration';
+ source: DescriptionSource;
pending: boolean;
app: string | null;
}
diff --git a/apps/desktop/src/renderer/overlay/controls.ts b/apps/desktop/src/renderer/overlay/controls.ts
index da2f3da..45ae35b 100644
--- a/apps/desktop/src/renderer/overlay/controls.ts
+++ b/apps/desktop/src/renderer/overlay/controls.ts
@@ -3,6 +3,7 @@ import { splitAtShortcut } from '@mimik/core/capture/split-at-shortcut';
import { hasVoiceApiKey, VOICE_KEY_SETTINGS } from '@mimik/core/capture/voice/api-key';
import { voiceErrorKey } from '@mimik/core/capture/voice/voice-error-key';
import { i18n, localStorage } from '@mimik/core/env';
+import { STEP_SOURCE_LABELS } from '@mimik/core/guides/step-source-labels';
import type { OverlayView } from '../../main/overlay';
import { icon } from '../icons';
import { cameraMascot } from './camera-mascot';
@@ -128,7 +129,7 @@ export function controls(): void {
let gaveUp: string | null = null;
let landing = false;
let landedId: string | null = null;
- let printingIndex = 1;
+ let printingNumber = 1;
let shownPercent = 0;
const resetPercent = () => {
@@ -165,13 +166,13 @@ export function controls(): void {
const resting = paused && !step && !busy;
if (busy && !wasBusy) {
- printingIndex = (step?.index ?? 0) + 1;
+ printingNumber = (step?.number ?? 0) + 1;
if (step) landedId = step.id;
resetPercent();
printingStep = true;
}
wasBusy = busy;
- const printed = step && step.index >= printingIndex ? step : null;
+ const printed = step && step.number >= printingNumber ? step : null;
const developed = printed?.src ?? print.src;
if (printingStep && developed && filmShot.getAttribute('src') !== developed) filmShot.src = developed;
photo.classList.toggle('developing', Boolean(printingStep && developed));
@@ -200,7 +201,7 @@ export function controls(): void {
document.body.classList.toggle('resting', resting);
document.body.classList.toggle('busy', busy);
- const count = capturing ? printingIndex - 1 : (step?.index ?? 0);
+ const count = capturing ? printingNumber - 1 : (step?.number ?? 0);
const counted = [String(count)];
label.textContent = starting
? 'Starting…'
@@ -255,7 +256,7 @@ export function controls(): void {
aim.style.left = `${(width - shownWidth) / 2 + aimed.x * shownWidth}px`;
aim.style.top = `${(height - shownHeight) / 2 + aimed.y * shownHeight}px`;
}
- printing.textContent = `Capturing step ${printingIndex}`;
+ printing.textContent = `Capturing step ${printingNumber}`;
shot.hidden = !step?.src;
veil.hidden = !paused || capturing;
remove.hidden = !step || capturing || armed;
@@ -268,10 +269,10 @@ export function controls(): void {
preview.style.setProperty('--title-extra', `${step ? Math.max(0, extra) : 0}px`);
source.hidden = !step;
const sourceKind = step?.source === 'ai' ? 'ai' : step?.source === 'narration' ? 'voice' : 'basic';
- source.textContent = i18n.t(`stepSource_${sourceKind}`);
+ source.textContent = i18n.t(STEP_SOURCE_LABELS[step?.source ?? 'heuristic']);
source.className = sourceKind;
metaText.textContent =
- [step ? i18n.t('export_stepLabel', [String(step.index)]) : '', step?.app ?? ''].filter(Boolean).join(' · ') ||
+ [step ? i18n.t('export_stepLabel', [String(step.number)]) : '', step?.app ?? ''].filter(Boolean).join(' · ') ||
'\u00a0';
intro.hidden = !(armed || waiting || resting);
diff --git a/packages/core/src/guides/step-source-labels.ts b/packages/core/src/guides/step-source-labels.ts
new file mode 100644
index 0000000..f8e638f
--- /dev/null
+++ b/packages/core/src/guides/step-source-labels.ts
@@ -0,0 +1,8 @@
+import type { DescriptionSource } from './types';
+
+export const STEP_SOURCE_LABELS: Record<DescriptionSource, string> = {
+ ai: 'stepSource.ai',
+ narration: 'stepSource.voice',
+ heuristic: 'stepSource.basic',
+ manual: 'stepSource.edited',
+};
diff --git a/packages/ui/src/guide/components/StepSourceBadge.tsx b/packages/ui/src/guide/components/StepSourceBadge.tsx
index 4c76fb4..224e9e5 100644
--- a/packages/ui/src/guide/components/StepSourceBadge.tsx
+++ b/packages/ui/src/guide/components/StepSourceBadge.tsx
@@ -1,4 +1,5 @@
import { i18n } from '@mimik/core/env';
+import { STEP_SOURCE_LABELS } from '@mimik/core/guides/step-source-labels';
import type { DescriptionSource } from '@mimik/core/guides/types';
const STYLES: Record<DescriptionSource, string> = {
@@ -8,13 +9,6 @@ const STYLES: Record<DescriptionSource, string> = {
manual: 'border border-border text-muted-foreground',
};
-const LABELS: Record<DescriptionSource, string> = {
- ai: 'stepSource.ai',
- narration: 'stepSource.voice',
- heuristic: 'stepSource.basic',
- manual: 'stepSource.edited',
-};
-
export function StepSourceBadge({ source }: { source: DescriptionSource | undefined }) {
if (!source) return null;
@@ -23,7 +17,7 @@ export function StepSourceBadge({ source }: { source: DescriptionSource | undefi
className={`inline-block leading-none text-[9px] font-bold uppercase tracking-wide rounded px-1 py-[2px] shrink-0 ${STYLES[source]}`}
title={i18n.t('stepSource.hint')}
>
- {i18n.t(LABELS[source])}
+ {i18n.t(STEP_SOURCE_LABELS[source])}
</span>
);
}