rivia 0.0.33 → 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 +663 -154
  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;
@@ -329,10 +490,12 @@ async function fetchWithTimeout(topTitle = "Get Started", subtitle, completion =
329
490
  const confirmDiv = document.createElement("div");
330
491
  confirmDiv.innerHTML = `
331
492
  <div style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 10000; display: flex; align-items: flex-end; justify-content: flex-start;">
332
- <div style="background: white; padding: 20px; border-radius: 10px; text-align: center; margin: 20px;">
333
- <p>Are you sure you want to dismiss this checklist?</p>
334
- <button id="confirmYes" style="margin: 10px; padding: 10px 20px; background: green; color: white; border: none; border-radius: 5px; cursor: pointer;">\u2713</button>
335
- <button id="confirmNo" style="margin: 10px; padding: 10px 20px; background: red; color: white; border: none; border-radius: 5px; cursor: pointer;">\u2717</button>
493
+ <div style="background: white;width: 250px; border-radius: 10px; text-align: center; margin: 20px;">
494
+ <p style="padding: 15px;">Are you sure you want to dismiss this checklist?</p>
495
+ <hr style="border-top: 2px solid #f33f27ff; margin-left: 10px; margin-right: 10px;">
496
+ <button id="confirmNo" style="margin: 10px; padding: 4px 8px;color: #f33f27ff; border: none; cursor: pointer;">No</button>
497
+ <span style="border-left: 2px solid #f33f27ff;color:#eda600ff; height: 52px; margin: 0 10px; display: inline-block; vertical-align: top;"></span>
498
+ <button id="confirmYes" style="margin: 10px; padding: 4px 8px; color: #f33f27ff; border: none; cursor: pointer;">Yes</button>
336
499
  </div>
337
500
  </div>
338
501
  `;
@@ -354,39 +517,41 @@ async function fetchWithTimeout(topTitle = "Get Started", subtitle, completion =
354
517
  });
355
518
  function createSlabs(n) {
356
519
  const container = label.querySelector("#progressContainer");
520
+ if (!container) return;
357
521
  container.innerHTML = "";
358
522
  for (let i2 = 0; i2 < n; i2++) {
359
523
  const slab = document.createElement("div");
360
- slab.classList.add("slab");
524
+ slab.className = "slab";
361
525
  container.appendChild(slab);
362
526
  }
363
527
  }
364
528
  const style = document.createElement("style");
365
529
  style.textContent = `
366
- .slab {
367
- flex: 1;
530
+ .slab {
531
+ flex: 1 0 0%; /* \u{1F512} important */
532
+ min-width: 5px;
368
533
  height: 8px;
369
534
  background-color: #ccc;
370
535
  border-radius: 4px;
371
- transition: background-color 0.3s;
536
+ transition: background-color 0.3s ease;
372
537
  }
373
538
  .slab.active {
374
539
  background-color: #4caf50;
375
- }
376
- #progressContainerBtn .slab {
377
- height: 5px;
378
- }
379
- `;
540
+ }
541
+ #progressContainerBtn .slab {
542
+ height: 5px;
543
+ }
544
+ `;
380
545
  label.appendChild(style);
381
546
  function updateProgress(completed) {
382
547
  const slabs = label.querySelectorAll(".slab");
383
548
  slabs.forEach((slab, index) => {
384
- if (index < completed) {
385
- slab.classList.add("active");
386
- } else {
387
- slab.classList.remove("active");
388
- }
549
+ slab.classList.toggle("active", index < completed);
389
550
  });
551
+ const fraction = label.querySelector("#progressFraction");
552
+ if (fraction) {
553
+ fraction.textContent = `${completed}/${slabs.length}`;
554
+ }
390
555
  }
391
556
  createSlabs(items.length);
392
557
  if (storedVisited) updateProgress(storedVisited.length);
@@ -402,7 +567,7 @@ async function fetchWithTimeout(topTitle = "Get Started", subtitle, completion =
402
567
  fontSize: cssConfig.fontSize,
403
568
  fontFamily: cssConfig.fontFamily,
404
569
  boxShadow: "0 4px 12px rgba(0, 0, 0, 0.2)",
405
- width: "90%",
570
+ width: "400px",
406
571
  maxWidth: "400px",
407
572
  maxHeight: "500px",
408
573
  lineHeight: "1.5",
@@ -435,108 +600,91 @@ async function fetchWithTimeout(topTitle = "Get Started", subtitle, completion =
435
600
  });
436
601
  }
437
602
  showBtn.id = "show-tooltip-btn";
603
+ showBtn.className = "rivia-launcher";
438
604
  const translateStyle = cssConfig.launcherProgressBar ? 'style="transform: translateY(10px);"' : "";
439
- 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">
440
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"/>
441
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"/>
442
609
  <path d="M12 20L11 21M4 12L3 13" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
443
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"/>
444
611
  <path d="M17.94 6.05957L16.5 7.49957" stroke="white" stroke-width="1.5" stroke-linecap="round"/>
445
612
  </svg>` : "";
446
- const progressPaddingLeft = cssConfig.launcherShowIcon ? "28px" : "0px";
447
613
  const textTranslateStyle = !cssConfig.launcherProgressBar ? " translateY(50%);" : "";
614
+ if (!cssConfig.launcherProgressBar) {
615
+ showBtn.classList.add("no-progress");
616
+ }
448
617
  showBtn.innerHTML = `
449
- <div style="display:flex; align-items:center; gap:0px; width:100%;">
450
-
451
- <!-- LEFT COLUMN -->
452
- <div style="flex:1; display:flex; flex-direction:column; box-sizing:border-box; padding-left:${progressPaddingLeft};">
453
-
454
- <!-- TITLE ROW -->
455
- <h3 style="
456
- margin:0;
457
- position:relative;
458
- line-height:1;
459
- ">
460
- <!-- ICON: fixed original position -->
461
- <span style="
462
- position:absolute;
463
- left:-20px;
464
- transform:translateY(-50%);
465
- display:flex;
466
- align-items:center;
467
- ">
468
- ${iconHTML}
469
- </span>
470
-
471
- <!-- TEXT: centered over progress bar -->
472
- <span style="
473
- display:block;
474
- width:100%;
475
- padding-left:5%;
476
- text-align:center;
477
- margin-top:-10%;
478
- transform: ${textTranslateStyle};
479
- pointer-events:none;
480
- font-size: ${cssConfig.fontSize};
481
- ">
482
- ${cssConfig.launcher_text}
483
- </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>
484
624
  </h3>
485
625
 
486
- <!-- PROGRESS BAR -->
487
- <div style="width:100%; margin-top:-2px; padding-left:4%;">
488
- <div id="progressContainerBtn" style="
489
- display:flex;
490
- gap:4px;
491
- width:100%;
492
- padding:5px;
493
- height:3px;
494
- box-sizing:border-box;
495
- "></div>
626
+ <div class="launcher-progress-wrap">
627
+ <div id="progressContainerBtn" class="launcher-progress"></div>
496
628
  </div>
629
+
497
630
  </div>
498
631
 
499
- <!-- RIGHT COLUMN: fraction -->
500
- <div style="flex-shrink:0; display:flex; align-items:center;">
501
- <span id="progressFraction" style="
502
- font-size:13px;
503
- white-space:nowrap;
504
- color:${cssConfig.launcherTextColor};
505
- padding-right:7px;
506
- min-width:10px;
507
- text-align:right;
508
- margin-top:50%;
509
- ">
510
- 0/0
511
- </span>
632
+ <div class="launcher-right">
633
+ <span id="progressFraction" class="launcher-fraction">0/0</span>
512
634
  </div>
513
635
  </div>
514
636
  `;
515
- 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();
516
661
  Object.assign(showBtn.style, {
517
- position: "fixed",
518
662
  bottom: cssConfig.launcherSpacingBottom || "20px",
519
- // Horizontal positioning
520
663
  left: isRight ? "auto" : cssConfig.launcherSpacingLeft || "20px",
521
664
  right: isRight ? cssConfig.launcherSpacingRight || "20px" : "auto",
522
665
  width: cssConfig.launcherWidth ? `${cssConfig.launcherWidth}px` : "150px",
523
666
  height: cssConfig.launcherHeight ? `${cssConfig.launcherHeight}px` : "78px",
524
- fontSize: cssConfig.fontSize,
525
- fontWeight: "bold",
526
- backgroundColor: cssConfig.launcherBackgroundColor,
527
- color: cssConfig.launcherTextColor,
528
- border: "none",
529
- borderRadius: `${cssConfig.launcherBorderRadius}px` || "6px",
530
- cursor: "pointer",
531
- zIndex: 9999,
532
- boxShadow: "0 2px 8px rgba(0, 0, 0, 0.2)"
667
+ borderRadius: `${cssConfig.launcherBorderRadius || 6}px`
668
+ /* CSS variables */
533
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();
534
675
  document.body.appendChild(showBtn);
676
+ console.log("after applyChecklistTheme");
677
+ document.body.appendChild(label);
535
678
  if (!cssConfig.launcherProgressBar) {
536
- document.getElementById("progressContainerBtn").style.display = "none";
537
- 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
+ }
538
687
  }
539
- document.body.appendChild(label);
540
688
  createS(items.length);
541
689
  const closeBtn = document.createElement("button");
542
690
  closeBtn.id = "tooltip-close-btn";
@@ -1184,7 +1332,7 @@ async function Checklist(checklist_id, user_var) {
1184
1332
  try {
1185
1333
  const cachedData = sessionStorage.getItem(`checklist_${checklist_id}`);
1186
1334
  if (cachedData) {
1187
- const { checklist: checklist2, cssConfig: cssConfig2, targetingData: targetingData2 } = JSON.parse(cachedData);
1335
+ const { checklist: checklist2, cssConfig: cssConfig2, targetingData: targetingData2, customCSS: customCSS2 } = JSON.parse(cachedData);
1188
1336
  Onboarding(
1189
1337
  checklist2.title || "Untitled Checklist",
1190
1338
  checklist2.subtitle || "Describe the purpose of this checklist...",
@@ -1192,6 +1340,186 @@ async function Checklist(checklist_id, user_var) {
1192
1340
  checklist2.items || [],
1193
1341
  cssConfig2 || {},
1194
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
+ }`,
1195
1523
  user_var,
1196
1524
  checklist_id
1197
1525
  );
@@ -1219,7 +1547,187 @@ async function Checklist(checklist_id, user_var) {
1219
1547
  const completion = checklist.completion || 0;
1220
1548
  const cssConfig = checklist.branding_data || {};
1221
1549
  const targetingData = checklist.targeting_data || {};
1222
- 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 };
1223
1731
  sessionStorage.setItem(
1224
1732
  `checklist_${checklist_id}`,
1225
1733
  JSON.stringify(fullData)
@@ -1231,6 +1739,7 @@ async function Checklist(checklist_id, user_var) {
1231
1739
  items,
1232
1740
  cssConfig,
1233
1741
  targetingData,
1742
+ customCSS,
1234
1743
  user_var,
1235
1744
  checklist_id
1236
1745
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rivia",
3
- "version": "0.0.33",
3
+ "version": "0.0.35",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",