stimulus-overlay-helpers 1.0.0 → 2.0.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 +5 -4
- data/lib/stimulus_overlay_helpers/view_helpers.rb +56 -4
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 86ae555d09ee9af3eae8fec2e46e53de2d2b907679cb7d7721196d44fdb5835f
|
|
4
|
+
data.tar.gz: 5bb2badc10b8d1278e93cc6083d35f468a551703fb88e989e738057805083f4e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 933332441daf7824da520ba1ec4acfcebd9d783aa2605d803a2b68847fa32911a2a879650c18f013609e908d7aeb51751b05b447adb69144aa70cca70a641607
|
|
7
|
+
data.tar.gz: 5b0136dd827abba33dba52ec1fb0ec8c3685f83abee61f9ee77968426561dd5a3e00e9ff1d785aa0f35b2854473cdacd7a922fbef3f888673e3e047c08f54051
|
data/README.md
CHANGED
|
@@ -27,23 +27,24 @@ If you work with the helpers on this gem, you can setup a initializer for a cust
|
|
|
27
27
|
|
|
28
28
|
StimulusDropdown.configure do |config|
|
|
29
29
|
config.close_button_proc = ->(view) do
|
|
30
|
-
view.content_tag(:span, 'X', class: 'close-button')
|
|
30
|
+
view.content_tag(:span, 'X', class: 'close-button', data: { close: true })
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
**Z-index issues / `panel_at_place` option**
|
|
36
36
|
|
|
37
|
-
If
|
|
37
|
+
If an overlay should appear above all other elements, it should be rendered close to the root level because `z-index` is always relative to the current stacking context.
|
|
38
|
+
|
|
39
|
+
By default, unless `true` is passed to the helper’s `panel_at_place` argument, the overlay is rendered via `yield :overlays_box` in the layout:
|
|
38
40
|
|
|
39
|
-
By default, when the `panel_at_place` argument is not passed to the helper, the overlay is rendered into the `:overlays_box` content block. Therefore, this block must be yielded in the layout:
|
|
40
41
|
|
|
41
42
|
```haml
|
|
42
43
|
#overlays-box
|
|
43
44
|
= yield :overlays_box
|
|
44
45
|
```
|
|
45
46
|
|
|
46
|
-
This
|
|
47
|
+
This matches the behavior of the [Svelte overlays from `@csedl/hotwire-svelte-helpers`](https://www.npmjs.com/package/@csedl/hotwire-svelte-helpers).
|
|
47
48
|
|
|
48
49
|
## Usage Examples
|
|
49
50
|
|
|
@@ -26,7 +26,7 @@ module StimulusOverlayHelpers
|
|
|
26
26
|
|
|
27
27
|
button_options = options.dup
|
|
28
28
|
button_options[:class] = [options[:class], 'dropdown-button'].compact.join(' ')
|
|
29
|
-
button_options = button_options.merge(data: { controller: '
|
|
29
|
+
button_options = button_options.merge(data: { controller: 'hotwire-svelte-helpers-dropdown', panel_id: id })
|
|
30
30
|
|
|
31
31
|
button_content = capture(&button_content) if button_content.is_a?(Proc)
|
|
32
32
|
btn = content_tag(:div, button_content, button_options)
|
|
@@ -46,7 +46,7 @@ module StimulusOverlayHelpers
|
|
|
46
46
|
safe_join([
|
|
47
47
|
content_tag(:div, class: 'header') do
|
|
48
48
|
concat content_tag(:div, title, class: 'title')
|
|
49
|
-
concat content_tag(:div, class: 'buttons') { close_btn_proc.present? ? close_btn_proc.call(self) : content_tag(:span, 'X', class: 'close-button') }
|
|
49
|
+
concat content_tag(:div, class: 'buttons') { close_btn_proc.present? ? close_btn_proc.call(self) : content_tag(:span, 'X', class: 'close-button', data: { close: true }) }
|
|
50
50
|
end,
|
|
51
51
|
content_tag(:div, class: 'content') do
|
|
52
52
|
capture(&panel_content) if block_given?
|
|
@@ -62,6 +62,59 @@ module StimulusOverlayHelpers
|
|
|
62
62
|
end
|
|
63
63
|
end
|
|
64
64
|
|
|
65
|
+
def modal(button_content, title = nil, options = {}, &panel_content)
|
|
66
|
+
if title.is_a?(Hash)
|
|
67
|
+
options = title.dup
|
|
68
|
+
title = nil
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
panel_at_place = options.delete(:panel_at_place)
|
|
72
|
+
|
|
73
|
+
id = "modal-overlay-#{SecureRandom.hex(4)}"
|
|
74
|
+
|
|
75
|
+
src = options.delete(:src)
|
|
76
|
+
|
|
77
|
+
# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
78
|
+
# create the Button
|
|
79
|
+
# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
80
|
+
|
|
81
|
+
button_options = options.dup
|
|
82
|
+
button_options[:class] = [options[:class], 'modal-button'].compact.join(' ')
|
|
83
|
+
button_options = button_options.merge(data: { controller: 'hotwire-svelte-helpers-modal', panel_id: id })
|
|
84
|
+
|
|
85
|
+
button_content = capture(&button_content) if button_content.is_a?(Proc)
|
|
86
|
+
btn = content_tag(:div, button_content, button_options)
|
|
87
|
+
|
|
88
|
+
# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
89
|
+
# create the overlay
|
|
90
|
+
# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
91
|
+
|
|
92
|
+
panel_options = options.dup
|
|
93
|
+
panel_options[:class] = [options[:class], 'modal-panel'].compact.join(' ')
|
|
94
|
+
panel_options['data-src'] = src if src
|
|
95
|
+
close_btn_proc = StimulusOverlayHelpers.close_button_proc
|
|
96
|
+
|
|
97
|
+
overlay = content_tag(:div, class: 'modal-overlay', style: 'display:none;', id: id) do
|
|
98
|
+
content_tag(:div, panel_options) do
|
|
99
|
+
safe_join([
|
|
100
|
+
content_tag(:div, class: 'header') do
|
|
101
|
+
concat content_tag(:div, title, class: 'title')
|
|
102
|
+
concat content_tag(:div, class: 'buttons') { close_btn_proc.present? ? close_btn_proc.call(self) : content_tag(:span, 'X', class: 'close-button', data: { close: true }) }
|
|
103
|
+
end,
|
|
104
|
+
content_tag(:div, class: 'content') do
|
|
105
|
+
capture(&panel_content) if block_given?
|
|
106
|
+
end
|
|
107
|
+
])
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
if panel_at_place
|
|
112
|
+
btn + overlay
|
|
113
|
+
else
|
|
114
|
+
content_for(:overlays_box, overlay)
|
|
115
|
+
btn
|
|
116
|
+
end
|
|
117
|
+
end
|
|
65
118
|
|
|
66
119
|
def tooltip(label, options = {}, &content)
|
|
67
120
|
|
|
@@ -86,7 +139,7 @@ module StimulusOverlayHelpers
|
|
|
86
139
|
label_options = options.dup
|
|
87
140
|
label_options[:id] = options.delete(:id)
|
|
88
141
|
label_options[:class] = [options[:class], label_class].compact.join(' ')
|
|
89
|
-
label_options = label_options.merge(data: { controller: '
|
|
142
|
+
label_options = label_options.merge(data: { controller: 'hotwire-svelte-helpers-tooltip', panel_id: id, delay: delay })
|
|
90
143
|
|
|
91
144
|
label_element = if block_given? && cont.present?
|
|
92
145
|
content_tag(:span, label_options) do
|
|
@@ -118,7 +171,6 @@ module StimulusOverlayHelpers
|
|
|
118
171
|
# return the result
|
|
119
172
|
# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
120
173
|
|
|
121
|
-
|
|
122
174
|
if !panel_element
|
|
123
175
|
label_element
|
|
124
176
|
elsif panel_at_place
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: stimulus-overlay-helpers
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Christian Sedlmair
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-05-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description:
|
|
14
14
|
email: christian@sedlmair.ch
|