rails_onboarding 0.8.9 → 0.8.10

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5de350daba589470bba3cfa3afe9daa037307873d47a888f81899b2e542172fa
4
- data.tar.gz: 6871219f6639948ec9e66747c2e89be3b58d2260d6ef8bc2750a84900db14b1d
3
+ metadata.gz: c05ac141e36d0ce4babc403026980c036569d9ae47a6dfe7fd945b9023bdce8b
4
+ data.tar.gz: a4a1482feee59b542485b5368e9cadbbe99dc16d3bcb9da6da399b7ca22c02c6
5
5
  SHA512:
6
- metadata.gz: 2b6e4ccc57e00c7d41e4b21604be312330888ac2cc96e6b8ef0bc39206c529416ddc35f5d4bdc998632a6488fca0ce2a1c53e900c50115a17b08c17c2f9193f3
7
- data.tar.gz: a4714eaed7cca529878cc9cc99ed06e0e48fa117a1cfa7f327eed5e9de97abf98cf5c35cc4ef7b51e2c8449cca5e78bf64953f9d2a8b2114487b60a9a0dc27d5
6
+ metadata.gz: abcfa7de7380a5a5591fbcad733a093c0eb11dfacf89e82fb20d25d7570c67e2f4d26040a7c871d1990d9de5283bfe45b42584241676a55173078f29b5ff8393
7
+ data.tar.gz: 95ed36308b6f64e56bb4b2cac753efec1f6359dde989b8ccd516f57f2a0e9106c4621e2e4ca0e59ec72b9eb0f6dfdc092da1dcd3a5e3b803dbc45a6f40821809
@@ -28,6 +28,12 @@ export default class extends Controller {
28
28
  scrollBehavior: { type: String, default: "smooth" }, // smooth, auto, none
29
29
  scrollOffset: { type: Number, default: 80 }, // px offset from top when scrolling
30
30
  persistProgress: { type: Boolean, default: true },
31
+ // Whether the highlighted element stays clickable. It is lifted above the
32
+ // overlay so that a tour can say "click here to continue", and that is the
33
+ // default. An informational tour wants the opposite: a link inside the
34
+ // spotlight is a trap, because following it navigates away and the tour is
35
+ // either lost or restarted from step one. Overridable per step.
36
+ allowInteraction: { type: Boolean, default: true },
31
37
  tourId: String
32
38
  }
33
39
 
@@ -80,6 +86,7 @@ export default class extends Controller {
80
86
  beforeHide: step.beforeHide,
81
87
  onComplete: step.onComplete,
82
88
  width: step.width || 400, // Popup width in px
89
+ allowInteraction: step.allowInteraction ?? this.allowInteractionValue,
83
90
  ...step
84
91
  }))
85
92
  }
@@ -259,13 +266,25 @@ export default class extends Controller {
259
266
  }
260
267
  }
261
268
 
269
+ /**
270
+ * Elements the controller injects into document.body. Turbo caches the whole body
271
+ * when you navigate away, so without this a Back lands you on a snapshot with a
272
+ * frozen overlay and popup baked in - which then sit underneath the live tour the
273
+ * launcher starts, as duplicated and inert DOM. The attribute is ignored by hosts
274
+ * that do not use Turbo.
275
+ */
276
+ excludeFromSnapshot(element) {
277
+ element.setAttribute('data-turbo-cache', 'false')
278
+ return element
279
+ }
280
+
262
281
  /**
263
282
  * Create modal overlay
264
283
  */
265
284
  createOverlay() {
266
285
  if (this.overlay) return
267
286
 
268
- this.overlay = document.createElement('div')
287
+ this.overlay = this.excludeFromSnapshot(document.createElement('div'))
269
288
  this.overlay.className = 'tour-overlay'
270
289
  this.overlay.style.cssText = `
271
290
  position: fixed;
@@ -322,7 +341,7 @@ export default class extends Controller {
322
341
 
323
342
  if (style === 'none') return
324
343
 
325
- this.spotlight = document.createElement('div')
344
+ this.spotlight = this.excludeFromSnapshot(document.createElement('div'))
326
345
  this.spotlight.className = `tour-spotlight tour-spotlight-${style}`
327
346
 
328
347
  const baseStyles = `
@@ -381,8 +400,16 @@ export default class extends Controller {
381
400
  this.highlightedElement = element
382
401
  this.previousElementPosition = element.style.position
383
402
  this.previousElementZIndex = element.style.zIndex
403
+ this.previousElementPointerEvents = element.style.pointerEvents
384
404
  element.style.position = 'relative'
385
405
  element.style.zIndex = '10000'
406
+
407
+ // With interaction off, clicks fall through the highlighted element to the
408
+ // overlay beneath, which swallows them like the rest of the page. The element
409
+ // is still lifted above the overlay so it stays fully lit.
410
+ if (step.allowInteraction === false) {
411
+ element.style.pointerEvents = 'none'
412
+ }
386
413
  }
387
414
 
388
415
  /**
@@ -426,6 +453,7 @@ export default class extends Controller {
426
453
  if (this.highlightedElement) {
427
454
  this.highlightedElement.style.position = this.previousElementPosition || ''
428
455
  this.highlightedElement.style.zIndex = this.previousElementZIndex || ''
456
+ this.highlightedElement.style.pointerEvents = this.previousElementPointerEvents || ''
429
457
  this.highlightedElement = null
430
458
  }
431
459
  }
@@ -436,7 +464,7 @@ export default class extends Controller {
436
464
  createPopup(step, targetElement) {
437
465
  this.removePopup()
438
466
 
439
- this.popup = document.createElement('div')
467
+ this.popup = this.excludeFromSnapshot(document.createElement('div'))
440
468
  this.popup.className = 'tour-popup'
441
469
 
442
470
  // Build popup HTML
@@ -1,3 +1,3 @@
1
1
  module RailsOnboarding
2
- VERSION = "0.8.9"
2
+ VERSION = "0.8.10"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_onboarding
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.9
4
+ version: 0.8.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Lewis
@@ -282,7 +282,7 @@ licenses:
282
282
  metadata:
283
283
  allowed_push_host: https://rubygems.org
284
284
  homepage_uri: https://github.com/bunnahabhain/rails_onboarding
285
- source_code_uri: https://github.com/bunnahabhain/rails_onboarding/tree/v0.8.9
285
+ source_code_uri: https://github.com/bunnahabhain/rails_onboarding/tree/v0.8.10
286
286
  changelog_uri: https://github.com/bunnahabhain/rails_onboarding/blob/master/docs/CHANGELOG.md
287
287
  rdoc_options: []
288
288
  require_paths: