stimulus-overlay-helpers 3.2.0 → 4.1.0
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 +4 -4
- data/README.md +10 -0
- data/lib/stimulus_overlay_helpers/view_helpers.rb +16 -6
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bd73c40c3f20afb36a51b7a1990210151b6fca78a2e6a592f06cc313f8f5b9e4
|
|
4
|
+
data.tar.gz: 1548190eb2bf9bff381f70454e4f5b28debe5a8ed335a9eb0dafc1e2bd2f3638
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5922da66fb9a269059baa7883b45fd806333eddd92ec5715ece68ebbad66fd1aed93bee8ab49602015b545e38677e01a4c17e92365a37e44b2393441b4316ae9
|
|
7
|
+
data.tar.gz: 304fbd447b8b5dc7f1a898dcbf8d53258f46f819ce324592bb179ab85b7067dd6d8d92032e8363a8a005a31010712ef6408d27e2cdc45ea1c862832c59554ccd
|
data/README.md
CHANGED
|
@@ -63,4 +63,14 @@ This matches the behavior of the [Svelte overlays from `@csedl/hotwire-svelte-he
|
|
|
63
63
|
tooltip-content
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
+
## Create Dropdown-Panel or Modal on opening
|
|
67
|
+
|
|
68
|
+
When `src` attribute is passed and, on opening, no panel is rendered, which is the case when:
|
|
69
|
+
|
|
70
|
+
- the button is rendered within a turbo-frame and therefore no content_for is working
|
|
71
|
+
|
|
72
|
+
Then, on opening, the panel is created by the `@csedl/hotwire-svelte-helpers` package
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
66
76
|
License: MIT
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
module StimulusOverlayHelpers
|
|
2
2
|
module ViewHelpers
|
|
3
3
|
|
|
4
|
-
|
|
5
4
|
#== dropdown helper
|
|
6
5
|
# @param [button_content] Proc or String for content of the button element
|
|
7
6
|
# @param [panel_at_place] true (default: false) => it would render the panel into content_for(:overlays_box) on sticky parts (left-menu / top-bar) panels should be at place for avoiding that the panel would scroll with the content
|
|
@@ -23,7 +22,8 @@ module StimulusOverlayHelpers
|
|
|
23
22
|
panel_at_place = options.delete(:panel_at_place)
|
|
24
23
|
src = options.delete(:src)
|
|
25
24
|
button_class = [options.delete(:button_class), 'dropdown-button', options[:class]].compact.join(' ')
|
|
26
|
-
panel_class = [options.delete(:
|
|
25
|
+
panel_class = [options.delete(:panel_class), 'dropdown-panel'].compact.join(' ')
|
|
26
|
+
|
|
27
27
|
close_btn_proc = StimulusOverlayHelpers.close_button_proc
|
|
28
28
|
|
|
29
29
|
id = "dropdown-panel-#{SecureRandom.hex(4)}"
|
|
@@ -34,6 +34,11 @@ module StimulusOverlayHelpers
|
|
|
34
34
|
|
|
35
35
|
button_content = capture(&panel_content_button = button_content) if button_content.is_a?(Proc)
|
|
36
36
|
button_options = options.merge(class: button_class, data: { controller: 'hotwire-svelte-helpers-dropdown', panel_id: id })
|
|
37
|
+
if src.present?
|
|
38
|
+
button_options['data-src'] = src
|
|
39
|
+
button_options["data-overlay-class"] = panel_class
|
|
40
|
+
button_options["data-overlay-title"] = title
|
|
41
|
+
end
|
|
37
42
|
button_element = content_tag(:div, button_content, button_options)
|
|
38
43
|
|
|
39
44
|
# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
@@ -63,7 +68,7 @@ module StimulusOverlayHelpers
|
|
|
63
68
|
if panel_at_place
|
|
64
69
|
button_element + panel_element
|
|
65
70
|
else
|
|
66
|
-
content_for(:overlays_box, panel_element)
|
|
71
|
+
content_for(:overlays_box, panel_element) unless src.present? && !block_given?
|
|
67
72
|
button_element
|
|
68
73
|
end
|
|
69
74
|
end
|
|
@@ -85,7 +90,7 @@ module StimulusOverlayHelpers
|
|
|
85
90
|
panel_at_place = options.delete(:panel_at_place)
|
|
86
91
|
src = options.delete(:src)
|
|
87
92
|
button_class = [options.delete(:button_class) || 'modal-button', options[:class]].compact.join(' ')
|
|
88
|
-
panel_class = [options.delete(:
|
|
93
|
+
panel_class = [options.delete(:modal_class), 'modal-panel'].compact.join(' ')
|
|
89
94
|
close_btn_proc = StimulusOverlayHelpers.close_button_proc
|
|
90
95
|
|
|
91
96
|
id = "modal-overlay-#{SecureRandom.hex(4)}"
|
|
@@ -96,6 +101,11 @@ module StimulusOverlayHelpers
|
|
|
96
101
|
|
|
97
102
|
button_content = capture(&button_content) if button_content.is_a?(Proc)
|
|
98
103
|
button_options = options.merge(class: button_class, data: { controller: 'hotwire-svelte-helpers-modal', panel_id: id })
|
|
104
|
+
if src.present?
|
|
105
|
+
button_options['data-src'] = src
|
|
106
|
+
button_options["data-overlay-class"] = panel_class
|
|
107
|
+
button_options["data-overlay-title"] = title
|
|
108
|
+
end
|
|
99
109
|
button_element = content_tag(:div, button_content, button_options)
|
|
100
110
|
|
|
101
111
|
# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
@@ -126,7 +136,7 @@ module StimulusOverlayHelpers
|
|
|
126
136
|
if panel_at_place
|
|
127
137
|
button_element + overlay_element
|
|
128
138
|
else
|
|
129
|
-
content_for(:overlays_box, overlay_element)
|
|
139
|
+
content_for(:overlays_box, overlay_element) unless src.present? && !block_given?
|
|
130
140
|
button_element
|
|
131
141
|
end
|
|
132
142
|
end
|
|
@@ -169,7 +179,7 @@ module StimulusOverlayHelpers
|
|
|
169
179
|
panel_options['data-src'] = src if src.present?
|
|
170
180
|
|
|
171
181
|
panel_element = content_tag(:div, panel_options) do
|
|
172
|
-
content_tag(
|
|
182
|
+
content_tag(:div, '', id: "arrow") +
|
|
173
183
|
content_tag(:div, tip, class: 'tooltip-content')
|
|
174
184
|
end
|
|
175
185
|
|