rails_onboarding 0.8.8 → 0.8.9

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: 408fd1e294065de10f66f097028bca6ea0ef929c2da585fb5fe20034a14e0202
4
- data.tar.gz: 2e015226988b1bda4bf5594d43c00341f4a9fb2c21c020b0607446be87dfe671
3
+ metadata.gz: 5de350daba589470bba3cfa3afe9daa037307873d47a888f81899b2e542172fa
4
+ data.tar.gz: 6871219f6639948ec9e66747c2e89be3b58d2260d6ef8bc2750a84900db14b1d
5
5
  SHA512:
6
- metadata.gz: 6f924adbe61c18fc3b8070653655b04d74bd01a97562ed5eaa274d43276c07a331a11ef233ceab5484f545b20779485cbe55417921516bc9c2cd0557da694884
7
- data.tar.gz: 678c83c71d204f027f92d65555af8cff1b3aecd53992cda79e5d234f5deffaf3a465e4b786295bc5ca2319b97a74946750e3a98083a45b8f1ad5ea4a37f3d4c1
6
+ metadata.gz: 2b6e4ccc57e00c7d41e4b21604be312330888ac2cc96e6b8ef0bc39206c529416ddc35f5d4bdc998632a6488fca0ce2a1c53e900c50115a17b08c17c2f9193f3
7
+ data.tar.gz: a4714eaed7cca529878cc9cc99ed06e0e48fa117a1cfa7f327eed5e9de97abf98cf5c35cc4ef7b51e2c8449cca5e78bf64953f9d2a8b2114487b60a9a0dc27d5
@@ -190,6 +190,7 @@ export default class extends Controller {
190
190
  const targetElement = step.selector ? document.querySelector(step.selector) : null
191
191
 
192
192
  this.currentTargetElement = targetElement
193
+ this.applyScrim(step, targetElement)
193
194
 
194
195
  if (targetElement) {
195
196
  this.scrollToElement(targetElement, step)
@@ -272,7 +273,7 @@ export default class extends Controller {
272
273
  left: 0;
273
274
  width: 100%;
274
275
  height: 100%;
275
- background: rgba(0, 0, 0, ${this.overlayOpacityValue});
276
+ background: transparent;
276
277
  z-index: 9998;
277
278
  opacity: 0;
278
279
  transition: opacity 0.3s ease;
@@ -300,6 +301,7 @@ export default class extends Controller {
300
301
  const overlay = this.overlay
301
302
  if (!overlay) return
302
303
 
304
+ document.documentElement.style.removeProperty('--onboarding-tour-scrim')
303
305
  this.overlay = null
304
306
  overlay.style.opacity = '0'
305
307
 
@@ -339,7 +341,6 @@ export default class extends Controller {
339
341
  left: ${rect.left - padding}px;
340
342
  width: ${rect.width + (padding * 2)}px;
341
343
  height: ${rect.height + (padding * 2)}px;
342
- box-shadow: 0 0 0 9999px rgba(0, 0, 0, ${this.overlayOpacityValue});
343
344
  border-radius: 8px;
344
345
  `
345
346
  break
@@ -384,6 +385,30 @@ export default class extends Controller {
384
385
  element.style.zIndex = '10000'
385
386
  }
386
387
 
388
+ /**
389
+ * Decide which layer paints the scrim for this step, and at what strength.
390
+ *
391
+ * A 'spotlight' highlight is already a full-viewport scrim - its box-shadow has a
392
+ * 9999px spread and covers everything but the cutout - so painting the overlay on
393
+ * top of it darkens every pixel twice. At the default 0.7 that composites to ~0.92,
394
+ * which buries the surrounding page and leaves someone unfamiliar with the layout
395
+ * with no idea what the highlight is being singled out *from*. Every other style
396
+ * (border, glow, none) draws no scrim of its own, and nor does a step with no target
397
+ * element, so those still need the overlay.
398
+ */
399
+ applyScrim(step, targetElement) {
400
+ document.documentElement.style.setProperty(
401
+ '--onboarding-tour-scrim', this.overlayOpacityValue
402
+ )
403
+
404
+ if (!this.overlay) return
405
+
406
+ const spotlit = Boolean(targetElement) && step.highlightStyle === 'spotlight'
407
+ this.overlay.style.background = spotlit
408
+ ? 'transparent'
409
+ : `rgba(0, 0, 0, ${this.overlayOpacityValue})`
410
+ }
411
+
387
412
  /**
388
413
  * Remove highlight/spotlight
389
414
  */
@@ -22,19 +22,15 @@
22
22
  border-radius: 8px;
23
23
  }
24
24
 
25
- /* Spotlight style - Creates cutout effect */
25
+ /* Spotlight style - Creates cutout effect.
26
+ The 9999px spread makes this box-shadow a full-viewport scrim in its own right, so
27
+ tour_controller stops painting .tour-overlay whenever a spotlight is drawn - the two
28
+ together composited to ~0.92 and buried the surrounding page.
29
+ The alpha comes from --onboarding-tour-scrim, which the controller sets on :root from
30
+ its overlayOpacity value. It is deliberately not animated: an animation on this
31
+ property overrides the inline style, which is what made overlayOpacity a dead knob. */
26
32
  .tour-spotlight-spotlight {
27
- box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.7);
28
- animation: onboarding-spotlightPulse 2s ease-in-out infinite;
29
- }
30
-
31
- @keyframes onboarding-spotlightPulse {
32
- 0%, 100% {
33
- box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.7);
34
- }
35
- 50% {
36
- box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.75);
37
- }
33
+ box-shadow: 0 0 0 9999px rgba(0, 0, 0, var(--onboarding-tour-scrim, 0.7));
38
34
  }
39
35
 
40
36
  /* Border highlight style */
@@ -327,6 +323,10 @@
327
323
  background: rgba(0, 0, 0, 0.85);
328
324
  }
329
325
 
326
+ .tour-spotlight-spotlight {
327
+ --onboarding-tour-scrim: 0.85;
328
+ }
329
+
330
330
  .tour-spotlight-border {
331
331
  border-width: 4px;
332
332
  }
@@ -351,10 +351,6 @@
351
351
  animation: none;
352
352
  }
353
353
 
354
- .tour-spotlight-spotlight {
355
- animation: none;
356
- }
357
-
358
354
  .tour-spotlight-border {
359
355
  animation: none;
360
356
  }
@@ -1,3 +1,3 @@
1
1
  module RailsOnboarding
2
- VERSION = "0.8.8"
2
+ VERSION = "0.8.9"
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.8
4
+ version: 0.8.9
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.8
285
+ source_code_uri: https://github.com/bunnahabhain/rails_onboarding/tree/v0.8.9
286
286
  changelog_uri: https://github.com/bunnahabhain/rails_onboarding/blob/master/docs/CHANGELOG.md
287
287
  rdoc_options: []
288
288
  require_paths: