bootstrap5_helper 1.2.1 → 2.0.0.beta
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/lib/bootstrap5_helper/accordion/item.rb +33 -21
- data/lib/bootstrap5_helper/accordion.rb +11 -8
- data/lib/bootstrap5_helper/alert.rb +13 -5
- data/lib/bootstrap5_helper/badge.rb +9 -6
- data/lib/bootstrap5_helper/callout.rb +12 -4
- data/lib/bootstrap5_helper/card.rb +25 -13
- data/lib/bootstrap5_helper/card_with_nav_tab.rb +18 -13
- data/lib/bootstrap5_helper/input_group.rb +9 -6
- data/lib/bootstrap5_helper/modal.rb +35 -24
- data/lib/bootstrap5_helper/nav.rb +117 -44
- data/lib/bootstrap5_helper/offcanvas/content.rb +53 -52
- data/lib/bootstrap5_helper/offcanvas.rb +9 -9
- data/lib/bootstrap5_helper/overlay/menu.rb +30 -26
- data/lib/bootstrap5_helper/overlay.rb +30 -19
- data/lib/bootstrap5_helper/page_header.rb +9 -7
- data/lib/bootstrap5_helper/spinner.rb +13 -10
- data/lib/bootstrap5_helper/tab/content.rb +22 -11
- data/lib/bootstrap5_helper/tab.rb +10 -5
- data/lib/bootstrap5_helper/version.rb +1 -1
- 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: b80e1976cb72cb25fc00dd66922607696c0ecd768f5a13a4fe4133a0b86c8df0
|
|
4
|
+
data.tar.gz: 490c5c5908ae56ca91ea9be973a52c3a9fc10d9e98f18b80518663816c939259
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8aa38ac1d5a6577d1f675ad65fee42aa6bd3b4bb9a48193b866ebfab2663de1955e2a5c81cfb3fba19ee51f977bb9bc4e62bad8395b74f3e51f7fec939a1cc2f
|
|
7
|
+
data.tar.gz: f10d1aedb9e4b448a1d0c11ac157d00733dc46a9f64427a0bfc3d457465ccc12c6a4f9e56892d90811c28a09b994f90a0e0aa6099b442631da21f340f39aeb7e
|
|
@@ -17,14 +17,15 @@ module Bootstrap5Helper
|
|
|
17
17
|
super(template)
|
|
18
18
|
|
|
19
19
|
@parent = parent_id
|
|
20
|
-
@
|
|
21
|
-
@
|
|
22
|
-
@
|
|
23
|
-
@
|
|
24
|
-
@
|
|
25
|
-
@
|
|
26
|
-
@
|
|
27
|
-
@
|
|
20
|
+
@attrs = opts
|
|
21
|
+
@id = @attrs.delete(:id) { uuid }
|
|
22
|
+
@class = @attrs.delete(:class) { '' }
|
|
23
|
+
@data = @attrs.delete(:data) { {} }
|
|
24
|
+
@expanded = @attrs.delete(:expanded) { false }
|
|
25
|
+
@collapse = @attrs.delete(:collapse) { {} }
|
|
26
|
+
@collapse_id = @collapse.delete(:id) { uuid }
|
|
27
|
+
@collapse_klass = @collapse.delete(:class) { '' }
|
|
28
|
+
@collapse_data = @collapse.delete(:data) { {} }
|
|
28
29
|
@header_id = uuid
|
|
29
30
|
@content = block || proc { '' }
|
|
30
31
|
end
|
|
@@ -51,15 +52,17 @@ module Bootstrap5Helper
|
|
|
51
52
|
def header(*tag_or_options, &block)
|
|
52
53
|
tag, args = parse_tag_or_options(*tag_or_options, {})
|
|
53
54
|
|
|
54
|
-
@header_id = args.
|
|
55
|
-
klass = args.
|
|
56
|
-
data = args.
|
|
55
|
+
@header_id = args.delete(:id) { @header_id }
|
|
56
|
+
klass = args.delete(:class) { '' }
|
|
57
|
+
data = args.delete(:data) { {} }
|
|
57
58
|
|
|
58
59
|
content_tag(
|
|
59
60
|
tag || config({ accordions: :header }, :h2),
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
{
|
|
62
|
+
id: @header_id,
|
|
63
|
+
class: "accordion-header #{klass}",
|
|
64
|
+
data: data
|
|
65
|
+
}.merge(args)
|
|
63
66
|
) do
|
|
64
67
|
content_tag(
|
|
65
68
|
:button,
|
|
@@ -90,9 +93,9 @@ module Bootstrap5Helper
|
|
|
90
93
|
# @return [String]
|
|
91
94
|
#
|
|
92
95
|
def body(opts = {}, &block)
|
|
93
|
-
id = opts.
|
|
94
|
-
klass = opts.
|
|
95
|
-
data = opts.
|
|
96
|
+
id = opts.delete(:id) { uuid }
|
|
97
|
+
klass = opts.delete(:class) { '' }
|
|
98
|
+
data = opts.delete(:data) { {} }
|
|
96
99
|
|
|
97
100
|
content_tag(
|
|
98
101
|
:div,
|
|
@@ -105,9 +108,11 @@ module Bootstrap5Helper
|
|
|
105
108
|
) do
|
|
106
109
|
content_tag(
|
|
107
110
|
:div,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
+
{
|
|
112
|
+
id: id,
|
|
113
|
+
class: "accordion-body #{klass}",
|
|
114
|
+
data: data
|
|
115
|
+
}.merge(opts),
|
|
111
116
|
&block
|
|
112
117
|
)
|
|
113
118
|
end
|
|
@@ -119,7 +124,14 @@ module Bootstrap5Helper
|
|
|
119
124
|
# @return [String]
|
|
120
125
|
#
|
|
121
126
|
def to_s
|
|
122
|
-
content_tag
|
|
127
|
+
content_tag(
|
|
128
|
+
:div,
|
|
129
|
+
{
|
|
130
|
+
id: @id,
|
|
131
|
+
class: "accordion-item #{@class}",
|
|
132
|
+
data: @data
|
|
133
|
+
}.merge(@attrs)
|
|
134
|
+
) do
|
|
123
135
|
@content.call(self)
|
|
124
136
|
end
|
|
125
137
|
end
|
|
@@ -16,11 +16,12 @@ module Bootstrap5Helper
|
|
|
16
16
|
def initialize(template, opts = {}, &block)
|
|
17
17
|
super(template)
|
|
18
18
|
|
|
19
|
-
@
|
|
20
|
-
@
|
|
21
|
-
@
|
|
22
|
-
@
|
|
23
|
-
@
|
|
19
|
+
@attrs = opts
|
|
20
|
+
@id = @attrs.delete(:id) { uuid }
|
|
21
|
+
@class = @attrs.delete(:class) { '' }
|
|
22
|
+
@data = @attrs.delete(:data) { {} }
|
|
23
|
+
@always_open = @attrs.delete(:always_open) { false }
|
|
24
|
+
@flush = @attrs.delete(:flush) { false }
|
|
24
25
|
@content = block || proc { '' }
|
|
25
26
|
end
|
|
26
27
|
|
|
@@ -39,9 +40,11 @@ module Bootstrap5Helper
|
|
|
39
40
|
def to_s
|
|
40
41
|
content_tag(
|
|
41
42
|
:div,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
{
|
|
44
|
+
id: @id,
|
|
45
|
+
class: "accordion #{@flush ? 'accordion-flush' : ''} #{@class}",
|
|
46
|
+
data: @data
|
|
47
|
+
}.merge(@attrs)
|
|
45
48
|
) do
|
|
46
49
|
@content.call(self)
|
|
47
50
|
end
|
|
@@ -17,10 +17,11 @@ module Bootstrap5Helper
|
|
|
17
17
|
super(template)
|
|
18
18
|
@context, args = parse_context_or_options(context_or_options, opts)
|
|
19
19
|
|
|
20
|
-
@
|
|
21
|
-
@
|
|
22
|
-
@
|
|
23
|
-
@
|
|
20
|
+
@attrs = args
|
|
21
|
+
@id = @attrs.delete(:id) { uuid }
|
|
22
|
+
@class = @attrs.delete(:class) { '' }
|
|
23
|
+
@data = @attrs.delete(:data) { {} }
|
|
24
|
+
@dismissible = @attrs.delete(:dismissible) { false }
|
|
24
25
|
@content = block || proc { '' }
|
|
25
26
|
end
|
|
26
27
|
|
|
@@ -43,7 +44,14 @@ module Bootstrap5Helper
|
|
|
43
44
|
# @return [String]
|
|
44
45
|
#
|
|
45
46
|
def to_s
|
|
46
|
-
content_tag(
|
|
47
|
+
content_tag(
|
|
48
|
+
:div,
|
|
49
|
+
{
|
|
50
|
+
id: @id,
|
|
51
|
+
class: container_class,
|
|
52
|
+
data: @data
|
|
53
|
+
}.merge(@attrs)
|
|
54
|
+
) do
|
|
47
55
|
concat(@dismissible ? close_button : '')
|
|
48
56
|
@content.call(self)
|
|
49
57
|
end
|
|
@@ -16,9 +16,10 @@ module Bootstrap5Helper
|
|
|
16
16
|
super(template)
|
|
17
17
|
@context, args = parse_context_or_options(context_or_options, opts)
|
|
18
18
|
|
|
19
|
-
@
|
|
20
|
-
@
|
|
21
|
-
@
|
|
19
|
+
@attrs = args
|
|
20
|
+
@id = @attrs.delete(:id) { nil }
|
|
21
|
+
@class = @attrs.delete(:class) { '' }
|
|
22
|
+
@data = @attrs.delete(:data) { {} }
|
|
22
23
|
@content = block || proc { '' }
|
|
23
24
|
end
|
|
24
25
|
|
|
@@ -29,9 +30,11 @@ module Bootstrap5Helper
|
|
|
29
30
|
def to_s
|
|
30
31
|
content_tag(
|
|
31
32
|
config({ badges: :base }, :span),
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
{
|
|
34
|
+
id: @id,
|
|
35
|
+
class: container_class,
|
|
36
|
+
data: @data
|
|
37
|
+
}.merge(@attrs)
|
|
35
38
|
) do
|
|
36
39
|
@content.call(self)
|
|
37
40
|
end
|
|
@@ -15,9 +15,10 @@ module Bootstrap5Helper
|
|
|
15
15
|
super(template)
|
|
16
16
|
@context, args = parse_context_or_options(context_or_options, opts)
|
|
17
17
|
|
|
18
|
-
@
|
|
19
|
-
@
|
|
20
|
-
@
|
|
18
|
+
@attrs = args
|
|
19
|
+
@id = @attrs.delete(:id) { nil }
|
|
20
|
+
@class = @attrs.delete(:class) { '' }
|
|
21
|
+
@data = @attrs.delete(:data) { {} }
|
|
21
22
|
@content = block || proc { '' }
|
|
22
23
|
end
|
|
23
24
|
|
|
@@ -40,7 +41,14 @@ module Bootstrap5Helper
|
|
|
40
41
|
# @return [String]
|
|
41
42
|
#
|
|
42
43
|
def to_s
|
|
43
|
-
content_tag
|
|
44
|
+
content_tag(
|
|
45
|
+
:div,
|
|
46
|
+
{
|
|
47
|
+
id: @id,
|
|
48
|
+
class: container_class,
|
|
49
|
+
data: @data
|
|
50
|
+
}.merge(@attrs)
|
|
51
|
+
) do
|
|
44
52
|
@content.call(self)
|
|
45
53
|
end
|
|
46
54
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module Bootstrap5Helper
|
|
2
|
-
#
|
|
3
|
-
|
|
4
|
-
#
|
|
2
|
+
# rubocop:disable Metrics/ClassLength
|
|
3
|
+
|
|
4
|
+
# Used to build Bootstrap Card components..
|
|
5
5
|
class Card < Component
|
|
6
6
|
# Used to initialize a new Card component.
|
|
7
7
|
#
|
|
@@ -15,9 +15,10 @@ module Bootstrap5Helper
|
|
|
15
15
|
def initialize(template, opts = {}, &block)
|
|
16
16
|
super(template)
|
|
17
17
|
|
|
18
|
-
@
|
|
19
|
-
@
|
|
20
|
-
@
|
|
18
|
+
@attrs = opts
|
|
19
|
+
@id = @attrs.delete(:id) { '' }
|
|
20
|
+
@class = @attrs.delete(:class) { '' }
|
|
21
|
+
@data = @attrs.delete(:data) { {} }
|
|
21
22
|
@content = block || proc { '' }
|
|
22
23
|
end
|
|
23
24
|
|
|
@@ -228,7 +229,14 @@ module Bootstrap5Helper
|
|
|
228
229
|
# @return [String]
|
|
229
230
|
#
|
|
230
231
|
def to_s
|
|
231
|
-
content_tag
|
|
232
|
+
content_tag(
|
|
233
|
+
:div,
|
|
234
|
+
{
|
|
235
|
+
id: @id,
|
|
236
|
+
class: "card #{@class}",
|
|
237
|
+
data: @data
|
|
238
|
+
}.merge(@attrs)
|
|
239
|
+
) do
|
|
232
240
|
@content.call(self)
|
|
233
241
|
end
|
|
234
242
|
end
|
|
@@ -256,17 +264,21 @@ module Bootstrap5Helper
|
|
|
256
264
|
# @return [String]
|
|
257
265
|
#
|
|
258
266
|
def build_sub_component(tag, type, args, &block)
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
267
|
+
attrs = args
|
|
268
|
+
id = attrs.delete(:id) { '' }
|
|
269
|
+
klass = attrs.delete(:class) { '' }
|
|
270
|
+
data = attrs.delete(:data) { {} }
|
|
262
271
|
|
|
263
272
|
content_tag(
|
|
264
273
|
tag,
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
274
|
+
{
|
|
275
|
+
id: id,
|
|
276
|
+
class: "card-#{type} #{klass}",
|
|
277
|
+
data: data
|
|
278
|
+
}.merge(attrs),
|
|
268
279
|
&block
|
|
269
280
|
)
|
|
270
281
|
end
|
|
271
282
|
end
|
|
283
|
+
# rubocop:enable Metrics/ClassLength
|
|
272
284
|
end
|
|
@@ -20,9 +20,11 @@ module Bootstrap5Helper
|
|
|
20
20
|
def initialize(template, *context_or_options, &block)
|
|
21
21
|
super(template)
|
|
22
22
|
@context, args = parse_context_or_options(*context_or_options, {})
|
|
23
|
-
|
|
24
|
-
@
|
|
25
|
-
@
|
|
23
|
+
|
|
24
|
+
@attrs = args
|
|
25
|
+
@id = @attrs.delete(:id) { '' }
|
|
26
|
+
@class = @attrs.delete(:class) { '' }
|
|
27
|
+
@data = @attrs.delete(:data) { {} }
|
|
26
28
|
@content = block || proc { '' }
|
|
27
29
|
end
|
|
28
30
|
|
|
@@ -47,13 +49,14 @@ module Bootstrap5Helper
|
|
|
47
49
|
# @return [Nav]
|
|
48
50
|
#
|
|
49
51
|
def nav(*tag_or_options, &block)
|
|
50
|
-
tag, args
|
|
51
|
-
args[:class]
|
|
52
|
-
args[:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
tag, args = parse_tag_or_options(*tag_or_options, {})
|
|
53
|
+
args[:class] = (args[:class] || '') << ' nav-tabs card-header-tabs'
|
|
54
|
+
args[:bs_attrs] = (args[:bs_attrs] || {}).merge(
|
|
55
|
+
{
|
|
56
|
+
data: {
|
|
57
|
+
'bs-toggle' => 'tab',
|
|
58
|
+
'bs-display' => 'static'
|
|
59
|
+
}
|
|
57
60
|
}
|
|
58
61
|
)
|
|
59
62
|
|
|
@@ -82,9 +85,11 @@ module Bootstrap5Helper
|
|
|
82
85
|
def to_s
|
|
83
86
|
content_tag(
|
|
84
87
|
:div,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
+
{
|
|
89
|
+
class: "card with-nav-tabs-#{@context} #{@class}",
|
|
90
|
+
id: @id,
|
|
91
|
+
data: @data
|
|
92
|
+
}.merge(@attrs)
|
|
88
93
|
) do
|
|
89
94
|
@content.call(self)
|
|
90
95
|
end
|
|
@@ -18,9 +18,10 @@ module Bootstrap5Helper
|
|
|
18
18
|
|
|
19
19
|
@context, args = parse_context_or_options(context_or_options, opts)
|
|
20
20
|
|
|
21
|
-
@
|
|
22
|
-
@
|
|
23
|
-
@
|
|
21
|
+
@attrs = args
|
|
22
|
+
@id = @attrs.delete(:id) { nil }
|
|
23
|
+
@class = @attrs.delete(:class) { '' }
|
|
24
|
+
@data = @attrs.delete(:data) { {} }
|
|
24
25
|
@content = block || proc { '' }
|
|
25
26
|
end
|
|
26
27
|
|
|
@@ -42,9 +43,11 @@ module Bootstrap5Helper
|
|
|
42
43
|
def to_s
|
|
43
44
|
content_tag(
|
|
44
45
|
:div,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
{
|
|
47
|
+
id: @id,
|
|
48
|
+
class: "input-group #{size_class} #{@class}",
|
|
49
|
+
data: @data
|
|
50
|
+
}.merge(@attrs)
|
|
48
51
|
) do
|
|
49
52
|
@content.call(self)
|
|
50
53
|
end
|
|
@@ -21,14 +21,15 @@ module Bootstrap5Helper
|
|
|
21
21
|
def initialize(template, opts = {}, &block)
|
|
22
22
|
super(template)
|
|
23
23
|
|
|
24
|
-
@
|
|
25
|
-
@
|
|
26
|
-
@
|
|
27
|
-
@
|
|
28
|
-
@
|
|
29
|
-
@
|
|
30
|
-
@
|
|
31
|
-
@
|
|
24
|
+
@attrs = opts
|
|
25
|
+
@id = @attrs.delete(:id) { uuid }
|
|
26
|
+
@class = @attrs.delete(:class) { '' }
|
|
27
|
+
@data = @attrs.delete(:data) { {} }
|
|
28
|
+
@scrollable = @attrs.delete(:scrollable) { false }
|
|
29
|
+
@vcentered = @attrs.delete(:vcentered) { false }
|
|
30
|
+
@static = @attrs.delete(:static) { false }
|
|
31
|
+
@fullscreen = @attrs.delete(:fullscreen) { false }
|
|
32
|
+
@size = @attrs.delete(:size) { nil }
|
|
32
33
|
@content = block || proc { '' }
|
|
33
34
|
end
|
|
34
35
|
|
|
@@ -87,14 +88,19 @@ module Bootstrap5Helper
|
|
|
87
88
|
# @return [String]
|
|
88
89
|
#
|
|
89
90
|
def close_button(opts = {})
|
|
90
|
-
|
|
91
|
+
attrs = opts
|
|
92
|
+
klass = attrs.delete(:class) { '' }
|
|
93
|
+
data = attrs.delete(:data) { {} }
|
|
94
|
+
aria = attrs.delete(:aria) { {} }
|
|
91
95
|
|
|
92
96
|
content_tag(
|
|
93
97
|
:button,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
+
{
|
|
99
|
+
type: 'button',
|
|
100
|
+
class: block_given? ? klass : 'btn-close',
|
|
101
|
+
data: data.merge('bs-dismiss' => 'modal'),
|
|
102
|
+
aria: aria.merge(label: 'Close')
|
|
103
|
+
}.merge(attrs)
|
|
98
104
|
) do
|
|
99
105
|
block_given? ? yield : xbutton
|
|
100
106
|
end
|
|
@@ -111,11 +117,13 @@ module Bootstrap5Helper
|
|
|
111
117
|
|
|
112
118
|
content_tag(
|
|
113
119
|
:div,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
120
|
+
{
|
|
121
|
+
id: @id,
|
|
122
|
+
class: "modal #{@class}",
|
|
123
|
+
tabindex: -1,
|
|
124
|
+
role: 'dialog',
|
|
125
|
+
data: @data
|
|
126
|
+
}.merge(@attrs)
|
|
119
127
|
) do
|
|
120
128
|
content_tag(
|
|
121
129
|
:div,
|
|
@@ -151,15 +159,18 @@ module Bootstrap5Helper
|
|
|
151
159
|
# @return [String]
|
|
152
160
|
#
|
|
153
161
|
def build_sub_component(tag, type, opts = {}, &block)
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
162
|
+
attrs = opts
|
|
163
|
+
id = attrs.delete(:id) { nil }
|
|
164
|
+
klass = attrs.delete(:class) { '' }
|
|
165
|
+
data = attrs.delete(:data) { {} }
|
|
157
166
|
|
|
158
167
|
content_tag(
|
|
159
168
|
tag,
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
169
|
+
{
|
|
170
|
+
id: id,
|
|
171
|
+
class: "modal-#{type} #{klass}",
|
|
172
|
+
data: data
|
|
173
|
+
}.merge(attrs),
|
|
163
174
|
&block
|
|
164
175
|
)
|
|
165
176
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module Bootstrap5Helper
|
|
2
|
+
# rubocop:disable Metrics/ClassLength
|
|
3
|
+
|
|
2
4
|
# Builds a Nav Component that can be used in other components.
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
5
|
class Nav < Component
|
|
6
6
|
# Class constructor
|
|
7
7
|
#
|
|
@@ -11,8 +11,7 @@ module Bootstrap5Helper
|
|
|
11
11
|
# @option opts [String] :id
|
|
12
12
|
# @option opts [String] :class
|
|
13
13
|
# @option opts [Hash] :data
|
|
14
|
-
# @option opts [
|
|
15
|
-
# @option opts []
|
|
14
|
+
# @option opts [Hash] :bs_attrs
|
|
16
15
|
#
|
|
17
16
|
def initialize(template, *tag_or_options, &block)
|
|
18
17
|
super(template)
|
|
@@ -20,17 +19,16 @@ module Bootstrap5Helper
|
|
|
20
19
|
@tag, args = parse_tag_or_options(*tag_or_options, {})
|
|
21
20
|
@tag ||= config({ navs: :base }, :ul)
|
|
22
21
|
|
|
23
|
-
@
|
|
24
|
-
@
|
|
25
|
-
@
|
|
26
|
-
@
|
|
27
|
-
@
|
|
22
|
+
@attrs = args
|
|
23
|
+
@id = @attrs.delete(:id) { uuid }
|
|
24
|
+
@class = @attrs.delete(:class) { '' }
|
|
25
|
+
@data = @attrs.delete(:data) { {} }
|
|
26
|
+
@bs_attrs = @attrs.delete(:bs_attrs) { {} }
|
|
28
27
|
@dropdown = Dropdown.new(@template)
|
|
28
|
+
@content = block || proc { '' }
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
#
|
|
32
|
-
|
|
33
|
-
# Adds an nav-item to the nav component. this method gets used when the nav-item
|
|
31
|
+
# Adds an nav-item to the nav component. This method gets used when the nav-item
|
|
34
32
|
# links to content in a tab or something.
|
|
35
33
|
#
|
|
36
34
|
# @param [Symbol|String] target
|
|
@@ -39,28 +37,17 @@ module Bootstrap5Helper
|
|
|
39
37
|
# @option opts [String] :class
|
|
40
38
|
# @option opts [Hash] :data
|
|
41
39
|
# @option opts [Hash] :aria
|
|
40
|
+
# @option opts [Hash] :child
|
|
42
41
|
# @return [String]
|
|
43
42
|
#
|
|
44
|
-
def item(target, opts = {})
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
nav_item_wrapper id: id, data: data do
|
|
51
|
-
content_tag(
|
|
52
|
-
:a,
|
|
53
|
-
class: "nav-link #{klass}",
|
|
54
|
-
href: "##{target}",
|
|
55
|
-
tabindex: -1,
|
|
56
|
-
data: @child[:data],
|
|
57
|
-
aria: aria
|
|
58
|
-
) do
|
|
59
|
-
block_given? ? yield : target.to_s.titleize
|
|
60
|
-
end
|
|
43
|
+
def item(target, opts = {}, &block)
|
|
44
|
+
case @tag
|
|
45
|
+
when :nav
|
|
46
|
+
nav_item_without_wrapper(target, opts, &block)
|
|
47
|
+
when :ul
|
|
48
|
+
nav_item_with_wrapper(target, opts, &block)
|
|
61
49
|
end
|
|
62
50
|
end
|
|
63
|
-
# rubocop:enable Metrics/MethodLength
|
|
64
51
|
|
|
65
52
|
# Use this when the nav item is nothing more than a hyperlink.
|
|
66
53
|
#
|
|
@@ -88,6 +75,7 @@ module Bootstrap5Helper
|
|
|
88
75
|
# @option opts [String] :class
|
|
89
76
|
# @option opts [Hash] :data
|
|
90
77
|
# @option opts [Hash] :aria
|
|
78
|
+
# @option opts [Hash] :child
|
|
91
79
|
# @return [String]
|
|
92
80
|
#
|
|
93
81
|
def dropdown(name, opts = {}, &block)
|
|
@@ -96,9 +84,14 @@ module Bootstrap5Helper
|
|
|
96
84
|
data = opts.fetch(:data, {}).merge('bs-toggle' => 'dropdown')
|
|
97
85
|
aria = opts.fetch(:aria, {}).merge(haspopup: true, expanded: false)
|
|
98
86
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
87
|
+
nav_item_wrapper(
|
|
88
|
+
id: id,
|
|
89
|
+
class: 'dropdown',
|
|
90
|
+
data: (@bs_attrs[:data] || {}).merge(
|
|
91
|
+
'bs-toggle' => 'dropdown',
|
|
92
|
+
'bs-display' => 'static'
|
|
93
|
+
)
|
|
94
|
+
) do
|
|
102
95
|
content_tag(
|
|
103
96
|
:a,
|
|
104
97
|
name,
|
|
@@ -117,34 +110,114 @@ module Bootstrap5Helper
|
|
|
117
110
|
# @return [String]
|
|
118
111
|
#
|
|
119
112
|
def to_s
|
|
120
|
-
content_tag(
|
|
113
|
+
content_tag(
|
|
114
|
+
@tag,
|
|
115
|
+
{
|
|
116
|
+
id: @id,
|
|
117
|
+
class: "nav #{@class}",
|
|
118
|
+
data: @data
|
|
119
|
+
}.merge(@attrs)
|
|
120
|
+
) do
|
|
121
121
|
@content.call(self)
|
|
122
122
|
end
|
|
123
123
|
end
|
|
124
124
|
|
|
125
125
|
private
|
|
126
126
|
|
|
127
|
+
# rubocop:disable Metrics/AbcSize
|
|
128
|
+
|
|
129
|
+
# @note This is one of the few places where things deviate
|
|
130
|
+
# a little from the pattern of child elements requiring
|
|
131
|
+
# the :child option class needing to be set in order to
|
|
132
|
+
# pass on the class. The reason being that the default DOM
|
|
133
|
+
# elements built for navs are UL, which means that the
|
|
134
|
+
# majority of them will have children elements. Just wanted
|
|
135
|
+
# an easy process of setting the active nav, without having
|
|
136
|
+
# to remember if you are using :nav or :ul components.
|
|
137
|
+
#
|
|
138
|
+
# @example Nav built with UL(default config) would require the
|
|
139
|
+
# the following for setting the active nav:
|
|
140
|
+
#
|
|
141
|
+
# ```ruby
|
|
142
|
+
# <%= nav_helper do |nav| %>
|
|
143
|
+
# <%= nav.item(child: { class: 'active' }) do
|
|
144
|
+
# <% end %>
|
|
145
|
+
# <% end %>
|
|
146
|
+
#
|
|
147
|
+
# @example With the deviation:
|
|
148
|
+
#
|
|
149
|
+
# <%= nav_helper do |nav| %>
|
|
150
|
+
# <%= nav.item(class: 'active') do
|
|
151
|
+
# <% end %>
|
|
152
|
+
# <% end %>
|
|
153
|
+
# ```
|
|
154
|
+
#
|
|
155
|
+
# @param [Symbol|String] target
|
|
156
|
+
# @param [Hash] opts
|
|
157
|
+
# @option opts [String] :id
|
|
158
|
+
# @option opts [String] :class
|
|
159
|
+
# @option opts [Hash] :data
|
|
160
|
+
# @option opts [Hash] :aria
|
|
161
|
+
# @option opts [Hash] :child
|
|
162
|
+
# @return [String]
|
|
163
|
+
#
|
|
164
|
+
def nav_item_with_wrapper(target, opts = {}, &block)
|
|
165
|
+
attrs = opts
|
|
166
|
+
child = attrs.delete(:child) { {} }.merge(@bs_attrs)
|
|
167
|
+
child[:class] = (child[:class] || '') << ' nav-link'
|
|
168
|
+
|
|
169
|
+
if attrs.fetch(:class, '').match?('active')
|
|
170
|
+
attrs[:class].gsub!('active', '')
|
|
171
|
+
child[:class] << ' active'
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
nav_item_wrapper(attrs) do
|
|
175
|
+
content_tag(
|
|
176
|
+
:a,
|
|
177
|
+
{ href: "##{target}", tabindex: -1 }.merge(child)
|
|
178
|
+
) do
|
|
179
|
+
block_given? ? block.call : target.to_s.titleize
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
# rubocop:enable Metrics/AbcSize
|
|
184
|
+
|
|
185
|
+
# @param [Symbol|String] target
|
|
186
|
+
# @param [Hash] opts
|
|
187
|
+
# @option opts [String] :id
|
|
188
|
+
# @option opts [String] :class
|
|
189
|
+
# @option opts [Hash] :data
|
|
190
|
+
# @option opts [Hash] :aria
|
|
191
|
+
# @return [String]
|
|
192
|
+
#
|
|
193
|
+
def nav_item_without_wrapper(target, opts = {}, &block)
|
|
194
|
+
attrs = opts.merge(@bs_attrs)
|
|
195
|
+
attrs[:class] = (attrs[:class] || '') << ' nav-link'
|
|
196
|
+
|
|
197
|
+
nav_item_wrapper do
|
|
198
|
+
content_tag(
|
|
199
|
+
:a,
|
|
200
|
+
{ href: "##{target}", tabindex: -1 }.merge(attrs)
|
|
201
|
+
) do
|
|
202
|
+
block_given? ? block.call : target.to_s.titleize
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
|
|
127
207
|
# Decorator for elements requiring a wrapper component.
|
|
128
208
|
#
|
|
129
209
|
# @return [String]
|
|
130
210
|
#
|
|
131
211
|
def nav_item_wrapper(opts = {}, &block)
|
|
132
|
-
|
|
133
|
-
klass = opts.fetch(:class, '')
|
|
134
|
-
data = opts.fetch(:data, {})
|
|
212
|
+
opts[:class] = (opts[:class] || '') << ' nav-item'
|
|
135
213
|
|
|
136
214
|
case @tag
|
|
137
215
|
when :nav
|
|
138
216
|
block.call
|
|
139
217
|
when :ul
|
|
140
|
-
content_tag(
|
|
141
|
-
:li,
|
|
142
|
-
id: id,
|
|
143
|
-
class: "nav-item #{klass}",
|
|
144
|
-
data: data,
|
|
145
|
-
&block
|
|
146
|
-
)
|
|
218
|
+
content_tag(:li, opts, &block)
|
|
147
219
|
end
|
|
148
220
|
end
|
|
149
221
|
end
|
|
222
|
+
# rubocop:enable Metrics/ClassLength
|
|
150
223
|
end
|
|
@@ -4,111 +4,112 @@ module Bootstrap5Helper
|
|
|
4
4
|
#
|
|
5
5
|
#
|
|
6
6
|
class Content < Component
|
|
7
|
-
# Constructor description...
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
7
|
# @param [Hash] opts
|
|
11
8
|
# @return [ClassName]
|
|
12
9
|
#
|
|
13
10
|
def initialize(template, opts = {}, &block)
|
|
14
11
|
super(template)
|
|
15
12
|
|
|
16
|
-
@
|
|
17
|
-
@
|
|
18
|
-
@
|
|
19
|
-
@
|
|
20
|
-
@
|
|
21
|
-
@
|
|
22
|
-
@
|
|
13
|
+
@attrs = opts
|
|
14
|
+
@id = @attrs.delete(:id) { uuid }
|
|
15
|
+
@class = @attrs.delete(:class) { '' }
|
|
16
|
+
@data = @attrs.delete(:data) { {} }
|
|
17
|
+
@aria = @attrs.delete(:aria) { {} }
|
|
18
|
+
@scrollable = @attrs.delete(:scrollable) { false }
|
|
19
|
+
@position = @attrs.delete(:position) { 'start' }
|
|
20
|
+
@backdrop = @attrs.delete(:backdrop) { true }
|
|
23
21
|
@content = block || proc { '' }
|
|
24
22
|
end
|
|
25
23
|
|
|
26
24
|
# @todo
|
|
27
|
-
#
|
|
28
|
-
#
|
|
29
25
|
def header(opts = {}, &block)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
attrs = opts
|
|
27
|
+
id = attrs.delete(:id) { nil }
|
|
28
|
+
klass = attrs.delete(:class) { '' }
|
|
29
|
+
data = attrs.delete(:data) { {} }
|
|
33
30
|
|
|
34
31
|
content_tag(
|
|
35
32
|
config({ offcanvas: :header }, :div),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
{
|
|
34
|
+
id: id,
|
|
35
|
+
class: "offcanvas-header #{klass}",
|
|
36
|
+
data: data
|
|
37
|
+
}.merge(attrs),
|
|
39
38
|
&block
|
|
40
39
|
)
|
|
41
40
|
end
|
|
42
41
|
|
|
43
42
|
# @todo
|
|
44
|
-
#
|
|
45
|
-
#
|
|
46
43
|
def title(text_or_options = nil, opts = {}, &block)
|
|
47
|
-
text,
|
|
44
|
+
text, attrs = parse_text_or_options(text_or_options, opts)
|
|
48
45
|
|
|
49
|
-
id =
|
|
50
|
-
klass =
|
|
51
|
-
data =
|
|
46
|
+
id = attrs.delete(:id) { nil }
|
|
47
|
+
klass = attrs.delete(:class) { '' }
|
|
48
|
+
data = attrs.delete(:data) { {} }
|
|
52
49
|
|
|
53
50
|
content_tag(
|
|
54
51
|
config({ offcanvas: :title }, :h6),
|
|
55
52
|
text,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
{
|
|
54
|
+
id: id,
|
|
55
|
+
class: "offcanvas-title #{klass}",
|
|
56
|
+
data: data
|
|
57
|
+
}.merge(attrs),
|
|
59
58
|
&block
|
|
60
59
|
)
|
|
61
60
|
end
|
|
62
61
|
|
|
63
62
|
# @todo
|
|
64
|
-
#
|
|
65
|
-
#
|
|
66
63
|
def close_button(opts = {})
|
|
67
|
-
|
|
64
|
+
attrs = opts
|
|
65
|
+
klass = attrs.delete(:class) { '' }
|
|
66
|
+
data = attrs.delete(:data) { {} }
|
|
67
|
+
aria = attrs.delete(:aria) { {} }
|
|
68
68
|
|
|
69
69
|
content_tag(
|
|
70
70
|
config({ offcanvas: :close }, :button),
|
|
71
71
|
class: block_given? ? klass : 'btn-close',
|
|
72
|
-
data:
|
|
73
|
-
aria:
|
|
72
|
+
data: data.merge('bs-dismiss' => 'offcanvas'),
|
|
73
|
+
aria: aria.merge(label: 'Close')
|
|
74
74
|
) do
|
|
75
75
|
block_given? ? yield : xbutton
|
|
76
76
|
end
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
# @todo
|
|
80
|
-
#
|
|
81
|
-
#
|
|
82
80
|
def body(opts = {}, &block)
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
attrs = opts
|
|
82
|
+
id = attrs.delete(:id) { nil }
|
|
83
|
+
klass = attrs.delete(:class) { '' }
|
|
84
|
+
data = attrs.delete(:data) { {} }
|
|
85
|
+
aria = attrs.delete(:aria) { {} }
|
|
87
86
|
|
|
88
87
|
content_tag(
|
|
89
88
|
:div,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
{
|
|
90
|
+
id: id,
|
|
91
|
+
class: "offcanvas-body #{klass}",
|
|
92
|
+
data: data,
|
|
93
|
+
aria: aria
|
|
94
|
+
}.merge(attrs),
|
|
94
95
|
&block
|
|
95
96
|
)
|
|
96
97
|
end
|
|
97
98
|
|
|
98
99
|
# @todo
|
|
99
|
-
#
|
|
100
|
-
#
|
|
101
100
|
def to_s
|
|
102
|
-
@data.merge!('bs-scroll': @scrollable)
|
|
103
|
-
@data.merge!('bs-backdrop': @backdrop)
|
|
104
|
-
|
|
105
101
|
content_tag(
|
|
106
102
|
:div,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
103
|
+
{
|
|
104
|
+
id: @id,
|
|
105
|
+
class: "offcanvas offcanvas-#{@position} #{@class}",
|
|
106
|
+
tabindex: -1,
|
|
107
|
+
data: @data.merge!(
|
|
108
|
+
'bs-scroll' => @scrollable,
|
|
109
|
+
'bs-backdrop' => @backdrop
|
|
110
|
+
),
|
|
111
|
+
aria: @aria.merge!(labelledby: 'offcanvasExampleLabel')
|
|
112
|
+
}.merge(@attrs)
|
|
112
113
|
) do
|
|
113
114
|
@content.call(self)
|
|
114
115
|
end
|
|
@@ -18,14 +18,14 @@ module Bootstrap5Helper
|
|
|
18
18
|
#
|
|
19
19
|
def initialize(template, position_or_options = nil, opts = {}, &block)
|
|
20
20
|
super(template)
|
|
21
|
-
@pos,
|
|
22
|
-
@id
|
|
23
|
-
@class
|
|
24
|
-
@data
|
|
25
|
-
@aria
|
|
26
|
-
@scrollable
|
|
27
|
-
@backdrop
|
|
28
|
-
@content
|
|
21
|
+
@pos, @attrs = parse_position_or_options(position_or_options, opts)
|
|
22
|
+
@id = @attrs.delete(:id) { uuid }
|
|
23
|
+
@class = @attrs.delete(:class) { '' }
|
|
24
|
+
@data = @attrs.delete(:data) { {} }
|
|
25
|
+
@aria = @attrs.delete(:aria) { {} }
|
|
26
|
+
@scrollable = @attrs.delete(:scrollable) { false }
|
|
27
|
+
@backdrop = @attrs.delete(:backdrop) { true }
|
|
28
|
+
@content = block || proc { '' }
|
|
29
29
|
end
|
|
30
30
|
# rubocop:disable Metrics/MethodLength
|
|
31
31
|
|
|
@@ -139,7 +139,7 @@ module Bootstrap5Helper
|
|
|
139
139
|
scrollable: @scrollable,
|
|
140
140
|
backdrop: @backdrop,
|
|
141
141
|
position: @pos
|
|
142
|
-
},
|
|
142
|
+
}.merge(@attrs),
|
|
143
143
|
&block
|
|
144
144
|
)
|
|
145
145
|
end
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
# frozen_string_literal: false
|
|
2
|
+
|
|
1
3
|
module Bootstrap5Helper
|
|
2
4
|
class Overlay
|
|
5
|
+
# rubocop:disable Metrics/ClassLength
|
|
3
6
|
# Builds a menu component for use in dropdowns.
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
7
|
class Menu < Component
|
|
7
8
|
# Class constructor
|
|
8
9
|
#
|
|
@@ -17,9 +18,10 @@ module Bootstrap5Helper
|
|
|
17
18
|
super(template)
|
|
18
19
|
|
|
19
20
|
@tag, opts = parse_tag_or_options(*tag_or_options, {})
|
|
20
|
-
@
|
|
21
|
-
@
|
|
22
|
-
@
|
|
21
|
+
@attrs = opts
|
|
22
|
+
@id = @attrs.delete(:id) { uuid }
|
|
23
|
+
@class = @attrs.delete(:class) { '' }
|
|
24
|
+
@data = @attrs.delete(:data) { {} }
|
|
23
25
|
@content = block || proc { '' }
|
|
24
26
|
end
|
|
25
27
|
|
|
@@ -45,8 +47,6 @@ module Bootstrap5Helper
|
|
|
45
47
|
end
|
|
46
48
|
end
|
|
47
49
|
|
|
48
|
-
# rubocop:disable Metrics/MethodLength
|
|
49
|
-
|
|
50
50
|
# Use this method when you are using the item in the menu as trigger for
|
|
51
51
|
# something like tab content.
|
|
52
52
|
#
|
|
@@ -59,25 +59,23 @@ module Bootstrap5Helper
|
|
|
59
59
|
# @return [String]
|
|
60
60
|
#
|
|
61
61
|
def item(target, opts = {})
|
|
62
|
-
|
|
63
|
-
klass =
|
|
64
|
-
data =
|
|
65
|
-
aria = opts.fetch(:aria, {})
|
|
62
|
+
attrs = opts
|
|
63
|
+
klass = attrs.delete(:class) { '' }
|
|
64
|
+
data = attrs.delete(:data) { {} }
|
|
66
65
|
|
|
67
66
|
nav_item_wrapper do
|
|
68
67
|
content_tag(
|
|
69
68
|
:a,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
{
|
|
70
|
+
class: "dropdown-item #{klass}",
|
|
71
|
+
href: "##{target}",
|
|
72
|
+
data: data.merge('bs-toggle' => 'tab')
|
|
73
|
+
}.merge(attrs)
|
|
75
74
|
) do
|
|
76
75
|
block_given? ? yield : target.to_s.titleize
|
|
77
76
|
end
|
|
78
77
|
end
|
|
79
78
|
end
|
|
80
|
-
# rubocop:enable Metrics/MethodLength
|
|
81
79
|
|
|
82
80
|
# Builds a Text component
|
|
83
81
|
#
|
|
@@ -142,9 +140,11 @@ module Bootstrap5Helper
|
|
|
142
140
|
def to_s
|
|
143
141
|
content_tag(
|
|
144
142
|
@tag || config({ overlay_menus: :base }, :div),
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
143
|
+
{
|
|
144
|
+
id: @id,
|
|
145
|
+
class: "dropdown-menu #{@class}",
|
|
146
|
+
data: @data
|
|
147
|
+
}.merge(@attrs)
|
|
148
148
|
) do
|
|
149
149
|
@content.call(self)
|
|
150
150
|
end
|
|
@@ -177,19 +177,23 @@ module Bootstrap5Helper
|
|
|
177
177
|
# @return [String]
|
|
178
178
|
#
|
|
179
179
|
def build_sub_component(tag, text, type, opts)
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
180
|
+
attrs = opts
|
|
181
|
+
id = attrs.delete(:id) { nil }
|
|
182
|
+
klass = attrs.delete(:class) { '' }
|
|
183
|
+
data = attrs.delete(:data) { {} }
|
|
183
184
|
|
|
184
185
|
content_tag(
|
|
185
186
|
tag,
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
187
|
+
{
|
|
188
|
+
id: id,
|
|
189
|
+
class: "dropdown-#{type} #{klass}",
|
|
190
|
+
data: data
|
|
191
|
+
}.merge(attrs)
|
|
189
192
|
) do
|
|
190
193
|
block_given? ? yield : text || ''
|
|
191
194
|
end
|
|
192
195
|
end
|
|
193
196
|
end
|
|
197
|
+
# rubocop:enable Metrics/ClassLength
|
|
194
198
|
end
|
|
195
199
|
end
|
|
@@ -28,15 +28,18 @@ module Bootstrap5Helper
|
|
|
28
28
|
super(template)
|
|
29
29
|
|
|
30
30
|
@tag, args = parse_tag_or_options(*tag_or_options, {})
|
|
31
|
-
@
|
|
32
|
-
@
|
|
33
|
-
@
|
|
34
|
-
@
|
|
35
|
-
@
|
|
31
|
+
@attrs = args
|
|
32
|
+
@split = @attrs.delete(:split) { false }
|
|
33
|
+
@centered = @attrs.delete(:centered) { false }
|
|
34
|
+
@id = @attrs.delete(:id) { uuid }
|
|
35
|
+
@class = @attrs.delete(:class) { '' }
|
|
36
|
+
@data = @attrs.delete(:data) { {} }
|
|
36
37
|
|
|
37
38
|
@content = block || proc { '' }
|
|
38
39
|
end
|
|
39
40
|
|
|
41
|
+
# rubocop:disable Metrics/MethodLength
|
|
42
|
+
|
|
40
43
|
# Used to generate a button for the dropdown. This button just
|
|
41
44
|
# opens the coresponding dropdown menu.
|
|
42
45
|
#
|
|
@@ -48,23 +51,29 @@ module Bootstrap5Helper
|
|
|
48
51
|
# @return [String]
|
|
49
52
|
#
|
|
50
53
|
def button(context = :primary, opts = {}, &block)
|
|
51
|
-
|
|
52
|
-
klass =
|
|
53
|
-
data =
|
|
54
|
-
|
|
55
|
-
'bs-display' => 'static'
|
|
56
|
-
)
|
|
54
|
+
attrs = opts
|
|
55
|
+
klass = attrs.delete(:class) { '' }
|
|
56
|
+
data = attrs.delete(:data) { {} }
|
|
57
|
+
aria = attrs.delete(:aria) { {} }
|
|
57
58
|
|
|
58
59
|
content_tag(
|
|
59
60
|
:button,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
{
|
|
62
|
+
type: 'button',
|
|
63
|
+
class: "dropdown-toggle btn btn-#{context} #{klass}",
|
|
64
|
+
data: data.merge(
|
|
65
|
+
'bs-toggle' => 'dropdown',
|
|
66
|
+
'bs-display' => 'static'
|
|
67
|
+
),
|
|
68
|
+
aria: aria.merge(
|
|
69
|
+
haspopup: true,
|
|
70
|
+
expanded: false
|
|
71
|
+
)
|
|
72
|
+
}.merge(attrs),
|
|
65
73
|
&block
|
|
66
74
|
)
|
|
67
75
|
end
|
|
76
|
+
# rubocop:enable Metrics/MethodLength
|
|
68
77
|
|
|
69
78
|
# Used to generate a button with just the caret, to open the dropdown.
|
|
70
79
|
#
|
|
@@ -112,9 +121,11 @@ module Bootstrap5Helper
|
|
|
112
121
|
def to_s
|
|
113
122
|
content_tag(
|
|
114
123
|
@tag || :div,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
124
|
+
{
|
|
125
|
+
id: @id,
|
|
126
|
+
class: "#{@type} #{alignment_type_class} #{@class}",
|
|
127
|
+
data: @data
|
|
128
|
+
}.merge(@attrs)
|
|
118
129
|
) do
|
|
119
130
|
@content.call(self)
|
|
120
131
|
end
|
|
@@ -15,12 +15,12 @@ module Bootstrap5Helper
|
|
|
15
15
|
def initialize(template, tag_or_options = nil, opts = {}, &block)
|
|
16
16
|
super(template)
|
|
17
17
|
|
|
18
|
-
@tag,
|
|
18
|
+
@tag, @attrs = parse_tag_or_options(tag_or_options, opts)
|
|
19
19
|
@tag ||= config(:page_header, :h1)
|
|
20
20
|
|
|
21
|
-
@id =
|
|
22
|
-
@class =
|
|
23
|
-
@data =
|
|
21
|
+
@id = @attrs.delete(:id) { uuid }
|
|
22
|
+
@class = @attrs.delete(:class) { '' }
|
|
23
|
+
@data = @attrs.delete(:data) { {} }
|
|
24
24
|
@content = block || proc { '' }
|
|
25
25
|
end
|
|
26
26
|
|
|
@@ -31,9 +31,11 @@ module Bootstrap5Helper
|
|
|
31
31
|
def to_s
|
|
32
32
|
content_tag(
|
|
33
33
|
@tag,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
{
|
|
35
|
+
id: @id,
|
|
36
|
+
class: "pb-2 mt-4 mb-2 border-bottom #{@class}",
|
|
37
|
+
data: @data
|
|
38
|
+
}.merge(@attrs)
|
|
37
39
|
) do
|
|
38
40
|
@content.call(self)
|
|
39
41
|
end
|
|
@@ -18,11 +18,12 @@ module Bootstrap5Helper
|
|
|
18
18
|
def initialize(template, opts = {}, &block)
|
|
19
19
|
super(template)
|
|
20
20
|
|
|
21
|
-
@
|
|
22
|
-
@
|
|
23
|
-
@
|
|
24
|
-
@
|
|
25
|
-
@
|
|
21
|
+
@attrs = opts
|
|
22
|
+
@type = @attrs.delete(:type) { :border }
|
|
23
|
+
@size = @attrs.delete(:size) { nil }
|
|
24
|
+
@id = @attrs.delete(:id) { uuid }
|
|
25
|
+
@class = @attrs.delete(:class) { '' }
|
|
26
|
+
@data = @attrs.delete(:data) { {} }
|
|
26
27
|
@content = block || proc { '' }
|
|
27
28
|
end
|
|
28
29
|
|
|
@@ -33,11 +34,13 @@ module Bootstrap5Helper
|
|
|
33
34
|
def to_s
|
|
34
35
|
content_tag(
|
|
35
36
|
:span,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
{
|
|
38
|
+
id: @id,
|
|
39
|
+
class: component_classes,
|
|
40
|
+
role: 'status',
|
|
41
|
+
aria: { hidden: true },
|
|
42
|
+
data: @data
|
|
43
|
+
}.merge(@attrs)
|
|
41
44
|
) do
|
|
42
45
|
content_tag :span, 'Loading', class: 'visually-hidden'
|
|
43
46
|
end
|
|
@@ -15,9 +15,10 @@ module Bootstrap5Helper
|
|
|
15
15
|
def initialize(template, opts = {}, &block)
|
|
16
16
|
super(template)
|
|
17
17
|
|
|
18
|
-
@
|
|
19
|
-
@
|
|
20
|
-
@
|
|
18
|
+
@attrs = opts
|
|
19
|
+
@id = @attrs.delete(:id) { uuid }
|
|
20
|
+
@class = @attrs.delete(:class) { '' }
|
|
21
|
+
@data = @attrs.delete(:data) { {} }
|
|
21
22
|
@content = block || proc { '' }
|
|
22
23
|
end
|
|
23
24
|
|
|
@@ -30,16 +31,19 @@ module Bootstrap5Helper
|
|
|
30
31
|
# @return [String]
|
|
31
32
|
#
|
|
32
33
|
def pane(source, opts = {}, &block)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
attrs = opts
|
|
35
|
+
id = attrs.delete(:id) { source }
|
|
36
|
+
klass = attrs.delete(:class) { '' }
|
|
37
|
+
data = attrs.delete(:data) { {} }
|
|
36
38
|
|
|
37
39
|
content_tag(
|
|
38
40
|
:div,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
{
|
|
42
|
+
id: id,
|
|
43
|
+
class: "tab-pane #{klass}",
|
|
44
|
+
role: 'tabpanel',
|
|
45
|
+
data: data
|
|
46
|
+
}.merge(attrs),
|
|
43
47
|
&block
|
|
44
48
|
)
|
|
45
49
|
end
|
|
@@ -49,7 +53,14 @@ module Bootstrap5Helper
|
|
|
49
53
|
# @return [String]
|
|
50
54
|
#
|
|
51
55
|
def to_s
|
|
52
|
-
content_tag
|
|
56
|
+
content_tag(
|
|
57
|
+
:div,
|
|
58
|
+
{
|
|
59
|
+
id: @id,
|
|
60
|
+
class: "tab-content #{@class}",
|
|
61
|
+
data: @data
|
|
62
|
+
}.merge(@attrs)
|
|
63
|
+
) do
|
|
53
64
|
@content.call(self)
|
|
54
65
|
end
|
|
55
66
|
end
|
|
@@ -30,14 +30,14 @@ module Bootstrap5Helper
|
|
|
30
30
|
# @option opts [String] :id
|
|
31
31
|
# @option opts [String] :class
|
|
32
32
|
# @option opts [Hash] :data
|
|
33
|
-
# @option opts [Hash] :
|
|
33
|
+
# @option opts [Hash] :bs_attrs
|
|
34
34
|
#
|
|
35
35
|
# @overload nav(opts)
|
|
36
36
|
# @param [Hash] opts
|
|
37
37
|
# @option opts [String] :id
|
|
38
38
|
# @option opts [String] :class
|
|
39
39
|
# @option opts [Hash] :data
|
|
40
|
-
# @option opts [Hash] :
|
|
40
|
+
# @option opts [Hash] :bs_attrs
|
|
41
41
|
#
|
|
42
42
|
# @yield [Nav]
|
|
43
43
|
# @return [Nav]
|
|
@@ -45,9 +45,14 @@ module Bootstrap5Helper
|
|
|
45
45
|
def nav(*tag_or_options, &block)
|
|
46
46
|
tag, args = parse_tag_or_options(*tag_or_options, {})
|
|
47
47
|
|
|
48
|
-
args[:class]
|
|
49
|
-
args[:data]
|
|
50
|
-
args[:
|
|
48
|
+
args[:class] = (args[:class] || '') << " nav-#{@type}"
|
|
49
|
+
args[:data] = (args[:data] || {})
|
|
50
|
+
args[:bs_attrs] = {
|
|
51
|
+
data: {
|
|
52
|
+
'bs-toggle' => 'tab',
|
|
53
|
+
'bs-display' => 'static'
|
|
54
|
+
}
|
|
55
|
+
}
|
|
51
56
|
|
|
52
57
|
Nav.new(@template, tag, args, &block)
|
|
53
58
|
end
|