rivia 0.0.34 → 0.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +657 -150
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2,12 +2,9 @@
2
2
  function slugify(text) {
3
3
  return "/" + String(text || "").trim().toLowerCase().replace(/[^a-z0-9\-_\s]/g, "").replace(/\s+/g, "-");
4
4
  }
5
- function Onboarding(topTitle = "Get Started", subtitle, completion = 0, checklistItems = [], cssText = [], targetingData = {}, user_var, checklist_id) {
5
+ function Onboarding(topTitle = "Get Started", subtitle, completion = 0, checklistItems = [], cssText = [], targetingData = {}, customCSS = "", user_var, checklist_id) {
6
6
  let usrn = targetingData?.targeting_data?.usernames ?? "Not Set";
7
7
  let inc = targetingData?.targeting_data?.inclusion ?? "Not Set";
8
- if (sessionStorage.getItem("dismissedChecklist") == "true") {
9
- return;
10
- }
11
8
  const mymap = /* @__PURE__ */ new Map();
12
9
  for (let i2 = 0; i2 < usrn.length; i2++) {
13
10
  mymap.set(usrn[i2], true);
@@ -181,7 +178,8 @@ function Onboarding(topTitle = "Get Started", subtitle, completion = 0, checklis
181
178
  backendUrl,
182
179
  progressData,
183
180
  visitedPages,
184
- cleanUrlItems
181
+ cleanUrlItems,
182
+ customCSS
185
183
  );
186
184
  });
187
185
  } else {
@@ -240,77 +238,240 @@ function Onboarding(topTitle = "Get Started", subtitle, completion = 0, checklis
240
238
  backendUrl,
241
239
  [],
242
240
  visitedPages,
243
- cleanUrlItems
241
+ cleanUrlItems,
242
+ customCSS
244
243
  );
245
244
  }
246
245
  }
247
- async function fetchWithTimeout(topTitle = "Get Started", subtitle, completion = 0, checklistItems = [], cssText = [], targetingData = {}, user_var, checklist_id, cssConfig = {}, items = [], storedVisited = [], backendUrl = "", progressData = {}, visitedPages = {}, cleanUrlItems = []) {
246
+ async function fetchWithTimeout(topTitle = "Get Started", subtitle, completion = 0, checklistItems = [], cssText = [], targetingData = {}, user_var, checklist_id, cssConfig = {}, items = [], storedVisited = [], backendUrl = "", progressData = {}, visitedPages = {}, cleanUrlItems = [], custom_css = "") {
248
247
  console.log("inside fetchWithTimeout", user_var);
249
248
  if (!user_var)
250
249
  return;
251
250
  let i = 0;
252
251
  const stepsHTML = items.map((it) => {
253
- const border = it.color || cssConfig.borderColor1;
254
- const bg = it.color || cssConfig.lowerBackgroundColor;
255
252
  return `
256
- <div id="${it.id}"
257
- class="onboard-step"
258
- style="position: relative; margin-bottom:16px; display:flex; align-items:flex-start; cursor:pointer; background-color:${bg}; padding:8px; border-radius:6px;">
259
-
260
- <!-- left vertical selector bar -->
261
- <div class="start-select"
262
- style="position:absolute; top:0; left:-18px; width:10px; height:120%; background:rgba(247,143,7,0.9); border-radius:4px 0 0 4px; display:none;">
263
- </div>
264
-
265
- <div class="onboard-circle"
266
- style="min-width:16px; min-height:16px; width:16px; height:16px; border-radius:50%;
267
- border:2px solid ${cssConfig.lowerCheckboxColor}; margin-right:10px; box-sizing:border-box;"></div>
253
+ <div id="${it.id}" class="onboard-step">
254
+ <div class="start-select"></div>
255
+
256
+ <div class="onboard-circle"></div>
268
257
 
269
- <div class="onboard-text"
270
- style=" font-family:${cssConfig.fontFamily}; font-size:${cssConfig.fontSize};">
271
- <strong style="color:${cssConfig.lowerHeadingColor};">${it.title}</strong><br>
272
- <small style="color:${cssConfig.lowerBodyColor};">${it.description || ""}</small>
258
+ <div class="onboard-text">
259
+ <strong class="onboard-title">${it.title}</strong><br />
260
+ <small class="onboard-desc">${it.description || ""}</small>
273
261
  </div>
274
262
  </div>
275
- ${i++ < items.length - 1 ? '<hr style="color: #9d9d9dff">' : ""}
276
- `;
263
+ ${i++ < items.length - 1 ? '<hr class="onboard-divider" />' : ""}
264
+ `;
277
265
  }).join("");
278
266
  const labelHTML = `
279
- <div id="checklistRoot"
280
- style="max-width:500px; margin:auto; font-family:${cssConfig.fontFamily}; font-size:${cssConfig.fontSize}; color:${cssConfig.textColor}; position: relative;">
281
-
282
- <!-- Close button -->
283
- <button id="checklistCloseBtn"
284
- style="
285
- position: absolute;
286
- top: 8px;
287
- left: 370px;
288
- background: transparent;
289
- border: none;
290
- font-size: 28px;
291
- cursor: pointer;
292
- color: ${cssConfig.textColor};
293
- line-height: 1;
294
- ">
295
- &times;
296
- </button>
297
-
298
- <div style="background-color:${cssConfig.backgroundColor}; padding:16px; border-radius:8px 8px 0 0;">
299
- <h3 style="margin:0;">${topTitle}</h3>
300
- <p style="margin-top:8px;color: ${cssConfig.subtitleColor};">${subtitle}</p>
301
- <div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px;">
302
- <div id="progressContainer" style="display: flex; gap: 4px; width: 300%; width: 800px; height: 10px;"></div>
267
+ <div id="checklistRoot" class="checklist-root">
268
+ <button id="checklistCloseBtn" class="checklist-close">&times;</button>
269
+
270
+ <div class="checklist-header">
271
+ <h3 class="checklist-title">${topTitle}</h3>
272
+ <p class="checklist-subtitle">${subtitle}</p>
273
+
274
+ <div class="checklist-progress">
275
+ <div id="progressContainer" style="display: flex; gap: 4px; width: 300px; height: 10px;"></div>
303
276
  <span id="progressFraction" style="margin-left: 0px; font-size: 13px; color: ${cssConfig.textColor}; min-width: 20px; text-align: right;">0/0 </span>
277
+
278
+ </div>
279
+
280
+ </div>
281
+
282
+ <div class="checklist-body">
283
+ ${stepsHTML}
284
+ <div style="text-align: right; margin-top: 10px; cursor: pointer; color: black; font-size: 12px;" id="dismissChecklist">Dismiss this checklist</div>
285
+ </div>
304
286
  </div>
287
+ `;
288
+ function injectChecklistBaseCSS() {
289
+ if (document.getElementById("rivia-checklist-css")) return;
290
+ const style2 = document.createElement("style");
291
+ style2.id = "rivia-checklist-css";
292
+ style2.textContent = custom_css || `/* Root */
293
+ .checklist-root {
294
+ max-width: 500px;
295
+ margin: auto;
296
+ position: relative;
297
+ font-family: var(--font-family);
298
+ font-size: var(--font-size);
299
+ color: var(--text-color);
300
+ }
305
301
 
306
- </div>
302
+ /* Close button */
303
+ .checklist-close {
304
+ position: absolute;
305
+ top: 8px;
306
+ right: 12px;
307
+ background: transparent;
308
+ border: none;
309
+ font-size: 28px;
310
+ cursor: pointer;
311
+ color: var(--text-color);
312
+ }
307
313
 
308
- <div style="border-top:none; border-radius:0 0 8px 8px; padding:16px; background-color:${cssConfig.lowerBackgroundColor}; max-height:340px; overflow:auto;">
309
- ${stepsHTML}
310
- <div style="text-align: right; margin-top: 10px; cursor: pointer; color: black; font-size: 12px;" id="dismissChecklist">Dismiss this checklist</div>
311
- </div>
312
- </div>
313
- `;
314
+ /* Header */
315
+ .checklist-header {
316
+ background: var(--header-bg);
317
+ padding: 16px;
318
+ border-radius: 8px 8px 0 0;
319
+ }
320
+
321
+ .checklist-subtitle {
322
+ margin-top: 8px;
323
+ color: var(--subtitle-color);
324
+ }
325
+
326
+ /* Progress */
327
+ .checklist-progress {
328
+ display: flex;
329
+ align-items: center;
330
+ justify-content: space-between;
331
+ }
332
+
333
+ .progress-fraction {
334
+ font-size: 13px;
335
+ }
336
+
337
+ /* Body */
338
+ .checklist-body {
339
+ padding: 16px;
340
+ background: var(--lower-bg);
341
+ max-height: 340px;
342
+ overflow: auto;
343
+ border-radius: 0 0 8px 8px;
344
+ }
345
+
346
+ /* Steps */
347
+ .onboard-step {
348
+ position: relative;
349
+ display: flex;
350
+ align-items: flex-start;
351
+ cursor: pointer;
352
+ padding: 8px;
353
+ border-radius: 6px;
354
+ background: var(--step-bg);
355
+ margin-bottom: 16px;
356
+ }
357
+
358
+ .start-select {
359
+ position: absolute;
360
+ top: 0;
361
+ left: -18px;
362
+ width: 10px;
363
+ height: 120%;
364
+ background: rgba(247,143,7,0.9);
365
+ border-radius: 4px 0 0 4px;
366
+ display: none;
367
+ }
368
+
369
+ .onboard-circle {
370
+ width: 16px;
371
+ height: 16px;
372
+ min-width: 16px;
373
+ min-height: 16px;
374
+ border-radius: 50%;
375
+ border: 2px solid var(--checkbox-color, #f78f07);
376
+ background: transparent;
377
+ margin-right: 10px;
378
+ box-sizing: border-box;
379
+ display: block;
380
+ }
381
+
382
+ .onboard-title {
383
+ color: var(--heading-color);
384
+ }
385
+
386
+ .onboard-desc {
387
+ color: var(--body-color);
388
+ }
389
+
390
+ .onboard-divider {
391
+ border: none;
392
+ border-top: 1px solid #9d9d9d;
393
+ }
394
+
395
+ .rivia-launcher {
396
+ position: fixed;
397
+ display: block;
398
+ z-index: 9999;
399
+ cursor: pointer;
400
+ border: none;
401
+ box-shadow: 0 2px 8px rgba(19, 20, 19, 0.2);
402
+ background: var(--launcher-bg);
403
+ color: var(--launcher-text);
404
+ font-weight: bold;
405
+ border-radius: 20px;
406
+ }
407
+
408
+ .rivia-launcher .launcher-root {
409
+ display: flex;
410
+ align-items: center;
411
+ width: 100%;
412
+ height: 100%;
413
+ }
414
+
415
+ .rivia-launcher .launcher-left {
416
+ flex: 1;
417
+ display: flex;
418
+ flex-direction: column;
419
+ }
420
+
421
+ .rivia-launcher .launcher-title {
422
+ transform: translateY(-20%);
423
+ position: relative;
424
+ margin: 0;
425
+ line-height: 1;
426
+ text-align: center;
427
+ padding-left: 28px;
428
+ }
429
+
430
+ .rivia-launcher .launcher-icon {
431
+ position: absolute;
432
+ left: 10px;
433
+
434
+ }
435
+
436
+ .rivia-launcher .launcher-text { font-size:var(--font-size);
437
+ display: block;
438
+ width: 100%;
439
+ padding-left: 5%;
440
+ text-align: center;
441
+ pointer-events: none;
442
+ }
443
+
444
+ .rivia-launcher .launcher-progress-wrap {
445
+ margin-top: 4px;
446
+ padding-left: 32px;
447
+ }
448
+
449
+ /* Text adjustment when progress bar is hidden */
450
+ .rivia-launcher.no-progress .launcher-text {
451
+ transform: translateY(50%);
452
+ }
453
+
454
+ .rivia-launcher .launcher-progress {
455
+ display: flex;
456
+ gap: 4px;
457
+ width: 100%;
458
+ padding: 5px;
459
+ height: 6px;
460
+ box-sizing: border-box;
461
+ }
462
+
463
+ .rivia-launcher .launcher-right {
464
+ flex-shrink: 0;
465
+ padding-right: 8px;
466
+ }
467
+
468
+ .rivia-launcher .launcher-fraction {
469
+ font-size: 13px;
470
+ white-space: nowrap;
471
+ }`;
472
+ document.head.appendChild(style2);
473
+ console.log("inside injectChecklistBaseCSS");
474
+ }
314
475
  const label = document.createElement("div");
315
476
  label.id = "route-label";
316
477
  label.innerHTML = labelHTML;
@@ -356,39 +517,41 @@ async function fetchWithTimeout(topTitle = "Get Started", subtitle, completion =
356
517
  });
357
518
  function createSlabs(n) {
358
519
  const container = label.querySelector("#progressContainer");
520
+ if (!container) return;
359
521
  container.innerHTML = "";
360
522
  for (let i2 = 0; i2 < n; i2++) {
361
523
  const slab = document.createElement("div");
362
- slab.classList.add("slab");
524
+ slab.className = "slab";
363
525
  container.appendChild(slab);
364
526
  }
365
527
  }
366
528
  const style = document.createElement("style");
367
529
  style.textContent = `
368
- .slab {
369
- flex: 1;
530
+ .slab {
531
+ flex: 1 0 0%; /* \u{1F512} important */
532
+ min-width: 5px;
370
533
  height: 8px;
371
534
  background-color: #ccc;
372
535
  border-radius: 4px;
373
- transition: background-color 0.3s;
536
+ transition: background-color 0.3s ease;
374
537
  }
375
538
  .slab.active {
376
539
  background-color: #4caf50;
377
- }
378
- #progressContainerBtn .slab {
379
- height: 5px;
380
- }
381
- `;
540
+ }
541
+ #progressContainerBtn .slab {
542
+ height: 5px;
543
+ }
544
+ `;
382
545
  label.appendChild(style);
383
546
  function updateProgress(completed) {
384
547
  const slabs = label.querySelectorAll(".slab");
385
548
  slabs.forEach((slab, index) => {
386
- if (index < completed) {
387
- slab.classList.add("active");
388
- } else {
389
- slab.classList.remove("active");
390
- }
549
+ slab.classList.toggle("active", index < completed);
391
550
  });
551
+ const fraction = label.querySelector("#progressFraction");
552
+ if (fraction) {
553
+ fraction.textContent = `${completed}/${slabs.length}`;
554
+ }
392
555
  }
393
556
  createSlabs(items.length);
394
557
  if (storedVisited) updateProgress(storedVisited.length);
@@ -404,7 +567,7 @@ async function fetchWithTimeout(topTitle = "Get Started", subtitle, completion =
404
567
  fontSize: cssConfig.fontSize,
405
568
  fontFamily: cssConfig.fontFamily,
406
569
  boxShadow: "0 4px 12px rgba(0, 0, 0, 0.2)",
407
- width: "90%",
570
+ width: "400px",
408
571
  maxWidth: "400px",
409
572
  maxHeight: "500px",
410
573
  lineHeight: "1.5",
@@ -437,108 +600,91 @@ async function fetchWithTimeout(topTitle = "Get Started", subtitle, completion =
437
600
  });
438
601
  }
439
602
  showBtn.id = "show-tooltip-btn";
603
+ showBtn.className = "rivia-launcher";
440
604
  const translateStyle = cssConfig.launcherProgressBar ? 'style="transform: translateY(10px);"' : "";
441
- const iconHTML = cssConfig.launcherShowIcon ? `<svg width="24" height="24" ${translateStyle} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
605
+ const isRight = cssConfig.launcherPosition === "right";
606
+ const iconHTML = cssConfig.launcherShowIcon ? `<svg class="launcher-icon" width="24" height="24" ${translateStyle} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
442
607
  <path d="M8 10.167L12.123 6.043C13.248 4.919 13.811 4.356 14.431 3.903C15.7049 2.97403 17.1822 2.36274 18.74 2.12C19.499 2 20.293 2 21.885 2C21.968 2 22 2.038 22 2.115C22 3.705 22 4.501 21.881 5.26C21.638 6.81791 21.0263 8.29523 20.097 9.569C19.644 10.189 19.081 10.752 17.957 11.877L13.833 16" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
443
608
  <path d="M10.341 8.098C8.638 8.098 6.498 7.738 4.904 8.398C3.737 8.88 2.878 10 2 10.878L5.306 12.296C6.182 12.671 5.646 13.776 5.501 14.502C5.34 15.31 5.349 15.34 5.931 15.922L8.078 18.068C8.66 18.651 8.69 18.66 9.498 18.498C10.223 18.353 11.329 17.818 11.704 18.694L13.121 22C13.999 21.122 15.119 20.263 15.602 19.096C16.262 17.502 15.902 15.362 15.902 13.659" stroke="white" stroke-width="1.5" stroke-linejoin="round"/>
444
609
  <path d="M12 20L11 21M4 12L3 13" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
445
610
  <path d="M15 4.08008C16.2 4.26008 17.46 4.74008 18.161 5.46008C19.058 6.25208 19.68 7.32008 19.92 9.00008" stroke="white" stroke-width="1.5" stroke-linecap="square"/>
446
611
  <path d="M17.94 6.05957L16.5 7.49957" stroke="white" stroke-width="1.5" stroke-linecap="round"/>
447
612
  </svg>` : "";
448
- const progressPaddingLeft = cssConfig.launcherShowIcon ? "28px" : "0px";
449
613
  const textTranslateStyle = !cssConfig.launcherProgressBar ? " translateY(50%);" : "";
614
+ if (!cssConfig.launcherProgressBar) {
615
+ showBtn.classList.add("no-progress");
616
+ }
450
617
  showBtn.innerHTML = `
451
- <div style="display:flex; align-items:center; gap:0px; width:100%;">
452
-
453
- <!-- LEFT COLUMN -->
454
- <div style="flex:1; display:flex; flex-direction:column; box-sizing:border-box; padding-left:${progressPaddingLeft};">
455
-
456
- <!-- TITLE ROW -->
457
- <h3 style="
458
- margin:0;
459
- position:relative;
460
- line-height:1;
461
- ">
462
- <!-- ICON: fixed original position -->
463
- <span style="
464
- position:absolute;
465
- left:-20px;
466
- transform:translateY(-50%);
467
- display:flex;
468
- align-items:center;
469
- ">
470
- ${iconHTML}
471
- </span>
472
-
473
- <!-- TEXT: centered over progress bar -->
474
- <span style="
475
- display:block;
476
- width:100%;
477
- padding-left:5%;
478
- text-align:center;
479
- margin-top:-10%;
480
- transform: ${textTranslateStyle};
481
- pointer-events:none;
482
- font-size: ${cssConfig.fontSize};
483
- ">
484
- ${cssConfig.launcher_text}
485
- </span>
618
+ <div class="launcher-root">
619
+ <div class="launcher-left">
620
+
621
+ <h3 class="launcher-title">
622
+ ${iconHTML}
623
+ <span class="launcher-text">${cssConfig.launcher_text}</span>
486
624
  </h3>
487
625
 
488
- <!-- PROGRESS BAR -->
489
- <div style="width:100%; margin-top:-2px; padding-left:4%;">
490
- <div id="progressContainerBtn" style="
491
- display:flex;
492
- gap:4px;
493
- width:100%;
494
- padding:5px;
495
- height:3px;
496
- box-sizing:border-box;
497
- "></div>
626
+ <div class="launcher-progress-wrap">
627
+ <div id="progressContainerBtn" class="launcher-progress"></div>
498
628
  </div>
629
+
499
630
  </div>
500
631
 
501
- <!-- RIGHT COLUMN: fraction -->
502
- <div style="flex-shrink:0; display:flex; align-items:center;">
503
- <span id="progressFraction" style="
504
- font-size:13px;
505
- white-space:nowrap;
506
- color:${cssConfig.launcherTextColor};
507
- padding-right:7px;
508
- min-width:10px;
509
- text-align:right;
510
- margin-top:50%;
511
- ">
512
- 0/0
513
- </span>
632
+ <div class="launcher-right">
633
+ <span id="progressFraction" class="launcher-fraction">0/0</span>
514
634
  </div>
515
635
  </div>
516
636
  `;
517
- const isRight = cssConfig.launcherPosition === "right";
637
+ function injectLauncherCSS() {
638
+ if (document.getElementById("rivia-launcher-css")) return;
639
+ const style2 = document.createElement("style");
640
+ style2.id = "rivia-launcher-css";
641
+ style2.textContent = `
642
+ /* Root */ .checklist-root { max-width: 500px; margin: auto; position: relative; font-family: var(--font-family); font-size: var(--font-size); color: var(--text-color); } /* Close button */ .checklist-close { position: absolute; top: 8px; right: 12px; background: transparent; border: none; font-size: 28px; cursor: pointer; color: var(--text-color); } /* Header */ .checklist-header { background: var(--header-bg); padding: 16px; border-radius: 8px 8px 0 0; } .checklist-subtitle { margin-top: 8px; color: var(--subtitle-color); } /* Progress */ .checklist-progress { display: flex; align-items: center; justify-content: space-between; } .progress-fraction { font-size: 13px; } /* Body */ .checklist-body { padding: 16px; background: var(--lower-bg); max-height: 340px; overflow: auto; border-radius: 0 0 8px 8px; } /* Steps */ .onboard-step { position: relative; display: flex; align-items: flex-start; cursor: pointer; padding: 8px; border-radius: 6px; background: var(--step-bg); margin-bottom: 16px; } .start-select { position: absolute; top: 0; left: -18px; width: 10px; height: 120%; background: rgba(247,143,7,0.9); border-radius: 4px 0 0 4px; display: none; } .onboard-circle { width: 16px; height: 16px; min-width: 16px; min-height: 16px; border-radius: 50%; border: 2px solid var(--checkbox-color, #f78f07); /* hardcoded for test */ background: transparent; margin-right: 10px; box-sizing: border-box; display: block; } .onboard-title { color: var(--heading-color); } .onboard-desc { color: var(--body-color); } .onboard-divider { border: none; border-top: 1px solid #9d9d9d; } .rivia-launcher { position: fixed; display: block; z-index: 9999; cursor: pointer; border: none; box-shadow: 0 2px 8px rgba(19, 20, 19, 0.2); background: var(--launcher-bg); color: var(--launcher-text); font-weight: bold; } .rivia-launcher .launcher-root { display: flex; align-items: center; width: 100%; height: 100%; } .rivia-launcher .launcher-left { flex: 1; display: flex; flex-direction: column; } .rivia-launcher .launcher-title { position: relative; margin: 0; line-height: 1; text-align: center; padding-left: 28px; } .rivia-launcher .launcher-icon { position: absolute; left: 10px; transform: translateY(50%); }
643
+ .rivia-launcher .launcher-text {font-size:var(--font-size); display: block; width: 100%; padding-left: 5%; text-align: center; pointer-events: none; }
644
+ .rivia-launcher .launcher-progress-wrap { margin-top: 4px; padding-left: 32px; } /* Text adjustment when progress bar is hidden */ .rivia-launcher.no-progress .launcher-text { transform: translateY(50%);font-size:var(--font-size); } .rivia-launcher .launcher-progress { display:flex; gap:4px; width:100%; padding:5px; height:3px; box-sizing:border-box; } .rivia-launcher .launcher-right { flex-shrink: 0; padding-right: 8px; } .rivia-launcher .launcher-fraction { font-size: 13px; white-space: nowrap; } /* Customer CSS */ .rivia-launcher { border-radius: 20px; } .rivia-launcher .launcher-progress { height: 6px; }
645
+ `;
646
+ document.head.appendChild(style2);
647
+ }
648
+ function applyChecklistTheme(root, cssConfig2) {
649
+ root.style.setProperty("--font-family", cssConfig2.fontFamily);
650
+ root.style.setProperty("--font-size", cssConfig2.fontSize);
651
+ root.style.setProperty("--text-color", cssConfig2.textColor);
652
+ root.style.setProperty("--subtitle-color", cssConfig2.subtitleColor);
653
+ root.style.setProperty("--header-bg", cssConfig2.backgroundColor);
654
+ root.style.setProperty("--lower-bg", cssConfig2.lowerBackgroundColor);
655
+ root.style.setProperty("--step-bg", cssConfig2.lowerBackgroundColor);
656
+ root.style.setProperty("--checkbox-color", cssConfig2.lowerCheckboxColor);
657
+ root.style.setProperty("--heading-color", cssConfig2.lowerHeadingColor);
658
+ root.style.setProperty("--body-color", cssConfig2.lowerBodyColor);
659
+ }
660
+ injectChecklistBaseCSS();
518
661
  Object.assign(showBtn.style, {
519
- position: "fixed",
520
662
  bottom: cssConfig.launcherSpacingBottom || "20px",
521
- // Horizontal positioning
522
663
  left: isRight ? "auto" : cssConfig.launcherSpacingLeft || "20px",
523
664
  right: isRight ? cssConfig.launcherSpacingRight || "20px" : "auto",
524
665
  width: cssConfig.launcherWidth ? `${cssConfig.launcherWidth}px` : "150px",
525
666
  height: cssConfig.launcherHeight ? `${cssConfig.launcherHeight}px` : "78px",
526
- fontSize: cssConfig.fontSize,
527
- fontWeight: "bold",
528
- backgroundColor: cssConfig.launcherBackgroundColor,
529
- color: cssConfig.launcherTextColor,
530
- border: "none",
531
- borderRadius: `${cssConfig.launcherBorderRadius}px` || "6px",
532
- cursor: "pointer",
533
- zIndex: 9999,
534
- boxShadow: "0 2px 8px rgba(0, 0, 0, 0.2)"
667
+ borderRadius: `${cssConfig.launcherBorderRadius || 6}px`
668
+ /* CSS variables */
535
669
  });
670
+ showBtn.style.setProperty("--launcher-bg", cssConfig.launcherBackgroundColor || "#f78f07");
671
+ showBtn.style.setProperty("--launcher-text", cssConfig.launcherTextColor || "#ffffff");
672
+ showBtn.style.setProperty("--font-size", cssConfig.fontSize || "14px");
673
+ applyChecklistTheme(label, cssConfig);
674
+ injectChecklistBaseCSS();
536
675
  document.body.appendChild(showBtn);
676
+ console.log("after applyChecklistTheme");
677
+ document.body.appendChild(label);
537
678
  if (!cssConfig.launcherProgressBar) {
538
- document.getElementById("progressContainerBtn").style.display = "none";
539
- document.getElementById("progressFraction").style.display = "none";
679
+ const progressContainerBtn = document.getElementById("progressContainerBtn");
680
+ if (progressContainerBtn) {
681
+ progressContainerBtn.style.display = "none";
682
+ }
683
+ const progressFraction = document.getElementById("progressFraction");
684
+ if (progressFraction) {
685
+ progressFraction.style.display = "none";
686
+ }
540
687
  }
541
- document.body.appendChild(label);
542
688
  createS(items.length);
543
689
  const closeBtn = document.createElement("button");
544
690
  closeBtn.id = "tooltip-close-btn";
@@ -1186,7 +1332,7 @@ async function Checklist(checklist_id, user_var) {
1186
1332
  try {
1187
1333
  const cachedData = sessionStorage.getItem(`checklist_${checklist_id}`);
1188
1334
  if (cachedData) {
1189
- const { checklist: checklist2, cssConfig: cssConfig2, targetingData: targetingData2 } = JSON.parse(cachedData);
1335
+ const { checklist: checklist2, cssConfig: cssConfig2, targetingData: targetingData2, customCSS: customCSS2 } = JSON.parse(cachedData);
1190
1336
  Onboarding(
1191
1337
  checklist2.title || "Untitled Checklist",
1192
1338
  checklist2.subtitle || "Describe the purpose of this checklist...",
@@ -1194,6 +1340,186 @@ async function Checklist(checklist_id, user_var) {
1194
1340
  checklist2.items || [],
1195
1341
  cssConfig2 || {},
1196
1342
  targetingData2 || {},
1343
+ customCSS2 || `/* Root */
1344
+ .checklist-root {
1345
+ max-width: 500px;
1346
+ margin: auto;
1347
+ position: relative;
1348
+ font-family: var(--font-family);
1349
+ font-size: var(--font-size);
1350
+ color: var(--text-color);
1351
+ }
1352
+
1353
+ /* Close button */
1354
+ .checklist-close {
1355
+ position: absolute;
1356
+ top: 8px;
1357
+ right: 12px;
1358
+ background: transparent;
1359
+ border: none;
1360
+ font-size: 28px;
1361
+ cursor: pointer;
1362
+ color: var(--text-color);
1363
+ }
1364
+
1365
+ /* Header */
1366
+ .checklist-header {
1367
+ background: var(--header-bg);
1368
+ padding: 16px;
1369
+ border-radius: 8px 8px 0 0;
1370
+ }
1371
+
1372
+ .checklist-subtitle {
1373
+ margin-top: 8px;
1374
+ color: var(--subtitle-color);
1375
+ }
1376
+
1377
+ /* Progress */
1378
+ .checklist-progress {
1379
+ display: flex;
1380
+ align-items: center;
1381
+ justify-content: space-between;
1382
+ }
1383
+
1384
+ .progress-fraction {
1385
+ font-size: 13px;
1386
+ }
1387
+
1388
+ /* Body */
1389
+ .checklist-body {
1390
+ padding: 16px;
1391
+ background: var(--lower-bg);
1392
+ max-height: 340px;
1393
+ overflow: auto;
1394
+ border-radius: 0 0 8px 8px;
1395
+ }
1396
+
1397
+ /* Steps */
1398
+ .onboard-step {
1399
+ position: relative;
1400
+ display: flex;
1401
+ align-items: flex-start;
1402
+ cursor: pointer;
1403
+ padding: 8px;
1404
+ border-radius: 6px;
1405
+ background: var(--step-bg);
1406
+ margin-bottom: 16px;
1407
+ }
1408
+
1409
+ .start-select {
1410
+ position: absolute;
1411
+ top: 0;
1412
+ left: -18px;
1413
+ width: 10px;
1414
+ height: 120%;
1415
+ background: rgba(247,143,7,0.9);
1416
+ border-radius: 4px 0 0 4px;
1417
+ display: none;
1418
+ }
1419
+
1420
+ .onboard-circle {
1421
+ width: 16px;
1422
+ height: 16px;
1423
+ min-width: 16px;
1424
+ min-height: 16px;
1425
+ border-radius: 50%;
1426
+ border: 2px solid var(--checkbox-color, #f78f07);
1427
+ background: transparent;
1428
+ margin-right: 10px;
1429
+ box-sizing: border-box;
1430
+ display: block;
1431
+ }
1432
+
1433
+ .onboard-title {
1434
+ color: var(--heading-color);
1435
+ }
1436
+
1437
+ .onboard-desc {
1438
+ color: var(--body-color);
1439
+ }
1440
+
1441
+ .onboard-divider {
1442
+ border: none;
1443
+ border-top: 1px solid #9d9d9d;
1444
+ }
1445
+
1446
+ .rivia-launcher {
1447
+ position: fixed;
1448
+ display: block;
1449
+ z-index: 9999;
1450
+ cursor: pointer;
1451
+ border: none;
1452
+ box-shadow: 0 2px 8px rgba(19, 20, 19, 0.2);
1453
+ background: var(--launcher-bg);
1454
+ color: var(--launcher-text);
1455
+ font-weight: bold;
1456
+ border-radius: 20px;
1457
+ }
1458
+
1459
+ .rivia-launcher .launcher-root {
1460
+ display: flex;
1461
+ align-items: center;
1462
+ width: 100%;
1463
+ height: 100%;
1464
+ }
1465
+
1466
+ .rivia-launcher .launcher-left {
1467
+ flex: 1;
1468
+ display: flex;
1469
+ flex-direction: column;
1470
+ }
1471
+
1472
+ .rivia-launcher .launcher-title {
1473
+ transform: translateY(-20%);
1474
+ position: relative;
1475
+ margin: 0;
1476
+ line-height: 1;
1477
+ text-align: center;
1478
+ padding-left: 28px;
1479
+ }
1480
+
1481
+ .rivia-launcher .launcher-icon {
1482
+ position: absolute;
1483
+ left: 10px;
1484
+
1485
+ }
1486
+
1487
+ .rivia-launcher .launcher-text { font-size:var(--font-size);
1488
+ display: block;
1489
+ width: 100%;
1490
+ padding-left: 5%;
1491
+ text-align: center;
1492
+ pointer-events: none;
1493
+ }
1494
+
1495
+ .rivia-launcher .launcher-progress-wrap {
1496
+ margin-top: 4px;
1497
+ padding-left: 32px;
1498
+ }
1499
+
1500
+ /* Text adjustment when progress bar is hidden */
1501
+ .rivia-launcher.no-progress .launcher-text {
1502
+ transform: translateY(50%);
1503
+ }
1504
+
1505
+ .rivia-launcher .launcher-progress {
1506
+ display: flex;
1507
+ gap: 4px;
1508
+ width: 100%;
1509
+ padding: 5px;
1510
+ height: 6px;
1511
+ box-sizing: border-box;
1512
+ }
1513
+
1514
+ .rivia-launcher .launcher-right {
1515
+ flex-shrink: 0;
1516
+ padding-right: 8px;
1517
+ }
1518
+
1519
+ .rivia-launcher .launcher-fraction {
1520
+ font-size: 13px;
1521
+ white-space: nowrap;
1522
+ }`,
1197
1523
  user_var,
1198
1524
  checklist_id
1199
1525
  );
@@ -1221,7 +1547,187 @@ async function Checklist(checklist_id, user_var) {
1221
1547
  const completion = checklist.completion || 0;
1222
1548
  const cssConfig = checklist.branding_data || {};
1223
1549
  const targetingData = checklist.targeting_data || {};
1224
- const fullData = { checklist, cssConfig, targetingData };
1550
+ const customCSS = checklist.customCSS || `/* Root */
1551
+ .checklist-root {
1552
+ max-width: 500px;
1553
+ margin: auto;
1554
+ position: relative;
1555
+ font-family: var(--font-family);
1556
+ font-size: var(--font-size);
1557
+ color: var(--text-color);
1558
+ }
1559
+
1560
+ /* Close button */
1561
+ .checklist-close {
1562
+ position: absolute;
1563
+ top: 8px;
1564
+ right: 12px;
1565
+ background: transparent;
1566
+ border: none;
1567
+ font-size: 28px;
1568
+ cursor: pointer;
1569
+ color: var(--text-color);
1570
+ }
1571
+
1572
+ /* Header */
1573
+ .checklist-header {
1574
+ background: var(--header-bg);
1575
+ padding: 16px;
1576
+ border-radius: 8px 8px 0 0;
1577
+ }
1578
+
1579
+ .checklist-subtitle {
1580
+ margin-top: 8px;
1581
+ color: var(--subtitle-color);
1582
+ }
1583
+
1584
+ /* Progress */
1585
+ .checklist-progress {
1586
+ display: flex;
1587
+ align-items: center;
1588
+ justify-content: space-between;
1589
+ }
1590
+
1591
+ .progress-fraction {
1592
+ font-size: 13px;
1593
+ }
1594
+
1595
+ /* Body */
1596
+ .checklist-body {
1597
+ padding: 16px;
1598
+ background: var(--lower-bg);
1599
+ max-height: 340px;
1600
+ overflow: auto;
1601
+ border-radius: 0 0 8px 8px;
1602
+ }
1603
+
1604
+ /* Steps */
1605
+ .onboard-step {
1606
+ position: relative;
1607
+ display: flex;
1608
+ align-items: flex-start;
1609
+ cursor: pointer;
1610
+ padding: 8px;
1611
+ border-radius: 6px;
1612
+ background: var(--step-bg);
1613
+ margin-bottom: 16px;
1614
+ }
1615
+
1616
+ .start-select {
1617
+ position: absolute;
1618
+ top: 0;
1619
+ left: -18px;
1620
+ width: 10px;
1621
+ height: 120%;
1622
+ background: rgba(247,143,7,0.9);
1623
+ border-radius: 4px 0 0 4px;
1624
+ display: none;
1625
+ }
1626
+
1627
+ .onboard-circle {
1628
+ width: 16px;
1629
+ height: 16px;
1630
+ min-width: 16px;
1631
+ min-height: 16px;
1632
+ border-radius: 50%;
1633
+ border: 2px solid var(--checkbox-color, #f78f07);
1634
+ background: transparent;
1635
+ margin-right: 10px;
1636
+ box-sizing: border-box;
1637
+ display: block;
1638
+ }
1639
+
1640
+ .onboard-title {
1641
+ color: var(--heading-color);
1642
+ }
1643
+
1644
+ .onboard-desc {
1645
+ color: var(--body-color);
1646
+ }
1647
+
1648
+ .onboard-divider {
1649
+ border: none;
1650
+ border-top: 1px solid #9d9d9d;
1651
+ }
1652
+
1653
+ .rivia-launcher {
1654
+ position: fixed;
1655
+ display: block;
1656
+ z-index: 9999;
1657
+ cursor: pointer;
1658
+ border: none;
1659
+ box-shadow: 0 2px 8px rgba(19, 20, 19, 0.2);
1660
+ background: var(--launcher-bg);
1661
+ color: var(--launcher-text);
1662
+ font-weight: bold;
1663
+ border-radius: 20px;
1664
+ }
1665
+
1666
+ .rivia-launcher .launcher-root {
1667
+ display: flex;
1668
+ align-items: center;
1669
+ width: 100%;
1670
+ height: 100%;
1671
+ }
1672
+
1673
+ .rivia-launcher .launcher-left {
1674
+ flex: 1;
1675
+ display: flex;
1676
+ flex-direction: column;
1677
+ }
1678
+
1679
+ .rivia-launcher .launcher-title {
1680
+ transform: translateY(-20%);
1681
+ position: relative;
1682
+ margin: 0;
1683
+ line-height: 1;
1684
+ text-align: center;
1685
+ padding-left: 28px;
1686
+ }
1687
+
1688
+ .rivia-launcher .launcher-icon {
1689
+ position: absolute;
1690
+ left: 10px;
1691
+
1692
+ }
1693
+
1694
+ .rivia-launcher .launcher-text { font-size:var(--font-size);
1695
+ display: block;
1696
+ width: 100%;
1697
+ padding-left: 5%;
1698
+ text-align: center;
1699
+ pointer-events: none;
1700
+ }
1701
+
1702
+ .rivia-launcher .launcher-progress-wrap {
1703
+ margin-top: 4px;
1704
+ padding-left: 32px;
1705
+ }
1706
+
1707
+ /* Text adjustment when progress bar is hidden */
1708
+ .rivia-launcher.no-progress .launcher-text {
1709
+ transform: translateY(50%);
1710
+ }
1711
+
1712
+ .rivia-launcher .launcher-progress {
1713
+ display: flex;
1714
+ gap: 4px;
1715
+ width: 100%;
1716
+ padding: 5px;
1717
+ height: 6px;
1718
+ box-sizing: border-box;
1719
+ }
1720
+
1721
+ .rivia-launcher .launcher-right {
1722
+ flex-shrink: 0;
1723
+ padding-right: 8px;
1724
+ }
1725
+
1726
+ .rivia-launcher .launcher-fraction {
1727
+ font-size: 13px;
1728
+ white-space: nowrap;
1729
+ }`;
1730
+ const fullData = { checklist, cssConfig, targetingData, customCSS };
1225
1731
  sessionStorage.setItem(
1226
1732
  `checklist_${checklist_id}`,
1227
1733
  JSON.stringify(fullData)
@@ -1233,6 +1739,7 @@ async function Checklist(checklist_id, user_var) {
1233
1739
  items,
1234
1740
  cssConfig,
1235
1741
  targetingData,
1742
+ customCSS,
1236
1743
  user_var,
1237
1744
  checklist_id
1238
1745
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rivia",
3
- "version": "0.0.34",
3
+ "version": "0.0.35",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",