lato 3.11.0 → 3.11.3

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: 890f6071431f470805aa8c253844356565814fbdc2ceb6152135fba2c02e79aa
4
- data.tar.gz: 8eddac1dc91f0a5755ee40a115b45038c023393e7ffee6200e796968c79a1a7f
3
+ metadata.gz: a5f0eb7f689dbdeaf6ed25131cbc8a6a4a3bdd3c0f402426373a29a9124d0506
4
+ data.tar.gz: ae388fcd54a59d7ac1f0b7ca3d3a342ac7839aaee1807697159b5c5fa7c67094
5
5
  SHA512:
6
- metadata.gz: 04ece6a0739114376e060e78d5a05e967d76d5469363635d0f3912de92e1f1861ca7c6b862e666257b31a1beeec31d6387f03a6f9ebbe3ebffb366685929b6b4
7
- data.tar.gz: 113ea99f5ba6a087dafdf6594d348ecb283451010766254b2c207c1ff68841791171482866e2df7b8f4d49a4a68f79755076b5a6a0a54870a71492dc8e738b69
6
+ metadata.gz: 4c788d7f5b53aeb6f4bea7a4d5614f12697e5883ab99ca40b6752179b1f9dd9903334455153dcbe7f89473888a2a32908bfc1f8009f9043383d836367340d881
7
+ data.tar.gz: 4402d91bc41aa788e358f9aaea6592ae70630f6b9bbb375f15e51817fc3a01737d9d6b33c4c7679a1a30ae3c5e7f14c92792ee8e5eb058a0477be935d65ffb17
@@ -12,65 +12,127 @@ export default class extends Controller {
12
12
  this.status = localStorageStatus ? JSON.parse(localStorageStatus) : {}
13
13
  this.storeStatus()
14
14
 
15
- this.start()
15
+ this.connected = true
16
+ this.tooltip = null
17
+ this.run()
18
+
19
+ window.addEventListener('resize', this.onWindowResize.bind(this))
16
20
  }
17
21
 
18
- start(e = null) {
19
- if (e) e.preventDefault()
22
+ disconnect() {
23
+ this.storeStatus()
20
24
 
21
- const targets = this.itemTargets.map(item => ({ element: item, key: item.dataset.guideKey, content: item.dataset.guideContent, index: parseInt(item.dataset.guideIndex) })).map(item => {
22
- item.index = isNaN(item.index) ? 999 : item.index
23
- return item
24
- }).sort((a, b) => a.index - b.index)
25
+ if (this.tooltip) {
26
+ this.tooltip.hide()
27
+ this.tooltip.dispose()
28
+ this.tooltip = null
29
+ }
30
+
31
+ this.connected = false
25
32
 
26
- this.showGuide(targets)
33
+ window.removeEventListener('resize', this.onWindowResize.bind(this))
27
34
  }
28
35
 
29
- async showGuide(targets) {
30
- for (let i = 0; i < targets.length; i++) {
31
- const item = targets[i]
32
- if (this.status[item.key]) continue
36
+ itemTargetConnected(e) {
37
+ this.run()
38
+ }
33
39
 
34
- await this.showGuideItem(item, i === targets.length - 1)
40
+ itemTargetDisconnected(e) {
41
+ if (this.tooltip && this.tooltip.itemKey === e.target.dataset.guideKey) {
42
+ this.tooltip.hide()
43
+ this.tooltip.dispose()
44
+ this.tooltip = null
35
45
  }
36
46
  }
37
47
 
38
- async showGuideItem(item, isLast = false) {
48
+ /**
49
+ * Exposed functions
50
+ */
51
+
52
+ rerun(e = null) {
53
+ if (e) e.preventDefault()
54
+ this.resetStatus()
55
+ this.run()
56
+ }
57
+
58
+ run(e = null) {
59
+ if (e) e.preventDefault()
60
+ if (!this.connected) return
61
+
62
+ const items = this.getNotShowedItems()
63
+ if (items.length === 0) return
64
+
65
+ this.showItem(items[0])
66
+ }
67
+
68
+ /**
69
+ * Helpers
70
+ */
71
+
72
+ getNotShowedItems() {
73
+ const items = this.itemTargets.map(item => ({ element: item, key: item.dataset.guideKey, content: item.dataset.guideContent, index: parseInt(item.dataset.guideIndex) })).map(item => {
74
+ item.index = isNaN(item.index) ? 999 : item.index
75
+ return item
76
+ }).sort((a, b) => a.index - b.index).filter((item) => !this.status[item.key])
77
+
78
+ return items
79
+ }
80
+
81
+ showItem(item) {
82
+ if (!this.status) return
39
83
  if (this.status[item.key]) return
84
+ if (this.tooltip) return
40
85
 
41
- return new Promise((resolve) => {
42
- const tooltipCloseId = `guide-close-${Math.random().toString(36).substring(7)}`
43
- const tooltipTitle = `
44
- <div class="px-3 py-3">
45
- <p class="mb-1">${item.content}</p>
46
- <a id="${tooltipCloseId}" class="btn btn-light btn-sm mt-2">${isLast ? 'Close' : 'Next'}</a>
47
- </div>
48
- `
49
-
50
- const tooltip = new bootstrap.Tooltip(item.element, { title: tooltipTitle, trigger: 'manual', html: true })
51
- item.element.addEventListener('shown.bs.tooltip', () => {
52
- setTimeout(() => {
53
- document.getElementById(tooltipCloseId).addEventListener('click', () => {
54
- tooltip.hide()
55
- this.status[item.key] = true
56
- this.storeStatus()
57
- resolve()
58
- })
59
- }, 250)
60
- })
61
- tooltip.show()
86
+ // setup tooltip
87
+ const tooltipCloseId = `lato-guide-close-${Math.random().toString(36).substring(7)}`
88
+ const tooltipTitle = `
89
+ <div class="px-2 py-2 d-flex align-items-center justify-content-between">
90
+ <p class="me-2 mb-0 text-start">${item.content}</p>
91
+ <a id="${tooltipCloseId}" class="btn btn-light btn-sm">Next</a>
92
+ </div>
93
+ `
94
+ this.tooltip = new bootstrap.Tooltip(item.element, { title: tooltipTitle, trigger: 'manual', html: true, customClass: 'lato-guide-tooltip' })
95
+ this.tooltip.itemKey = item.key
96
+
97
+ // listen to tooltip close
98
+ item.element.addEventListener('shown.bs.tooltip', () => {
99
+ setTimeout(() => {
100
+ document.getElementById(tooltipCloseId).addEventListener('click', () => {
101
+ this.tooltip.hide()
102
+ this.tooltip.dispose()
103
+ this.tooltip = null
104
+ this.status[item.key] = true
105
+ this.storeStatus()
106
+ this.run()
107
+ })
108
+ }, 250)
62
109
  })
110
+ this.tooltip.show()
111
+
112
+ return true
63
113
  }
64
114
 
65
- storeStatus(e = null) {
66
- if (e) e.preventDefault()
115
+ storeStatus() {
67
116
  localStorage.setItem('lato_guide', JSON.stringify(this.status))
117
+
118
+ return true
68
119
  }
69
120
 
70
- resetStatus(e = null) {
71
- if (e) e.preventDefault()
121
+ resetStatus() {
72
122
  this.status = {}
73
123
  this.storeStatus()
74
- this.start()
124
+
125
+ return true
126
+ }
127
+
128
+ /**
129
+ * Events
130
+ */
131
+
132
+ onWindowResize(e) { // on window resize, repostion tooltip
133
+ if (this.tooltip) {
134
+ this.tooltip.hide()
135
+ this.tooltip.show()
136
+ }
75
137
  }
76
138
  }
@@ -17,6 +17,9 @@ $gray-700: #454f58 !default;
17
17
  $gray-800: #313a42 !default;
18
18
  $gray-900: #1f262c !default;
19
19
 
20
+ $tooltip-opacity: 1;
21
+ $tooltip-max-width: 300px;
22
+
20
23
  @import url("https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.2/font/bootstrap-icons.css");
21
24
  @import "bootstrap";
22
25
 
@@ -127,4 +130,8 @@ main, aside {
127
130
  100% {
128
131
  transform: rotate(360deg);
129
132
  }
133
+ }
134
+
135
+ .lato-guide-tooltip {
136
+
130
137
  }
data/lib/lato/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lato
2
- VERSION = "3.11.0"
2
+ VERSION = "3.11.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lato
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.11.0
4
+ version: 3.11.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregorio Galante
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-12 00:00:00.000000000 Z
11
+ date: 2025-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails