forked from Savitura/crowdpay
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-embed.html
More file actions
179 lines (159 loc) Β· 4.95 KB
/
Copy pathtest-embed.html
File metadata and controls
179 lines (159 loc) Β· 4.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>External Site - Campaign Embed Test</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
background: #f5f5f5;
padding: 2rem;
line-height: 1.6;
}
.container {
max-width: 800px;
margin: 0 auto;
background: #fff;
padding: 2rem;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
h1 {
color: #111;
margin-bottom: 1rem;
}
p {
color: #555;
margin-bottom: 1.5rem;
}
.embed-section {
margin: 2rem 0;
padding: 1.5rem;
background: #fafafa;
border: 2px dashed #ddd;
border-radius: 8px;
}
.embed-label {
font-weight: 600;
color: #333;
margin-bottom: 1rem;
display: block;
}
.embed-wrapper {
display: flex;
justify-content: center;
gap: 2rem;
flex-wrap: wrap;
}
iframe {
border: 1px solid #e5e5e5;
border-radius: 8px;
}
.info-box {
background: #f0f9ff;
border-left: 4px solid #0ea5e9;
padding: 1rem;
margin: 1.5rem 0;
border-radius: 4px;
}
.info-box strong {
color: #0369a1;
}
code {
background: #f4f4f5;
padding: 0.2rem 0.4rem;
border-radius: 3px;
font-size: 0.9em;
font-family: monospace;
}
</style>
</head>
<body>
<div class="container">
<h1>π External Website - Campaign Embed Demo</h1>
<p>
This page simulates an external website (blog, creator site, etc.) embedding CrowdPay campaign widgets.
The embeds below are live and will update in real-time when contributions are made.
</p>
<div class="info-box">
<strong>How it works:</strong> The iframe loads from <code>http://localhost:5173/embed/campaigns/:id</code>
and communicates with the parent page via <code>postMessage</code> for auto-resizing.
No authentication required - anyone can view the embed!
</div>
<div class="embed-section">
<span class="embed-label">π Campaign Widget (480px width):</span>
<div class="embed-wrapper">
<!-- Replace CAMPAIGN_ID with an actual campaign ID from your database -->
<iframe
src="http://localhost:5173/embed/campaigns/1"
width="480"
height="280"
frameborder="0"
title="Campaign embed">
</iframe>
</div>
</div>
<div class="embed-section">
<span class="embed-label">π± Responsive Widget (320px width - mobile):</span>
<div class="embed-wrapper">
<iframe
src="http://localhost:5173/embed/campaigns/1"
width="320"
height="280"
frameborder="0"
title="Campaign embed mobile">
</iframe>
</div>
</div>
<div class="embed-section">
<span class="embed-label">π» Wide Widget (600px width - desktop):</span>
<div class="embed-wrapper">
<iframe
src="http://localhost:5173/embed/campaigns/1"
width="600"
height="280"
frameborder="0"
title="Campaign embed desktop">
</iframe>
</div>
</div>
<h2 style="margin-top: 2rem; margin-bottom: 1rem;">π Embed Code Example</h2>
<pre style="background: #f4f4f5; padding: 1rem; border-radius: 6px; overflow: auto; font-size: 0.85rem;">
<iframe src="https://crowdpay.io/embed/campaigns/[CAMPAIGN_ID]"
width="480" height="280" frameborder="0">
</iframe></pre>
<div class="info-box" style="margin-top: 2rem;">
<strong>Features:</strong>
<ul style="margin-top: 0.5rem; margin-left: 1.5rem;">
<li>β
Live progress bar updates via SSE (within 10 seconds)</li>
<li>β
"Back this campaign" button opens CrowdPay in new tab</li>
<li>β
Responsive design (300px - 600px width)</li>
<li>β
No authentication required</li>
<li>β
Auto-resizes via postMessage</li>
<li>β
Permissive CORS headers for cross-origin embedding</li>
</ul>
</div>
<script>
// Listen for postMessage events from embed iframes
window.addEventListener('message', (event) => {
// In production, you should validate event.origin
const { data } = event;
if (data.type === 'resize') {
// Auto-resize iframe (optional - iframes have fixed height for simplicity)
console.log('Embed wants to resize to:', data.height);
}
if (data.type === 'cta_click') {
// Track when users click "Back this campaign"
console.log('User clicked CTA for campaign:', data.campaignId);
}
});
</script>
</div>
</body>
</html>