bootstrap5_helper 1.0.0 → 1.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/lib/bootstrap5_helper/accordion/item.rb +34 -13
- data/lib/bootstrap5_helper/accordion.rb +6 -2
- data/lib/bootstrap5_helper/badge.rb +12 -5
- data/lib/bootstrap5_helper/card.rb +103 -35
- data/lib/bootstrap5_helper/card_with_nav_tab.rb +80 -0
- data/lib/bootstrap5_helper/configuration.rb +12 -7
- data/lib/bootstrap5_helper/constants.rb +6 -1
- data/lib/bootstrap5_helper/dropdown.rb +25 -112
- data/lib/bootstrap5_helper/dropend.rb +34 -0
- data/lib/bootstrap5_helper/dropstart.rb +34 -0
- data/lib/bootstrap5_helper/dropup.rb +34 -0
- data/lib/bootstrap5_helper/modal.rb +5 -5
- data/lib/bootstrap5_helper/nav.rb +17 -12
- data/lib/bootstrap5_helper/offcanvas/content.rb +1 -0
- data/lib/bootstrap5_helper/{dropdown → overlay}/menu.rb +75 -42
- data/lib/bootstrap5_helper/overlay.rb +138 -0
- data/lib/bootstrap5_helper/tab.rb +18 -6
- data/lib/bootstrap5_helper/version.rb +1 -1
- data/lib/bootstrap5_helper.rb +119 -40
- metadata +10 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ab8982347a3e4e8f5b3f295df1d32c1436c96f6a0e6ed7ebe49be9cb2030acf
|
4
|
+
data.tar.gz: 1f0e37c6a736272b748fab3c8c00107d58d232f177d4fcbb812d212085670d6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81a56bd544a7aaa270adbde0e361e2c1bf206e9e39980eca8ad8af45295a430c2cb1b21d76af32eb320013715ca5545ba99c784f881786e1df967f9a6df1aad8
|
7
|
+
data.tar.gz: 5aedd70cae3d0fce44b2457a1be9918b4e8c5cf95440970f6eb1dee8c4abb3be40af7b345a6312b7504f42f958304cf1be833fdde375a1bd21f9888888b1351f
|
@@ -11,29 +11,45 @@ module Bootstrap5Helper
|
|
11
11
|
# @option opts [String] :id
|
12
12
|
# @option opts [String] :class
|
13
13
|
# @option opts [Hash] :data
|
14
|
+
# @option opts [Hash] :collapse
|
14
15
|
#
|
15
16
|
def initialize(template, parent_id = nil, opts = {}, &block)
|
16
17
|
super(template)
|
17
18
|
|
18
|
-
@parent
|
19
|
-
@id
|
20
|
-
@class
|
21
|
-
@data
|
22
|
-
@expanded
|
23
|
-
@
|
24
|
-
@collapse_id
|
25
|
-
@
|
19
|
+
@parent = parent_id
|
20
|
+
@id = opts.fetch(:id, uuid)
|
21
|
+
@class = opts.fetch(:class, '')
|
22
|
+
@data = opts.fetch(:data, {})
|
23
|
+
@expanded = opts.fetch(:expanded, false)
|
24
|
+
@collapse = opts.fetch(:collapse, {})
|
25
|
+
@collapse_id = @collapse.fetch(:id, uuid)
|
26
|
+
@collapse_klass = @collapse.fetch(:class, '')
|
27
|
+
@collapse_data = @collapse.fetch(:data, {})
|
28
|
+
@header_id = uuid
|
29
|
+
@content = block || proc { '' }
|
26
30
|
end
|
27
31
|
|
28
32
|
# rubocop:disable Metrics/MethodLength
|
29
33
|
|
30
34
|
# Builds a header component for the accordion.
|
31
35
|
#
|
32
|
-
# @
|
36
|
+
# @overload header(tag, opts)
|
37
|
+
# @param [Symbol|String] tag - The HTML element to use.
|
38
|
+
# @param [Hash] options
|
39
|
+
# @option opts [String] :id
|
40
|
+
# @option opts [String] :class
|
41
|
+
# @option opts [Hash] :data
|
42
|
+
#
|
43
|
+
# @overload header(opts)
|
44
|
+
# @param [Hash] options
|
45
|
+
# @option opts [String] :id
|
46
|
+
# @option opts [String] :class
|
47
|
+
# @option opts [Hash] :data
|
48
|
+
#
|
33
49
|
# @return [String]
|
34
50
|
#
|
35
|
-
def header(tag_or_options
|
36
|
-
tag, args = parse_tag_or_options(tag_or_options,
|
51
|
+
def header(*tag_or_options, &block)
|
52
|
+
tag, args = parse_tag_or_options(*tag_or_options, {})
|
37
53
|
|
38
54
|
@header_id = args.fetch(:id, @header_id)
|
39
55
|
klass = args.fetch(:class, '')
|
@@ -68,6 +84,9 @@ module Bootstrap5Helper
|
|
68
84
|
# Builds the body component for the accordion.
|
69
85
|
#
|
70
86
|
# @param [Hash] opts
|
87
|
+
# @option opts [String] :id
|
88
|
+
# @option opts [String] :class
|
89
|
+
# @option opts [Hash] :data
|
71
90
|
# @return [String]
|
72
91
|
#
|
73
92
|
def body(opts = {}, &block)
|
@@ -78,9 +97,11 @@ module Bootstrap5Helper
|
|
78
97
|
content_tag(
|
79
98
|
:div,
|
80
99
|
id: @collapse_id,
|
81
|
-
class: "accordion-collapse collapse #{@expanded ? 'show' : ''}",
|
100
|
+
class: "accordion-collapse collapse #{@collapse_klass} #{@expanded ? 'show' : ''}",
|
82
101
|
aria: { labelledby: @header_id },
|
83
|
-
data: {
|
102
|
+
data: {
|
103
|
+
'bs-parent' => @parent.present? ? "##{@parent}" : nil
|
104
|
+
}.merge(@collapse_data)
|
84
105
|
) do
|
85
106
|
content_tag(
|
86
107
|
:div,
|
@@ -24,8 +24,12 @@ module Bootstrap5Helper
|
|
24
24
|
@content = block || proc { '' }
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
|
27
|
+
# Used to generate a <tt>Accordion::Item</tt> component.
|
28
|
+
#
|
29
|
+
# @return [Accodion::Item]
|
30
|
+
#
|
31
|
+
def item(opts = {}, &block)
|
32
|
+
Accordion::Item.new(self, (@always_open ? nil : @id), opts, &block)
|
29
33
|
end
|
30
34
|
|
31
35
|
# String representation of the object.
|
@@ -28,7 +28,7 @@ module Bootstrap5Helper
|
|
28
28
|
#
|
29
29
|
def to_s
|
30
30
|
content_tag(
|
31
|
-
config(:
|
31
|
+
config({ badges: :base }, :span),
|
32
32
|
id: @id,
|
33
33
|
class: container_class,
|
34
34
|
data: @data
|
@@ -44,10 +44,17 @@ module Bootstrap5Helper
|
|
44
44
|
# @return [String]
|
45
45
|
#
|
46
46
|
def container_class
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
47
|
+
"badge #{component_class} #{@class}"
|
48
|
+
end
|
49
|
+
|
50
|
+
def component_class
|
51
|
+
contrast = config({ badges: :contrast }, false)
|
52
|
+
|
53
|
+
if @context == 'secondary'
|
54
|
+
contrast ? 'text-bg-secondary' : 'bg-secondary'
|
55
|
+
else
|
56
|
+
contrast ? "text-bg-#{@context}" : "bg-#{@context}"
|
57
|
+
end
|
51
58
|
end
|
52
59
|
end
|
53
60
|
end
|
@@ -23,15 +23,23 @@ module Bootstrap5Helper
|
|
23
23
|
|
24
24
|
# Builds the Header component.
|
25
25
|
#
|
26
|
-
# @
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
26
|
+
# @overload header(tag, opts)
|
27
|
+
# @param [Symbol|String] tag - The HTML element to use.
|
28
|
+
# @param [Hash] options
|
29
|
+
# @option opts [String] :id
|
30
|
+
# @option opts [String] :class
|
31
|
+
# @option opts [Hash] :data
|
32
|
+
#
|
33
|
+
# @overload header(opts)
|
34
|
+
# @param [Hash] options
|
35
|
+
# @option opts [String] :id
|
36
|
+
# @option opts [String] :class
|
37
|
+
# @option opts [Hash] :data
|
38
|
+
#
|
31
39
|
# @return [String]
|
32
40
|
#
|
33
|
-
def header(tag_or_options
|
34
|
-
tag, args = parse_tag_or_options(tag_or_options,
|
41
|
+
def header(*tag_or_options, &block)
|
42
|
+
tag, args = parse_tag_or_options(*tag_or_options, {})
|
35
43
|
build_base_component(
|
36
44
|
tag || config({ cards: :header }, :h5),
|
37
45
|
:header,
|
@@ -42,15 +50,23 @@ module Bootstrap5Helper
|
|
42
50
|
|
43
51
|
# Builds the Body component.
|
44
52
|
#
|
45
|
-
# @
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
49
|
-
#
|
53
|
+
# @overload body(tag, opts)
|
54
|
+
# @param [Symbol|String] tag - The HTML element to use.
|
55
|
+
# @param [Hash] options
|
56
|
+
# @option opts [String] :id
|
57
|
+
# @option opts [String] :class
|
58
|
+
# @option opts [Hash] :data
|
59
|
+
#
|
60
|
+
# @overload body(opts)
|
61
|
+
# @param [Hash] options
|
62
|
+
# @option opts [String] :id
|
63
|
+
# @option opts [String] :class
|
64
|
+
# @option opts [Hash] :data
|
65
|
+
#
|
50
66
|
# @return [String]
|
51
67
|
#
|
52
|
-
def body(tag_or_options
|
53
|
-
tag, args = parse_tag_or_options(tag_or_options,
|
68
|
+
def body(*tag_or_options, &block)
|
69
|
+
tag, args = parse_tag_or_options(*tag_or_options, {})
|
54
70
|
build_base_component(
|
55
71
|
tag || config({ cards: :body }, :div),
|
56
72
|
:body,
|
@@ -61,15 +77,24 @@ module Bootstrap5Helper
|
|
61
77
|
|
62
78
|
# Builds the Footer component.
|
63
79
|
#
|
64
|
-
#
|
65
|
-
# @
|
66
|
-
#
|
67
|
-
#
|
68
|
-
#
|
80
|
+
#
|
81
|
+
# @overload footer(tag, opts)
|
82
|
+
# @param [Symbol|String] tag - The HTML element to use.
|
83
|
+
# @param [Hash] options
|
84
|
+
# @option opts [String] :id
|
85
|
+
# @option opts [String] :class
|
86
|
+
# @option opts [Hash] :data
|
87
|
+
#
|
88
|
+
# @overload footer(opts)
|
89
|
+
# @param [Hash] options
|
90
|
+
# @option opts [String] :id
|
91
|
+
# @option opts [String] :class
|
92
|
+
# @option opts [Hash] :data
|
93
|
+
#
|
69
94
|
# @return [String]
|
70
95
|
#
|
71
|
-
def footer(tag_or_options
|
72
|
-
tag, args = parse_tag_or_options(tag_or_options,
|
96
|
+
def footer(*tag_or_options, &block)
|
97
|
+
tag, args = parse_tag_or_options(*tag_or_options, {})
|
73
98
|
build_base_component(
|
74
99
|
tag || config({ cards: :footer }, :div),
|
75
100
|
:footer,
|
@@ -80,15 +105,23 @@ module Bootstrap5Helper
|
|
80
105
|
|
81
106
|
# Builds a Title component.
|
82
107
|
#
|
83
|
-
# @
|
84
|
-
#
|
85
|
-
#
|
86
|
-
#
|
87
|
-
#
|
108
|
+
# @overload title(tag, opts)
|
109
|
+
# @param [Symbol|String] tag - The HTML element to use.
|
110
|
+
# @param [Hash] options
|
111
|
+
# @option opts [String] :id
|
112
|
+
# @option opts [String] :class
|
113
|
+
# @option opts [Hash] :data
|
114
|
+
#
|
115
|
+
# @overload title(opts)
|
116
|
+
# @param [Hash] options
|
117
|
+
# @option opts [String] :id
|
118
|
+
# @option opts [String] :class
|
119
|
+
# @option opts [Hash] :data
|
120
|
+
#
|
88
121
|
# @return [String]
|
89
122
|
#
|
90
|
-
def title(tag_or_options
|
91
|
-
tag, args = parse_tag_or_options(tag_or_options,
|
123
|
+
def title(*tag_or_options, &block)
|
124
|
+
tag, args = parse_tag_or_options(*tag_or_options, {})
|
92
125
|
build_sub_component(
|
93
126
|
tag || config({ cards: :title }, :h5),
|
94
127
|
:title,
|
@@ -97,17 +130,52 @@ module Bootstrap5Helper
|
|
97
130
|
)
|
98
131
|
end
|
99
132
|
|
133
|
+
# Builds a Title component.
|
134
|
+
#
|
135
|
+
# @overload subtitle(tag, opts)
|
136
|
+
# @param [Symbol|String] tag - The HTML element to use.
|
137
|
+
# @param [Hash] options
|
138
|
+
# @option opts [String] :id
|
139
|
+
# @option opts [String] :class
|
140
|
+
# @option opts [Hash] :data
|
141
|
+
#
|
142
|
+
# @overload subtitle(opts)
|
143
|
+
# @param [Hash] options
|
144
|
+
# @option opts [String] :id
|
145
|
+
# @option opts [String] :class
|
146
|
+
# @option opts [Hash] :data
|
147
|
+
#
|
148
|
+
# @return [String]
|
149
|
+
#
|
150
|
+
def subtitle(*tag_or_options, &block)
|
151
|
+
tag, args = parse_tag_or_options(*tag_or_options, {})
|
152
|
+
build_sub_component(
|
153
|
+
tag || config({ cards: :subtitle }, :h6),
|
154
|
+
:subtitle,
|
155
|
+
args,
|
156
|
+
&block
|
157
|
+
)
|
158
|
+
end
|
159
|
+
|
100
160
|
# Builds a Text component.
|
101
161
|
#
|
102
|
-
# @
|
103
|
-
#
|
104
|
-
#
|
105
|
-
#
|
106
|
-
#
|
162
|
+
# @overload header(tag, opts)
|
163
|
+
# @param [Symbol|String] tag - The HTML element to use.
|
164
|
+
# @param [Hash] options
|
165
|
+
# @option opts [String] :id
|
166
|
+
# @option opts [String] :class
|
167
|
+
# @option opts [Hash] :data
|
168
|
+
#
|
169
|
+
# @overload header(opts)
|
170
|
+
# @param [Hash] options
|
171
|
+
# @option opts [String] :id
|
172
|
+
# @option opts [String] :class
|
173
|
+
# @option opts [Hash] :data
|
174
|
+
#
|
107
175
|
# @return [String]
|
108
176
|
#
|
109
|
-
def text(tag_or_options
|
110
|
-
tag, args = parse_tag_or_options(tag_or_options,
|
177
|
+
def text(*tag_or_options, &block)
|
178
|
+
tag, args = parse_tag_or_options(*tag_or_options, {})
|
111
179
|
build_sub_component(
|
112
180
|
tag || config(:card_text, :p),
|
113
181
|
:text,
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module Bootstrap5Helper
|
2
|
+
class CardWithNavTab < Component # :nodoc:
|
3
|
+
# Class constructor
|
4
|
+
#
|
5
|
+
# @param [ActionView] template
|
6
|
+
# @param [Symbol|String|Hash] type_or_options
|
7
|
+
# @param [Hash] opts
|
8
|
+
# @option opts [String] :id
|
9
|
+
# @option opts [String] :class
|
10
|
+
# @option opts [Hash] :data
|
11
|
+
#
|
12
|
+
def initialize(template, *context_or_options, &block)
|
13
|
+
super(template)
|
14
|
+
@context, args = parse_context_or_options(*context_or_options, {})
|
15
|
+
@id = args.fetch(:id, '')
|
16
|
+
@class = args.fetch(:class, '')
|
17
|
+
@data = args.fetch(:data, nil)
|
18
|
+
@content = block || proc { '' }
|
19
|
+
end
|
20
|
+
|
21
|
+
# Builds a custom Nav component for the tabs.
|
22
|
+
#
|
23
|
+
# @overload nav(tag, opts)
|
24
|
+
# @param [Symbol|String] tag - :nav, :ul
|
25
|
+
# @param [Hash] opts
|
26
|
+
# @option opts [String] :id
|
27
|
+
# @option opts [String] :class
|
28
|
+
# @option opts [Hash] :data
|
29
|
+
# @option opts [Hash] :child - data attributes for child, NOT wrapper
|
30
|
+
#
|
31
|
+
# @overload nav(opts)
|
32
|
+
# @param [Hash] opts
|
33
|
+
# @option opts [String] :id
|
34
|
+
# @option opts [String] :class
|
35
|
+
# @option opts [Hash] :data
|
36
|
+
# @option opts [Hash] :child - data attributes for child, NOT wrapper
|
37
|
+
#
|
38
|
+
# @yield [Nav]
|
39
|
+
# @return [Nav]
|
40
|
+
#
|
41
|
+
def nav(*tag_or_options, &block)
|
42
|
+
tag, args = parse_tag_or_options(*tag_or_options, {})
|
43
|
+
args[:class] = (args[:class] || '') << 'nav-tabs card-header-tabs'
|
44
|
+
args[:data] = (args[:data] || {}).merge('bs-toggle' => 'tab')
|
45
|
+
args[:child] = {
|
46
|
+
data: {
|
47
|
+
'bs-toggle' => 'tab',
|
48
|
+
'bs-display' => 'static'
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
content_tag :div, class: 'card-header' do
|
53
|
+
Nav.new(@template, tag, args, &block).to_s
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Builds the Content object for the Tab.
|
58
|
+
#
|
59
|
+
# @param [Hash] opts
|
60
|
+
# @option opts [String] :id
|
61
|
+
# @option opts [String] :class
|
62
|
+
# @option opts [Hash] :data
|
63
|
+
# @return [Tab::Content]
|
64
|
+
#
|
65
|
+
def content(opts = {}, &block)
|
66
|
+
content_tag :div, class: 'card-body' do
|
67
|
+
Tab::Content.new(@template, opts, &block).to_s
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# @todo
|
72
|
+
#
|
73
|
+
#
|
74
|
+
def to_s
|
75
|
+
content_tag :div, class: "card with-nav-tabs-#{@context}" do
|
76
|
+
@content.call(self)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -10,19 +10,24 @@ module Bootstrap5Helper
|
|
10
10
|
header: :h2,
|
11
11
|
body: :div
|
12
12
|
},
|
13
|
-
badges:
|
13
|
+
badges: {
|
14
|
+
contrast: false,
|
15
|
+
base: :span
|
16
|
+
},
|
14
17
|
callouts: {
|
15
18
|
header: :h4
|
16
19
|
},
|
17
20
|
cards: {
|
18
|
-
header:
|
19
|
-
body:
|
20
|
-
footer:
|
21
|
-
title:
|
22
|
-
|
21
|
+
header: :h5,
|
22
|
+
body: :div,
|
23
|
+
footer: :div,
|
24
|
+
title: :h5,
|
25
|
+
subtitle: :h6,
|
26
|
+
text: :p
|
23
27
|
},
|
24
28
|
dropdowns: {},
|
25
|
-
|
29
|
+
overlay_menus: {
|
30
|
+
base: :div,
|
26
31
|
text: :span,
|
27
32
|
header: :h6,
|
28
33
|
divider: :div
|
@@ -12,8 +12,12 @@ module Bootstrap5Helper
|
|
12
12
|
card
|
13
13
|
callout
|
14
14
|
configuration
|
15
|
+
overlay
|
16
|
+
overlay/menu
|
15
17
|
dropdown
|
16
|
-
|
18
|
+
dropup
|
19
|
+
dropstart
|
20
|
+
dropend
|
17
21
|
input_group
|
18
22
|
modal
|
19
23
|
nav
|
@@ -23,6 +27,7 @@ module Bootstrap5Helper
|
|
23
27
|
spinner
|
24
28
|
tab
|
25
29
|
tab/content
|
30
|
+
card_with_nav_tab
|
26
31
|
].freeze
|
27
32
|
end
|
28
33
|
end
|
@@ -2,120 +2,33 @@ module Bootstrap5Helper
|
|
2
2
|
# Builds a Dropdown component that can be used in other components.
|
3
3
|
#
|
4
4
|
#
|
5
|
-
class Dropdown <
|
5
|
+
class Dropdown < Overlay
|
6
6
|
# Class constructor
|
7
7
|
#
|
8
|
-
# @
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
#
|
33
|
-
# @param [Symbol] context
|
34
|
-
# @param [Hash] opts
|
35
|
-
# @option opts [String] :id
|
36
|
-
# @option opts [String] :class
|
37
|
-
# @option opts [Hash] :data
|
38
|
-
# @option opts [Boolean] :split
|
39
|
-
# @return [String]
|
40
|
-
#
|
41
|
-
def button(context = :primary, opts = {})
|
42
|
-
id = opts.fetch(:id, nil)
|
43
|
-
klass = opts.fetch(:class, '')
|
44
|
-
split = opts.fetch(:split, false)
|
45
|
-
data = opts.fetch(:data, {}).merge('bs-toggle' => 'dropdown')
|
46
|
-
extra = @split ? 'dropdown-toggle-split' : ''
|
47
|
-
|
48
|
-
content_tag(
|
49
|
-
:button,
|
50
|
-
id: id,
|
51
|
-
type: 'button',
|
52
|
-
class: "dropdown-toggle btn btn-#{context} #{klass} #{extra}",
|
53
|
-
data: data,
|
54
|
-
aria: { haspopup: true, expanded: false }
|
55
|
-
) do
|
56
|
-
split ? content_tag(:span, 'Toggle Dropdown', class: 'visually-hidden') : yield
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
# Used to create a new `Dropdown::Menu`
|
61
|
-
#
|
62
|
-
# @param [Hash] opts
|
63
|
-
# @option opts [String] :id
|
64
|
-
# @option opts [String] :class
|
65
|
-
# @option opts [Hash] :data
|
66
|
-
# @return [Dropdown::Menu]
|
67
|
-
#
|
68
|
-
def menu(opts = {}, &block)
|
69
|
-
Menu.new(@template, opts, &block)
|
70
|
-
end
|
71
|
-
|
72
|
-
# String reprentation of the object.
|
73
|
-
#
|
74
|
-
# @return [String]
|
75
|
-
#
|
76
|
-
def to_s
|
77
|
-
content_tag(
|
78
|
-
:div,
|
79
|
-
id: @id,
|
80
|
-
class: "#{element_type_class} #{alignment_type_class} #{@class}",
|
81
|
-
data: @data
|
82
|
-
) do
|
83
|
-
@content.call(self)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
private
|
88
|
-
|
89
|
-
# Returns the container class for the dropdown component.
|
90
|
-
#
|
91
|
-
# @return [String]
|
92
|
-
#
|
93
|
-
def element_type_class
|
94
|
-
case @type
|
95
|
-
when :dropdown
|
96
|
-
'dropdown'
|
97
|
-
when :dropup
|
98
|
-
'dropup'
|
99
|
-
when :dropstart
|
100
|
-
'dropstart'
|
101
|
-
when :dropend
|
102
|
-
'dropend'
|
103
|
-
else
|
104
|
-
''
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
# Returns the alignment class for the dropdown component.
|
109
|
-
#
|
110
|
-
# @return [String]
|
111
|
-
#
|
112
|
-
def alignment_type_class
|
113
|
-
case @type
|
114
|
-
when :dropdown, :dropup
|
115
|
-
@centered ? "#{element_type_class}-center" : ''
|
116
|
-
else
|
117
|
-
''
|
118
|
-
end
|
8
|
+
# @overload initialize(template, tag, opts)
|
9
|
+
# @param [ActionView] template
|
10
|
+
# @param [Symbol|String] tag - The HTML element to use to wrap the component.
|
11
|
+
# @param [Hash] opts
|
12
|
+
# @option opts [String] :id
|
13
|
+
# @option opts [String] :class
|
14
|
+
# @option opts [Hash] :data
|
15
|
+
# @option opts [Boolea] :split
|
16
|
+
# @option opts [Boolean] :centered
|
17
|
+
#
|
18
|
+
# @overload initialize(template, opts)
|
19
|
+
# @param [ActionView] template
|
20
|
+
# @param [Hash] opts
|
21
|
+
# @option opts [String] :id
|
22
|
+
# @option opts [String] :class
|
23
|
+
# @option opts [Hash] :data
|
24
|
+
# @option opts [Boolea] :split
|
25
|
+
# @option opts [Boolean] :centered
|
26
|
+
#
|
27
|
+
# @return [Dropdown]
|
28
|
+
#
|
29
|
+
def initialize(template, *tag_or_options, &block)
|
30
|
+
super(template, *tag_or_options, &block)
|
31
|
+
@type = :dropdown
|
119
32
|
end
|
120
33
|
end
|
121
34
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Bootstrap5Helper
|
2
|
+
# Builds a Dropdown component that can be used in other components.
|
3
|
+
#
|
4
|
+
#
|
5
|
+
class Dropend < Overlay
|
6
|
+
# Class constructor
|
7
|
+
#
|
8
|
+
# @overload initialize(template, tag, opts)
|
9
|
+
# @param [ActionView] template
|
10
|
+
# @param [Symbol|String] tag - The HTML element to use to wrap the component.
|
11
|
+
# @param [Hash] opts
|
12
|
+
# @option opts [String] :id
|
13
|
+
# @option opts [String] :class
|
14
|
+
# @option opts [Hash] :data
|
15
|
+
# @option opts [Boolea] :split
|
16
|
+
# @option opts [Boolean] :centered
|
17
|
+
#
|
18
|
+
# @overload initialize(template, opts)
|
19
|
+
# @param [ActionView] template
|
20
|
+
# @param [Hash] opts
|
21
|
+
# @option opts [String] :id
|
22
|
+
# @option opts [String] :class
|
23
|
+
# @option opts [Hash] :data
|
24
|
+
# @option opts [Boolea] :split
|
25
|
+
# @option opts [Boolean] :centered
|
26
|
+
#
|
27
|
+
# @return [Dropend]
|
28
|
+
#
|
29
|
+
def initialize(template, *tag_or_options, &block)
|
30
|
+
super(template, *tag_or_options, &block)
|
31
|
+
@type = :dropend
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Bootstrap5Helper
|
2
|
+
# Builds a Dropdown component that can be used in other components.
|
3
|
+
#
|
4
|
+
#
|
5
|
+
class Dropstart < Overlay
|
6
|
+
# Class constructor
|
7
|
+
#
|
8
|
+
# @overload initialize(template, tag, opts)
|
9
|
+
# @param [ActionView] template
|
10
|
+
# @param [Symbol|String] tag - The HTML element to use to wrap the component.
|
11
|
+
# @param [Hash] opts
|
12
|
+
# @option opts [String] :id
|
13
|
+
# @option opts [String] :class
|
14
|
+
# @option opts [Hash] :data
|
15
|
+
# @option opts [Boolea] :split
|
16
|
+
# @option opts [Boolean] :centered
|
17
|
+
#
|
18
|
+
# @overload initialize(template, opts)
|
19
|
+
# @param [ActionView] template
|
20
|
+
# @param [Hash] opts
|
21
|
+
# @option opts [String] :id
|
22
|
+
# @option opts [String] :class
|
23
|
+
# @option opts [Hash] :data
|
24
|
+
# @option opts [Boolea] :split
|
25
|
+
# @option opts [Boolean] :centered
|
26
|
+
#
|
27
|
+
# @return [Dropstart]
|
28
|
+
#
|
29
|
+
def initialize(template, *tag_or_options, &block)
|
30
|
+
super(template, *tag_or_options, &block)
|
31
|
+
@type = :dropstart
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|