Skip to content

Commit 580b0d6

Browse files
committed
v14.2.5
1 parent 177e0f1 commit 580b0d6

File tree

10 files changed

+105
-23
lines changed

10 files changed

+105
-23
lines changed

build/cjs/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/esm/index.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

demo/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@
161161

162162
<!-- Main content wireframe blocks -->
163163
<main class="main-placeholder" id="main1">
164+
<input placeholder="Name" type="text" id="input1" />
164165
<div class="wireframe-block"></div>
165166
<div class="wireframe-block"></div>
166167
<div class="wireframe-block"></div>
@@ -169,7 +170,7 @@
169170
<div class="wireframe-block"></div>
170171
</main>
171172

172-
<main class="main-placeholder-2" id="main2" style="display: none;">
173+
<main class="main-placeholder-2" id="main2" style="display: none">
173174
<div class="wireframe-block--title"></div>
174175
<div class="wireframe-block-2">
175176
<div class="wireframe-block--text" style="width: 80%"></div>

demo/main.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
11
const Gleap = window.Gleap;
22

3-
Gleap.setFrameUrl("http://0.0.0.0:3001");
4-
Gleap.setApiUrl("http://0.0.0.0:9000");
5-
Gleap.setWSApiUrl("ws://0.0.0.0:9000");
3+
// Gleap.setFrameUrl("http://0.0.0.0:3001");
4+
// Gleap.setApiUrl("http://0.0.0.0:9000");
5+
// Gleap.setWSApiUrl("ws://0.0.0.0:9000");
66

7-
Gleap.setLanguage("ar-DZ");
8-
9-
Gleap.initialize("VHKvTzWV8jKjms6mWWygiUDWlL8zs7an");
7+
Gleap.initialize("ng6GlnVz6BEUyxFu9nVCg1dlrfHz8tTK");
108

119
// const lastMonthDate = new Date();
1210
// lastMonthDate.setMonth(lastMonthDate.getMonth() - 1);
1311

14-
Gleap.identify("94383829393", {
15-
email: "luca@gleap.io",
16-
name: "Luca Blaser",
17-
})
18-
19-
Gleap.open();
2012
// Gleap.showSurvey("c01abef016b8efb03a9a", "survey_full");
2113

2214

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gleap",
3-
"version": "14.2.4",
3+
"version": "14.2.5",
44
"main": "build/cjs/index.js",
55
"module": "build/esm/index.mjs",
66
"exports": {

published/14.2.5/index.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

published/latest/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/GleapCopilotTours.js

Lines changed: 91 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { GleapTranslationManager } from "./Gleap";
12
import { loadIcon } from "./UI";
23

34
const localStorageKey = "gleap-tour-data";
@@ -6,6 +7,8 @@ const styleId = "copilot-tour-styles";
67
const copilotJoinedContainerId = "copilot-joined-container";
78
const copilotInfoBubbleId = "copilot-info-bubble";
89

10+
const arrowRightIcon = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M438.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L338.8 224 32 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l306.7 0L233.4 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l160-160z"/></svg>`;
11+
912
function estimateReadTime(text) {
1013
const wordsPerSecond = 3.6; // Average reading speed
1114
const wordCount = text.split(/\s+/).filter((word) => word.length > 0).length;
@@ -138,7 +141,8 @@ export default class GleapCopilotTours {
138141
) {
139142
// Wait for the element to be rendered.
140143
self.updatePointerPosition(
141-
document.querySelector(currentStep.selector)
144+
document.querySelector(currentStep.selector),
145+
currentStep
142146
);
143147
}
144148
}
@@ -186,7 +190,7 @@ export default class GleapCopilotTours {
186190
}
187191
}
188192

189-
updatePointerPosition(anchor) {
193+
updatePointerPosition(anchor, currentStep) {
190194
try {
191195
const container = document.getElementById(pointerContainerId);
192196
if (!container) {
@@ -221,6 +225,11 @@ export default class GleapCopilotTours {
221225
let anchorCenterY =
222226
anchorRect.top + anchorRect.height / 2 + window.scrollY;
223227

228+
if (currentStep?.mode === "INPUT") {
229+
anchorCenterX -= anchorRect.width / 2 - 10;
230+
anchorCenterY += anchorRect.height / 2 - 5;
231+
}
232+
224233
let containerWidthSpace = 350;
225234
if (containerWidthSpace > window.innerWidth - 40) {
226235
containerWidthSpace = window.innerWidth - 40;
@@ -286,8 +295,21 @@ export default class GleapCopilotTours {
286295
display: flex;
287296
align-items: flex-start;
288297
pointer-events: none;
289-
z-index: 9999;
290-
transition: all 0.5s ease;;
298+
z-index: 2147483610;
299+
transition: all 0.5s ease;
300+
}
301+
302+
.${pointerContainerId}-clickmode {
303+
cursor: pointer;
304+
pointer-events: all !important;
305+
}
306+
307+
.${pointerContainerId}-clickmode #${copilotInfoBubbleId}-content {
308+
display: flex !important;
309+
}
310+
311+
.${pointerContainerId}-clickmode svg {
312+
display: none !important;
291313
}
292314
293315
#${pointerContainerId} svg {
@@ -315,6 +337,13 @@ export default class GleapCopilotTours {
315337
align-items: flex-start;
316338
}
317339
340+
#${copilotInfoBubbleId}-content svg {
341+
width: 16px;
342+
height: 16px;
343+
display: inline-block !important;
344+
margin-left: 5px;
345+
}
346+
318347
#${copilotInfoBubbleId}-content {
319348
margin-top: 18px;
320349
margin-left: 5px;
@@ -605,6 +634,7 @@ export default class GleapCopilotTours {
605634
return;
606635
}
607636

637+
const self = this;
608638
const config = this.productTourData;
609639
const steps = config.steps;
610640

@@ -619,13 +649,69 @@ export default class GleapCopilotTours {
619649
const currentStep = steps[this.currentActiveIndex];
620650

621651
const handleStep = (element) => {
652+
document.getElementById(pointerContainerId).style.display = "flex";
653+
622654
// If we have a selector but the element was null, close the tour.
623655
if (currentStep.selector && currentStep.selector.length > 0 && !element) {
624656
this.completeTour(false);
625657
return;
626658
}
627659

628660
const gotToNextStep = () => {
661+
if (currentStep.mode === "INPUT" && element) {
662+
// Wait for text to be entered. Continue tour on enter. element is the input.
663+
function handleClick() {
664+
document
665+
.querySelector(`#${pointerContainerId}`)
666+
.classList.remove("copilot-pointer-container-clickmode");
667+
668+
// Remove the highlight from the input fields.
669+
element.classList.remove("gleap-input-highlight");
670+
671+
// Hide the info bubble.
672+
document.getElementById(pointerContainerId).style.display = "none";
673+
674+
self.currentActiveIndex++;
675+
self.storeUncompletedTour();
676+
self.renderNextStep();
677+
}
678+
679+
function handleInputEvent(e) {
680+
if (e.target.value.length === 0) return;
681+
682+
const cursor = document.getElementById(
683+
`${copilotInfoBubbleId}-content`
684+
);
685+
if (!cursor) return;
686+
687+
cursor.innerHTML = `${GleapTranslationManager.translateText(
688+
`next`
689+
)} ${arrowRightIcon}`;
690+
cursor.addEventListener("click", handleClick, { once: true });
691+
692+
// Add highlight to the input fields. red shadow glow.
693+
element.classList.add("gleap-input-highlight");
694+
695+
document
696+
.querySelector(`#${pointerContainerId}`)
697+
.classList.add("copilot-pointer-container-clickmode");
698+
699+
// Remove the input event listener after execution
700+
element.removeEventListener("input", handleInputEvent);
701+
}
702+
703+
element.addEventListener("input", handleInputEvent);
704+
705+
// Focus on the input.
706+
element.addEventListener("blur", () => {
707+
element.focus();
708+
});
709+
710+
element.focus();
711+
712+
return;
713+
}
714+
629715
this.currentActiveIndex++;
630716
this.storeUncompletedTour();
631717

@@ -648,7 +734,7 @@ export default class GleapCopilotTours {
648734
};
649735

650736
// Update pointer position, even if element is null.
651-
this.updatePointerPosition(element);
737+
this.updatePointerPosition(element, currentStep);
652738

653739
const message = currentStep?.message
654740
? htmlToPlainText(currentStep.message)

src/GleapProductTours.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ export default class GleapProductTours {
7070
GleapSession.getInstance()
7171
.validateProductTour(tourId)
7272
.then(() => {
73-
console.log("Product tour is live.");
7473
if (delay > 0) {
7574
return setTimeout(() => {
7675
self.start();

src/UI.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ export const injectStyledCSS = (
9494
line-height: 1;
9595
font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
9696
}
97+
.gleap-input-highlight {
98+
box-shadow: 0 0 0 3px ${primaryColor} !important;
99+
}
97100
.gleap-frame-container {
98101
right: ${buttonX}px;
99102
bottom: ${61 + buttonY}px;

0 commit comments

Comments
 (0)