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 📖

fix(desktop): keep the recording card one height as steps land

Luis Ortiz1b787418d949
diff --git a/apps/desktop/scripts/check-overlay.ts b/apps/desktop/scripts/check-overlay.ts
index 1a85a1c..da5c552 100644
--- a/apps/desktop/scripts/check-overlay.ts
+++ b/apps/desktop/scripts/check-overlay.ts
@@ -254,7 +254,7 @@ app.whenReady().then(async () => {
"document.querySelector('#primary').disabled",
);
const veil = await card(
- "text: document.querySelector('#veilText').textContent, remove: document.querySelector('#remove').hidden, shot: document.querySelector('#shot').hidden",
+ "text: document.querySelector('#veilText').textContent, remove: document.querySelector('#remove').hidden, shot: document.querySelector('#shot').hidden, height: document.body.scrollHeight",
);
check(
'a capture in flight shows the mascot instead of the last screenshot',
@@ -263,6 +263,17 @@ app.whenReady().then(async () => {
);
overlay.setBusy(false);
await settle();
+ const shortTitle = await card("height: document.body.scrollHeight, preview: document.querySelector('#preview').offsetHeight");
+ overlay.showStep({ id: 'one', index: 1, title: 'Click '.repeat(40), 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', 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',
+ shortTitle.height === veil.height && longTitle.height === veil.height && longTitle.preview < shortTitle.preview,
+ `${veil.height} px while capturing, ${shortTitle.height} px with a short title, ${longTitle.height} px with a long one, preview ${shortTitle.preview} → ${longTitle.preview} px`,
+ );
const whenIdle = await windowWithHash('controls')?.webContents.executeJavaScript(
"document.querySelector('#primary').disabled",
);
diff --git a/apps/desktop/src/renderer/overlay.css b/apps/desktop/src/renderer/overlay.css
index 32cbe85..7d83d52 100644
--- a/apps/desktop/src/renderer/overlay.css
+++ b/apps/desktop/src/renderer/overlay.css
@@ -358,7 +358,7 @@ body.controls #body {
body.controls #preview {
position: relative;
- height: 150px;
+ height: calc(150px - var(--title-extra, 0px));
border: 1px solid #e0e7ff;
border-radius: 10px;
background: #eef2ff;
@@ -421,7 +421,8 @@ body.controls #remove svg {
}
body.controls #stepTitle,
-body.controls #writing {
+body.controls #writing,
+body.controls #skeleton .line {
margin: 11px 0 0;
font-size: 13px;
line-height: 1.45;
@@ -459,15 +460,9 @@ body.controls #pillWriting svg {
}
}
-body.controls #skeleton {
- display: flex;
- flex-direction: column;
- gap: 8px;
- margin-top: 13px;
-}
-
body.controls #skeleton span {
- display: block;
+ display: inline-block;
+ vertical-align: middle;
height: 10px;
width: 78%;
border-radius: 5px;
@@ -476,7 +471,7 @@ body.controls #skeleton span {
animation: shimmer 1.4s linear infinite;
}
-body.controls #skeleton span + span {
+body.controls #skeleton .meta span {
width: 38%;
}
@@ -489,7 +484,8 @@ body.controls #skeleton span + span {
}
}
-body.controls #stepMeta {
+body.controls #stepMeta,
+body.controls #skeleton .meta {
display: flex;
align-items: center;
gap: 6px;
diff --git a/apps/desktop/src/renderer/overlay/controls.ts b/apps/desktop/src/renderer/overlay/controls.ts
index b7af4d4..3a18959 100644
--- a/apps/desktop/src/renderer/overlay/controls.ts
+++ b/apps/desktop/src/renderer/overlay/controls.ts
@@ -43,7 +43,12 @@ export function controls(): void {
const stepTitle = el('p', { id: 'stepTitle' });
const writing = el('p', { id: 'writing' }, icon('loader', 13), 'Writing step description…');
- const skeleton = el('div', { id: 'skeleton' }, el('span', {}), el('span', {}));
+ const skeleton = el(
+ 'div',
+ { id: 'skeleton' },
+ el('p', { className: 'line' }, el('span', {}), '\u00a0'),
+ el('div', { className: 'meta' }, el('span', {}), '\u00a0'),
+ );
const source = el('span', { id: 'source' });
const metaText = el('span', { id: 'metaText' });
const stepMeta = el('div', { id: 'stepMeta' }, source, metaText);
@@ -132,6 +137,8 @@ export function controls(): void {
const settled = Boolean(step) && !busy && !paused;
stepTitle.textContent = step?.title ?? '';
stepTitle.hidden = !settled || pending;
+ const extra = stepTitle.getBoundingClientRect().height - Number.parseFloat(getComputedStyle(stepTitle).lineHeight);
+ preview.style.setProperty('--title-extra', `${stepTitle.hidden ? 0 : Math.max(0, extra)}px`);
writing.hidden = !settled || !pending;
skeleton.hidden = !busy;
stepMeta.hidden = !settled;