Embed mini widget + prominent back button

Embed mode (?embed=1 or iframe detection):
- Shows sleek mini card (Make a Pledge) instead of full step 1
- 160px at rest, expands to 700px when user starts the flow
- postMessage resize signal for parent iframe auto-height
- Powered-by footer

Back button:
- Moved from hidden bottom bar to fixed top navigation bar
- ChevronLeft + "Back" text, always visible during backable steps
- Org name centered in header, step label on right
- Progress bar integrated into top bar

Embed code updated:
- iframe starts at height=160 (mini widget height)
- Includes resize listener script for auto-expansion
This commit is contained in:
2026-03-05 18:06:08 +08:00
parent 5c615ad35e
commit b6384da417
5 changed files with 183 additions and 41 deletions

View File

@@ -126,7 +126,7 @@ export default function CollectPage() {
setCopiedCode(code); setTimeout(() => setCopiedCode(null), 2000)
}
const copyEmbed = async (code: string) => {
const snippet = `<iframe src="${baseUrl}/p/${code}" width="100%" height="700" style="border:none;max-width:480px;" title="Make a Pledge"></iframe>`
const snippet = `<iframe src="${baseUrl}/p/${code}?embed=1" width="100%" height="160" style="border:none;max-width:480px;" title="Make a Pledge"></iframe>\n<script>window.addEventListener("message",e=>{if(e.data?.type==="pnpl-resize")document.querySelector('iframe[src*="${code}"]').style.height=e.data.height+"px"});<\/script>`
await navigator.clipboard.writeText(snippet)
setCopiedEmbed(code); setTimeout(() => setCopiedEmbed(null), 2000)
}
@@ -773,7 +773,7 @@ export default function CollectPage() {
<div className="space-y-3">
<p className="text-xs text-gray-600">Add the pledge form to your website. Copy this code and paste it into your HTML:</p>
<div className="bg-[#111827] p-4 overflow-x-auto">
<code className="text-[11px] text-[#4ADE80] font-mono whitespace-pre">{`<iframe\n src="${url}"\n width="100%"\n height="700"\n style="border:none;max-width:480px;"\n title="Pledge: ${src.label}"\n></iframe>`}</code>
<code className="text-[11px] text-[#4ADE80] font-mono whitespace-pre">{`<iframe\n src="${url}?embed=1"\n width="100%"\n height="160"\n style="border:none;max-width:480px;"\n title="Pledge: ${src.label}"\n></iframe>`}</code>
</div>
<button onClick={() => copyEmbed(src.code)} className={`w-full py-2.5 text-xs font-bold flex items-center justify-center gap-1.5 ${
isEmbedCopied ? "bg-[#16A34A] text-white" : "bg-[#111827] text-white hover:bg-gray-800"