-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
472 lines (405 loc) · 16.7 KB
/
index.html
File metadata and controls
472 lines (405 loc) · 16.7 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Consent Modal — Playground</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: #0a0a0a; color: #e0e0e0; line-height: 1.5;
}
.playground {
display: grid; grid-template-columns: 380px 1fr;
min-height: 100vh;
}
@media (max-width: 960px) {
.playground { grid-template-columns: 1fr; }
.preview-panel { border-left: none; border-top: 1px solid #1a1a1a; }
}
/* ── Sidebar ── */
.sidebar {
background: #0f0f0f; border-right: 1px solid #1a1a1a;
overflow-y: auto; max-height: 100vh; position: sticky; top: 0;
display: flex; flex-direction: column;
}
.sidebar-header {
padding: 1.25rem 1.25rem 0;
}
.sidebar-header h1 {
font-size: 1rem; font-weight: 700; color: #fff;
display: flex; align-items: center; gap: .5rem;
}
.sidebar-header h1 span { font-size: 1.1rem; }
.sidebar-header .tagline { font-size: .7rem; color: #555; margin-top: .25rem; }
.sidebar-body {
flex: 1; overflow-y: auto; padding: 1rem 1.25rem 1.25rem;
}
/* ── Sections & Fields ── */
.section { margin-bottom: 1.25rem; }
.section-title {
font-size: .65rem; text-transform: uppercase; letter-spacing: .08em;
color: #444; font-weight: 600; margin-bottom: .6rem;
display: flex; align-items: center; gap: .5rem;
}
.section-title::after {
content: ''; flex: 1; height: 1px; background: #1a1a1a;
}
.field { margin-bottom: .6rem; }
.field label { display: block; font-size: .7rem; color: #666; margin-bottom: .2rem; }
.field input, .field textarea, .field select {
width: 100%; padding: .45rem .6rem; border-radius: .4rem;
border: 1px solid #222; background: #141414; color: #e0e0e0;
font-size: .78rem; font-family: inherit; outline: none;
transition: border-color .15s;
}
.field input:focus, .field textarea:focus, .field select:focus {
border-color: #c6ff00;
}
.field textarea { resize: vertical; min-height: 2.5rem; }
.field select { cursor: pointer; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.color-field {
display: flex; align-items: center; gap: .4rem;
}
.color-field input[type="color"] {
width: 1.75rem; height: 1.75rem; border: none; background: none;
cursor: pointer; padding: 0; border-radius: .25rem;
}
.color-field input[type="text"] { flex: 1; }
.toggle-field {
display: flex; align-items: center; justify-content: space-between;
padding: .4rem 0;
}
.toggle-field label { margin: 0; font-size: .75rem; color: #888; cursor: pointer; }
.switch {
position: relative; width: 2.25rem; height: 1.25rem;
border-radius: 9999px; background: #222; cursor: pointer;
transition: background .2s; border: none;
}
.switch.on { background: #c6ff00; }
.switch::after {
content: ''; position: absolute; top: 2px; left: 2px;
width: calc(1.25rem - 4px); height: calc(1.25rem - 4px);
border-radius: 9999px; background: #fff; transition: transform .2s;
}
.switch.on::after { transform: translateX(1rem); background: #0a0a0a; }
/* ── Category Cards ── */
.cat-card {
background: #141414; border: 1px solid #1e1e1e; border-radius: .6rem;
padding: .75rem; margin-bottom: .5rem; position: relative;
}
.cat-card.locked { opacity: .55; }
.cat-header {
display: flex; justify-content: space-between; align-items: center;
margin-bottom: .5rem;
}
.cat-header strong { font-size: .78rem; color: #ccc; }
.cat-actions { display: flex; gap: .2rem; }
.icon-btn {
width: 1.3rem; height: 1.3rem; border-radius: .2rem; border: 1px solid #2a2a2a;
background: transparent; color: #555; cursor: pointer; font-size: .6rem;
display: flex; align-items: center; justify-content: center; transition: all .15s;
}
.icon-btn:hover { border-color: #c6ff00; color: #c6ff00; }
.icon-btn.del:hover { border-color: #e53e3e; color: #e53e3e; }
.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.cat-grid .full { grid-column: 1 / -1; }
.add-btn {
width: 100%; padding: .5rem; border-radius: .4rem;
border: 1px dashed #2a2a2a; background: transparent; color: #444;
cursor: pointer; font-size: .75rem; transition: all .15s;
}
.add-btn:hover { border-color: #c6ff00; color: #c6ff00; }
/* ── Preview Panel ── */
.preview-panel {
padding: 1.5rem; display: flex; flex-direction: column; gap: 1.25rem;
background: #0a0a0a;
}
.toolbar {
display: flex; gap: .5rem; flex-wrap: wrap; align-items: center;
}
.btn {
padding: .5rem 1rem; border-radius: .4rem; border: 1px solid #222;
background: #111; color: #ccc; font-weight: 600; cursor: pointer;
font-size: .75rem; transition: all .15s; font-family: inherit;
}
.btn:hover { border-color: #c6ff00; color: #c6ff00; }
.btn.primary { background: #c6ff00; color: #0a0a0a; border-color: #c6ff00; }
.btn.primary:hover { background: #d4ff33; }
.btn.danger { border-color: #e53e3e; color: #e53e3e; }
.btn.danger:hover { background: #e53e3e; color: #fff; }
.btn.outline-accent { border-color: #c6ff00; color: #c6ff00; }
.spacer { flex: 1; }
/* ── State Cards ── */
.panel-card {
background: #111; border: 1px solid #1a1a1a; border-radius: .6rem;
padding: 1rem; overflow: hidden;
}
.panel-card h3 {
font-size: .65rem; text-transform: uppercase; letter-spacing: .08em;
color: #444; font-weight: 600; margin-bottom: .6rem;
}
.panel-card pre {
font-size: .78rem; color: #c6ff00;
font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Fira Code', monospace;
white-space: pre-wrap; word-break: break-all;
}
.gcm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .4rem; }
.gcm-item {
display: flex; justify-content: space-between; align-items: center;
padding: .35rem .6rem; border-radius: .3rem; background: #0a0a0a;
}
.gcm-item .key { font-size: .72rem; color: #666; font-family: monospace; }
.gcm-item .val { font-size: .72rem; font-weight: 600; }
.gcm-item .val.granted { color: #48bb78; }
.gcm-item .val.denied { color: #e53e3e; }
.event-log {
max-height: 10rem; overflow-y: auto; font-size: .72rem; color: #555;
}
.code-block {
position: relative;
}
.copy-btn {
position: absolute; top: .5rem; right: .5rem;
padding: .25rem .5rem; border-radius: .25rem; border: 1px solid #333;
background: #1a1a1a; color: #888; cursor: pointer; font-size: .65rem;
transition: all .15s;
}
.copy-btn:hover { border-color: #c6ff00; color: #c6ff00; }
.dl-grid {
display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
}
@media (max-width: 700px) {
.dl-grid { grid-template-columns: 1fr; }
}
.tabs { display: flex; gap: 0; border-bottom: 1px solid #1a1a1a; margin-bottom: .75rem; }
.tab {
padding: .4rem .75rem; font-size: .72rem; color: #555; background: none;
border: none; border-bottom: 2px solid transparent; cursor: pointer;
font-family: inherit; transition: all .15s;
}
.tab:hover { color: #888; }
.tab.active { color: #c6ff00; border-bottom-color: #c6ff00; }
</style>
</head>
<body>
<div class="playground">
<!-- ── Sidebar ── -->
<div class="sidebar">
<div class="sidebar-header">
<h1><span>🍪</span> Consent Modal</h1>
<p class="tagline">Playground — configure and preview in real-time</p>
</div>
<div class="sidebar-body">
<!-- General -->
<div class="section">
<div class="section-title">General</div>
<div class="row">
<div class="field">
<label>Cookie Name</label>
<input type="text" id="cfg-cookie" value="demo_consent">
</div>
<div class="field">
<label>Cookie Days</label>
<input type="number" id="cfg-cookiedays" value="365" min="1" max="3650">
</div>
</div>
<div class="field">
<label>Privacy Policy URL</label>
<input type="text" id="cfg-privacy" value="#privacy">
</div>
<div class="field">
<label>Logo URL</label>
<input type="text" id="cfg-logo" value="" placeholder="https://example.com/logo.svg">
</div>
<div class="row">
<div class="field">
<label>Locale</label>
<select id="cfg-locale">
<option value="en">English</option>
<option value="es">Español</option>
<option value="de">Deutsch</option>
<option value="fr">Français</option>
<option value="pt">Português</option>
<option value="it">Italiano</option>
<option value="ca">Català</option>
<option value="eu">Euskara</option>
<option value="gl">Galego</option>
<option value="ja">日本語</option>
<option value="ko">한국어</option>
<option value="ru">Русский</option>
<option value="zh">中文</option>
<option value="ast">Asturianu</option>
</select>
</div>
<div class="field">
<label>Accent Color</label>
<div class="color-field">
<input type="color" id="cfg-color-picker" value="#c6ff00">
<input type="text" id="cfg-color" value="#c6ff00">
</div>
</div>
</div>
<div class="field">
<label>Dark Mode</label>
<select id="cfg-darkmode">
<option value="false">Light</option>
<option value="true">Dark</option>
<option value="auto">Auto (system)</option>
</select>
</div>
</div>
<!-- Behavior -->
<div class="section">
<div class="section-title">Behavior</div>
<div class="toggle-field">
<label for="cfg-autoshow">Auto-show when no consent</label>
<button class="switch on" id="cfg-autoshow" type="button" role="switch" aria-checked="true"></button>
</div>
<div class="toggle-field">
<label for="cfg-detectlocale">Auto-detect browser locale</label>
<button class="switch" id="cfg-detectlocale" type="button" role="switch" aria-checked="false"></button>
</div>
<div class="toggle-field">
<label for="cfg-blocknavigation">Block navigation until consent</label>
<button class="switch" id="cfg-blocknavigation" type="button" role="switch" aria-checked="false"></button>
</div>
</div>
<!-- Texts -->
<div class="section">
<div class="section-title">Texts</div>
<div class="field">
<label>Heading</label>
<input type="text" id="txt-heading" value="Privacy comes first">
</div>
<div class="field">
<label>Subheading</label>
<input type="text" id="txt-subheading" value="We respect your privacy and give you full control">
</div>
<div class="field">
<label>Description (HTML supported)</label>
<textarea id="txt-description" style="min-height:3rem"><p>This site uses cookies to keep things running smoothly and help us understand how we can improve.</p><p>You can accept everything, reject non-essential cookies, or customize your preferences.</p></textarea>
</div>
<div class="row">
<div class="field">
<label>Accept All</label>
<input type="text" id="txt-accept" value="Sounds good, accept all ✓">
</div>
<div class="field">
<label>Reject All</label>
<input type="text" id="txt-reject" value="Reject All">
</div>
</div>
<div class="row">
<div class="field">
<label>Customize</label>
<input type="text" id="txt-customize" value="Let me choose">
</div>
<div class="field">
<label>Save Choices</label>
<input type="text" id="txt-saveChoices" value="Save my choices">
</div>
</div>
<div class="row">
<div class="field">
<label>Customize Heading</label>
<input type="text" id="txt-customizeHeading" value="Choose your preferences">
</div>
<div class="field">
<label>Customize Subheading</label>
<input type="text" id="txt-customizeSubheading" value="Toggle what you're comfortable with">
</div>
</div>
<div class="row">
<div class="field">
<label>Back</label>
<input type="text" id="txt-back" value="← Back">
</div>
<div class="field">
<label>Footer Text</label>
<input type="text" id="txt-footerText" value="You can change your mind anytime in our">
</div>
</div>
<div class="field">
<label>Privacy Policy Link Text</label>
<input type="text" id="txt-privacyPolicyLink" value="privacy policy">
</div>
</div>
<!-- GCM Mappings -->
<div class="section">
<div class="section-title">GCM v2 Mappings</div>
<div class="row">
<div class="field">
<label>ad_storage</label>
<input type="text" id="gcm-ad_storage" value="marketing">
</div>
<div class="field">
<label>analytics_storage</label>
<input type="text" id="gcm-analytics_storage" value="analytics">
</div>
</div>
<div class="row">
<div class="field">
<label>ad_user_data</label>
<input type="text" id="gcm-ad_user_data" value="marketing">
</div>
<div class="field">
<label>ad_personalization</label>
<input type="text" id="gcm-ad_personalization" value="marketing">
</div>
</div>
</div>
<!-- Custom CSS -->
<div class="section">
<div class="section-title">Custom CSS Override</div>
<div class="field">
<textarea id="css-editor" style="min-height:5rem;font-family:'SF Mono',Monaco,'Cascadia Code',monospace;font-size:.72rem;line-height:1.4">/* Injected into Shadow DOM after default styles */
/* e.g. .cm-card { border-radius: 0; } */</textarea>
</div>
</div>
<!-- Categories -->
<div class="section">
<div class="section-title">Categories</div>
<div id="categories-list"></div>
<button class="add-btn" id="add-category">+ Add Category</button>
</div>
</div>
</div>
<!-- ── Preview Panel ── -->
<div class="preview-panel">
<div class="toolbar">
<button class="btn primary" id="btn-show">Open Modal</button>
<button class="btn" id="btn-settings">Open Settings</button>
<span class="spacer"></span>
<button class="btn danger" id="btn-reset">Clear Cookie & Reload</button>
</div>
<div class="dl-grid">
<div class="panel-card">
<h3>Consent State</h3>
<pre id="state-output">{ }</pre>
</div>
<div class="panel-card">
<h3>Google Consent Mode v2</h3>
<div class="gcm-grid" id="gcm-output"></div>
</div>
</div>
<div class="panel-card">
<h3>Event Log</h3>
<pre class="event-log" id="event-log">Waiting for events...</pre>
</div>
<div class="panel-card code-block">
<div class="tabs">
<button class="tab active" data-tab="code-esm">ESM</button>
<button class="tab" data-tab="code-cdn">CDN / Script Tag</button>
</div>
<button class="copy-btn" id="copy-code">Copy</button>
<pre id="code-esm" style="font-size:.72rem"></pre>
<pre id="code-cdn" style="font-size:.72rem;display:none"></pre>
</div>
</div>
</div>
<script type="module" src="./playground.ts"></script>
</body>
</html>