bootstrap4_helper 1.0.4 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- 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 +40 -0
- 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: c35ca44f120427c65ccdf083ee5a0fbf7c39a2457e2e6f37b652afba0d0495fa
|
4
|
+
data.tar.gz: 3d793601d6c68ab812508002ff3d1725d3b8e01a33b49304d87f3a351cf796f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10eacd735ea5520e0096569a6b48d6234bf106d4f7d92d4b85ebcb11389b5d0df61b0b7684fd0641decbb27ff21ba27792eaa158fb730f95bd814d8a5fbbb9d1
|
7
|
+
data.tar.gz: 457595afdaee9a6d10db19026332f2cab1b5538fabc24b8fb5633ba7d4a5332a96a8baea97a0a9cd1f0b5daa81738a34211243e400d2efed6775ad56ef5b5273
|
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,40 @@
|
|
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 [symbol] :type
|
11
|
+
# @option opts [String] :id
|
12
|
+
# @option opts [String] :class
|
13
|
+
# @option opts [Hash] :data
|
14
|
+
#
|
15
|
+
def initialize(template, opts = {}, &block)
|
16
|
+
super(template)
|
17
|
+
|
18
|
+
@type = opts.fetch(:type, nil)
|
19
|
+
@id = opts.fetch(:id, uuid)
|
20
|
+
@class = opts.fetch(:class, '')
|
21
|
+
@data = opts.fetch(:data, {})
|
22
|
+
@content = block || proc { '' }
|
23
|
+
end
|
24
|
+
|
25
|
+
# String representation of the object.
|
26
|
+
#
|
27
|
+
# @return [String]
|
28
|
+
#
|
29
|
+
def to_s
|
30
|
+
content_tag(
|
31
|
+
@type || config(:page_header, :h1),
|
32
|
+
id: @id,
|
33
|
+
class: "pb-2 mt-4 mb-2 border-bottom #{@class}",
|
34
|
+
data: @data
|
35
|
+
) do
|
36
|
+
@content.call(self)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
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.2
|
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-07-08 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
|