bootstrap4_helper 1.0.3 → 1.2.1
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/bootstrap4_helper.rb +9 -0
- data/lib/bootstrap4_helper/accordion.rb +21 -17
- data/lib/bootstrap4_helper/configuration.rb +2 -1
- data/lib/bootstrap4_helper/constants.rb +1 -0
- data/lib/bootstrap4_helper/modal.rb +25 -6
- data/lib/bootstrap4_helper/page_header.rb +38 -0
- data/lib/bootstrap4_helper/tab/content.rb +3 -2
- data/lib/bootstrap4_helper/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 201fec26b2a05fac10b958a08380937f58b38be45b6b67f90352c12871769206
|
4
|
+
data.tar.gz: f171f43fdb7db816c1761cf0e6c2826acaa2f0b69c78a6169f1c936bca397e1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a63ba3c1dae1b90cc9536696475891621305c5025fbb1ed6a7ab64a6f3ea9c7b6a2ef58f773c1823c3037f0690c73331afb71daddfd480b3f63a96371732bae
|
7
|
+
data.tar.gz: 8978545cf5212adfea6062ac7d34f7fd245f556128bdeae01d753fc1c7832c11e48855974498b6034a63238005b25f3609e5ee2ae8feb09f1c4c2ca2f0f955a3
|
data/lib/bootstrap4_helper.rb
CHANGED
@@ -448,6 +448,15 @@ module Bootstrap4Helper
|
|
448
448
|
Nav.new(self, opts, &block)
|
449
449
|
end
|
450
450
|
|
451
|
+
# Generates a page header, similiar to bootstrap 3
|
452
|
+
#
|
453
|
+
# @param [Hash] opts
|
454
|
+
# @return [String]
|
455
|
+
#
|
456
|
+
def page_header_helper(opts = {}, &block)
|
457
|
+
PageHeader.new(self, opts, &block)
|
458
|
+
end
|
459
|
+
|
451
460
|
# Generates a Tab component.
|
452
461
|
#
|
453
462
|
# ```erb
|
@@ -7,29 +7,31 @@ module Bootstrap4Helper
|
|
7
7
|
title
|
8
8
|
text
|
9
9
|
image_overlay
|
10
|
+
footer
|
10
11
|
].freeze
|
11
12
|
|
12
13
|
# Class constructor
|
13
|
-
# -
|
14
14
|
#
|
15
15
|
# @param [ActionView] template
|
16
16
|
# @param [Hash] opts
|
17
|
-
# @option opts [String]
|
18
|
-
# @option opts [String]
|
19
|
-
# @option opts [Hash]
|
20
|
-
# @option opts [String]
|
21
|
-
# @option opts [String]
|
17
|
+
# @option opts [String] :id
|
18
|
+
# @option opts [String] :class
|
19
|
+
# @option opts [Hash] :data
|
20
|
+
# @option opts [String] :parent
|
21
|
+
# @option opts [String] :target
|
22
|
+
# @option opts [Boolean] :expanded
|
22
23
|
#
|
23
24
|
def initialize(template, opts = {}, &block)
|
24
25
|
super(template)
|
25
26
|
|
26
|
-
@id
|
27
|
-
@class
|
28
|
-
@data
|
29
|
-
@parent
|
30
|
-
@
|
31
|
-
@
|
32
|
-
@
|
27
|
+
@id = opts.fetch(:id, uuid)
|
28
|
+
@class = opts.fetch(:class, '')
|
29
|
+
@data = opts.fetch(:data, {})
|
30
|
+
@parent = opts.fetch(:parent, nil)
|
31
|
+
@expanded = opts.fetch(:expanded, false)
|
32
|
+
@target = @data.fetch(:target, uuid)
|
33
|
+
@content = block || proc { '' }
|
34
|
+
@card = Card.new(@template)
|
33
35
|
end
|
34
36
|
|
35
37
|
# Builds a header component for the accordion, which is actually the header
|
@@ -60,9 +62,11 @@ module Bootstrap4Helper
|
|
60
62
|
# @return [String]
|
61
63
|
#
|
62
64
|
def body(opts = {}, &block)
|
63
|
-
data
|
65
|
+
data = { parent: "##{@parent}" } if @parent.present?
|
66
|
+
klass = 'collapse'
|
67
|
+
klass += ' show' if @expanded
|
64
68
|
|
65
|
-
content_tag :div, id: @target, class:
|
69
|
+
content_tag :div, id: @target, class: klass, data: data do
|
66
70
|
@card.body(opts, &block)
|
67
71
|
end
|
68
72
|
end
|
@@ -82,7 +86,7 @@ module Bootstrap4Helper
|
|
82
86
|
end
|
83
87
|
end
|
84
88
|
|
85
|
-
# Checks if the Object reponds to missing.
|
89
|
+
# Checks if the Object reponds to missing.
|
86
90
|
#
|
87
91
|
#
|
88
92
|
def respond_to_missing?(method, include_private = false)
|
@@ -95,7 +99,7 @@ module Bootstrap4Helper
|
|
95
99
|
# @return [String]
|
96
100
|
#
|
97
101
|
def to_s
|
98
|
-
content_tag :div, class: "card #{@class}", data: @data do
|
102
|
+
content_tag :div, id: @id, class: "card #{@class}", data: @data.except(:target) do
|
99
103
|
@content.call(self)
|
100
104
|
end
|
101
105
|
end
|
@@ -12,6 +12,7 @@ module Bootstrap4Helper
|
|
12
12
|
# @option opts [Hash] :data
|
13
13
|
# @option opts [Boolean] :scrollable
|
14
14
|
# @option opts [Boolean] :vcentered
|
15
|
+
# @option opts [Symbol] :size
|
15
16
|
#
|
16
17
|
def initialize(template, opts = {}, &block)
|
17
18
|
super(template)
|
@@ -21,6 +22,7 @@ module Bootstrap4Helper
|
|
21
22
|
@data = opts.fetch(:data, {})
|
22
23
|
@scrollable = opts.fetch(:scrollable, false)
|
23
24
|
@vcentered = opts.fetch(:vcentered, false)
|
25
|
+
@size = opts.fetch(:size, nil)
|
24
26
|
@content = block || proc { '' }
|
25
27
|
end
|
26
28
|
|
@@ -83,10 +85,10 @@ module Bootstrap4Helper
|
|
83
85
|
|
84
86
|
content_tag(
|
85
87
|
:button,
|
86
|
-
type:
|
88
|
+
type: 'button',
|
87
89
|
class: block_given? ? klass : 'close',
|
88
|
-
data:
|
89
|
-
aria:
|
90
|
+
data: { dismiss: 'modal' },
|
91
|
+
aria: { label: 'Close' }
|
90
92
|
) do
|
91
93
|
block_given? ? yield : xbutton
|
92
94
|
end
|
@@ -98,7 +100,7 @@ module Bootstrap4Helper
|
|
98
100
|
#
|
99
101
|
def to_s
|
100
102
|
content_tag :div, id: @id, class: "modal #{@class}", tabindex: -1, role: 'dialog', data: @data do
|
101
|
-
content_tag :div, class: "modal-dialog #{scrollable} #{vcentered}", role: 'document' do
|
103
|
+
content_tag :div, class: "modal-dialog #{size} #{scrollable} #{vcentered}", role: 'document' do
|
102
104
|
content_tag(:div, class: 'modal-content') { @content.call(self) }
|
103
105
|
end
|
104
106
|
end
|
@@ -133,9 +135,9 @@ module Bootstrap4Helper
|
|
133
135
|
|
134
136
|
content_tag(
|
135
137
|
tag,
|
136
|
-
id:
|
138
|
+
id: id,
|
137
139
|
class: "modal-#{type} #{klass}",
|
138
|
-
data:
|
140
|
+
data: data,
|
139
141
|
&block
|
140
142
|
)
|
141
143
|
end
|
@@ -163,5 +165,22 @@ module Bootstrap4Helper
|
|
163
165
|
def vcentered
|
164
166
|
@vcentered ? 'modal-dialog-centered' : ''
|
165
167
|
end
|
168
|
+
|
169
|
+
# Gets the size of the modal window.
|
170
|
+
#
|
171
|
+
# @return [String]
|
172
|
+
#
|
173
|
+
def size
|
174
|
+
case @size
|
175
|
+
when :xlarge
|
176
|
+
'modal-xl'
|
177
|
+
when :large
|
178
|
+
'modal-lg'
|
179
|
+
when :small
|
180
|
+
'modal-sm'
|
181
|
+
else
|
182
|
+
''
|
183
|
+
end
|
184
|
+
end
|
166
185
|
end
|
167
186
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Bootstrap4Helper
|
2
|
+
# Builds a simple CSS spinner component.
|
3
|
+
#
|
4
|
+
#
|
5
|
+
class PageHeader < Component
|
6
|
+
# Class constructor
|
7
|
+
#
|
8
|
+
# @param [ActionView] template
|
9
|
+
# @param [Hash] opts
|
10
|
+
# @option opts [String] :id
|
11
|
+
# @option opts [String] :class
|
12
|
+
# @option opts [Hash] :data
|
13
|
+
#
|
14
|
+
def initialize(template, opts = {}, &block)
|
15
|
+
super(template)
|
16
|
+
|
17
|
+
@id = opts.fetch(:id, uuid)
|
18
|
+
@class = opts.fetch(:class, '')
|
19
|
+
@data = opts.fetch(:data, {})
|
20
|
+
@content = block || proc { '' }
|
21
|
+
end
|
22
|
+
|
23
|
+
# String representation of the object.
|
24
|
+
#
|
25
|
+
# @return [String]
|
26
|
+
#
|
27
|
+
def to_s
|
28
|
+
content_tag(
|
29
|
+
config(:page_header, :h1),
|
30
|
+
id: @id,
|
31
|
+
class: "pb-2 mt-4 mb-2 border-bottom #{@class}",
|
32
|
+
data: @data
|
33
|
+
) do
|
34
|
+
@content.call(self)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -24,18 +24,19 @@ module Bootstrap4Helper
|
|
24
24
|
# Builds the pane for the tab.
|
25
25
|
#
|
26
26
|
# @param [Symbol] source
|
27
|
-
# @param [Hash]
|
27
|
+
# @param [Hash] opts
|
28
28
|
# @option opts [String] :class
|
29
29
|
# @option opts [Hash] :data
|
30
30
|
# @return [String]
|
31
31
|
#
|
32
32
|
def pane(source, opts = {}, &block)
|
33
|
+
id = opts.fetch(:id, source)
|
33
34
|
klass = opts.fetch(:class, '')
|
34
35
|
data = opts.fetch(:data, {})
|
35
36
|
|
36
37
|
content_tag(
|
37
38
|
:div,
|
38
|
-
id:
|
39
|
+
id: id,
|
39
40
|
class: "tab-pane #{klass}",
|
40
41
|
role: 'tabpanel',
|
41
42
|
data: data,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstrap4_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert David
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -156,6 +156,7 @@ files:
|
|
156
156
|
- lib/bootstrap4_helper/initialize.rb
|
157
157
|
- lib/bootstrap4_helper/modal.rb
|
158
158
|
- lib/bootstrap4_helper/nav.rb
|
159
|
+
- lib/bootstrap4_helper/page_header.rb
|
159
160
|
- lib/bootstrap4_helper/railtie.rb
|
160
161
|
- lib/bootstrap4_helper/spinner.rb
|
161
162
|
- lib/bootstrap4_helper/tab.rb
|
@@ -181,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
182
|
- !ruby/object:Gem::Version
|
182
183
|
version: '0'
|
183
184
|
requirements: []
|
184
|
-
rubygems_version: 3.1
|
185
|
+
rubygems_version: 3.0.1
|
185
186
|
signing_key:
|
186
187
|
specification_version: 4
|
187
188
|
summary: Library for rapidly building bootstrap 4 components
|