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: export cover β€” clean centered layout with badge, gradient, metadata

Luis Ortiz5edab5c4c188
diff --git a/src/core/export/html-export.ts b/src/core/export/html-export.ts
index de8e978..a09fbec 100644
--- a/src/core/export/html-export.ts
+++ b/src/core/export/html-export.ts
@@ -49,12 +49,23 @@ export async function exportGuideAsHTML(
</style>
</head>
<body>
- <div style="margin-bottom:48px;">
- <span style="display:inline-block;background:#4F46E5;color:#fff;font-size:13px;font-weight:600;padding:4px 14px;border-radius:999px;margin-bottom:20px;">${steps.length} step${steps.length === 1 ? '' : 's'}</span>
- <div style="height:2px;background:linear-gradient(to right,#4F46E5,#C7D2FE,#38BDF8);border-radius:1px;margin-bottom:24px;"></div>
- <h1 style="font-size:28px;font-weight:700;color:#1E1B4B;line-height:1.3;margin-bottom:20px;">${escapeHtml(guide.title)}</h1>
- <div style="background:#EEF2FF;border-radius:8px;padding:14px 20px;font-size:14px;color:#4338CA;">
- Created ${formatDate(guide.createdAt)}${metaSeparator}${domainHtml}
+ <div style="margin-bottom:48px;text-align:center;display:flex;flex-direction:column;align-items:center;">
+ <span style="display:inline-block;background:#4F46E5;color:#fff;font-size:13px;font-weight:600;padding:5px 16px;border-radius:999px;">${steps.length} Step${steps.length === 1 ? '' : 's'}</span>
+ <div style="height:3px;width:60%;background:linear-gradient(to right,#4F46E5,#C7D2FE,#38BDF8);border-radius:3px;margin:20px auto;"></div>
+ <h1 style="font-size:28px;font-weight:800;color:#1E1B4B;line-height:1.2;margin-bottom:24px;max-width:80%;">${escapeHtml(guide.title)}</h1>
+ <div style="display:flex;gap:32px;justify-content:center;">
+ <div style="text-align:left;">
+ <div style="font-size:10px;font-weight:600;color:#6B7280;text-transform:uppercase;letter-spacing:0.06em;">Created</div>
+ <div style="font-size:14px;font-weight:600;color:#1E1B4B;">${formatDate(guide.createdAt)}</div>
+ </div>
+ ${
+ domain
+ ? `<div style="text-align:left;">
+ <div style="font-size:10px;font-weight:600;color:#6B7280;text-transform:uppercase;letter-spacing:0.06em;">Source</div>
+ <div style="font-size:14px;font-weight:600;color:#4F46E5;">${escapeHtml(domain)}</div>
+ </div>`
+ : ''
+ }
</div>
</div>
diff --git a/src/core/export/pdf-export.ts b/src/core/export/pdf-export.ts
index c838324..a7897e1 100644
--- a/src/core/export/pdf-export.ts
+++ b/src/core/export/pdf-export.ts
@@ -14,66 +14,76 @@ export async function exportGuideAsPDF(
const margin = 20;
const contentWidth = pageWidth - margin * 2;
- let y = pageHeight / 2 - 30;
+ const centerX = pageWidth / 2;
+ const domain = extractDomain(steps);
+ const dateStr = formatDate(guide.createdAt);
const badgeText = `${steps.length} Steps`;
- doc.setFontSize(9);
+ doc.setFontSize(10);
doc.setFont('helvetica', 'bold');
- const badgeWidth = doc.getTextWidth(badgeText) + 8;
- const badgeHeight = 7;
- doc.setFillColor(79, 70, 229);
- doc.roundedRect(margin, y, badgeWidth, badgeHeight, 2, 2, 'F');
- doc.setTextColor(255, 255, 255);
- doc.text(badgeText, margin + 4, y + 4.8);
- y += badgeHeight + 6;
-
- const segmentWidth = contentWidth / 3;
- doc.setFillColor(139, 92, 246);
- doc.rect(margin, y, segmentWidth, 1.2, 'F');
- doc.setFillColor(167, 139, 250);
- doc.rect(margin + segmentWidth, y, segmentWidth, 1.2, 'F');
- doc.setFillColor(125, 211, 252);
- doc.rect(margin + segmentWidth * 2, y, segmentWidth, 1.2, 'F');
- y += 8;
+ const badgeTextWidth = doc.getTextWidth(badgeText);
+ const badgePadH = 5;
+ const badgePadV = 2.5;
+ const badgeW = badgeTextWidth + badgePadH * 2;
+ const badgeH = 7;
doc.setFontSize(22);
doc.setFont('helvetica', 'bold');
- doc.setTextColor(30, 27, 75);
- const titleLines = doc.splitTextToSize(guide.title, contentWidth);
- doc.text(titleLines, margin, y);
- y += titleLines.length * 9 + 10;
+ const titleLines = doc.splitTextToSize(guide.title, contentWidth * 0.8);
+ const titleBlockH = titleLines.length * 9;
- const cardPadding = 6;
- const domain = extractDomain(steps);
- const dateStr = formatDate(guide.createdAt);
+ const gradLineW = contentWidth * 0.6;
+ const totalBlockH = badgeH + 8 + 1.5 + 10 + titleBlockH + 16 + 12;
+ let y = (pageHeight - totalBlockH) / 2;
+
+ doc.setFillColor(79, 70, 229);
+ doc.roundedRect(centerX - badgeW / 2, y, badgeW, badgeH, 3.5, 3.5, 'F');
+ doc.setFontSize(10);
+ doc.setTextColor(255, 255, 255);
+ doc.text(badgeText, centerX, y + 5, { align: 'center' });
+ y += badgeH + 8;
- let cardHeight = cardPadding * 2 + 10;
- if (domain) cardHeight += 14;
+ const gradX = centerX - gradLineW / 2;
+ const segW = gradLineW / 3;
+ doc.setFillColor(79, 70, 229);
+ doc.rect(gradX, y, segW, 1.5, 'F');
+ doc.setFillColor(199, 210, 254);
+ doc.rect(gradX + segW, y, segW, 1.5, 'F');
+ doc.setFillColor(56, 189, 248);
+ doc.rect(gradX + segW * 2, y, segW, 1.5, 'F');
+ y += 10;
- doc.setFillColor(238, 242, 255);
- doc.roundedRect(margin, y, contentWidth, cardHeight, 3, 3, 'F');
+ doc.setFontSize(22);
+ doc.setFont('helvetica', 'bold');
+ doc.setTextColor(30, 27, 75);
+ doc.text(titleLines, centerX, y, { align: 'center' });
+ y += titleBlockH + 16;
- let cardY = y + cardPadding;
+ const metaColW = 40;
+ const metaGap = 16;
+ const numCols = domain ? 2 : 1;
+ const metaTotalW = numCols * metaColW + (numCols - 1) * metaGap;
+ let metaX = centerX - metaTotalW / 2;
doc.setFontSize(7);
doc.setFont('helvetica', 'bold');
doc.setTextColor(107, 114, 128);
- doc.text('CREATED', margin + cardPadding, cardY + 4);
- doc.setFontSize(10);
+ doc.text('CREATED', metaX, y);
+ doc.setFontSize(12);
doc.setFont('helvetica', 'normal');
doc.setTextColor(30, 27, 75);
- doc.text(dateStr, margin + cardPadding, cardY + 10);
+ doc.text(dateStr, metaX, y + 6);
if (domain) {
- cardY += 14;
+ metaX += metaColW + metaGap;
doc.setFontSize(7);
doc.setFont('helvetica', 'bold');
doc.setTextColor(107, 114, 128);
- doc.text('SOURCE', margin + cardPadding, cardY + 4);
- doc.setFontSize(10);
+ doc.text('SOURCE', metaX, y);
+ doc.setFontSize(12);
doc.setFont('helvetica', 'normal');
doc.setTextColor(79, 70, 229);
- doc.text(domain, margin + cardPadding, cardY + 10);
+ doc.text(domain, metaX, y + 6);
}
const stepIndent = 16;