bootstrap4_helper 1.1.1 → 1.2.3
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/accordion.rb +20 -17
- data/lib/bootstrap4_helper/constants.rb +1 -0
- data/lib/bootstrap4_helper/input_group.rb +54 -0
- data/lib/bootstrap4_helper/modal.rb +25 -6
- data/lib/bootstrap4_helper/page_header.rb +5 -3
- data/lib/bootstrap4_helper/version.rb +1 -1
- data/lib/bootstrap4_helper.rb +24 -0
- metadata +20 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a23f132c519e3621ae8a9ce0c6b9cdd4a253ec17377cd5dee9874993140e7f0
|
4
|
+
data.tar.gz: 72d27fda2a64db784d5bd8f248f4a59d9ce8621d01ba98007f262ffa66873478
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f487e7dcbbe737c7ca67ae673234e71003262974d692dcf7e3eaad45d0efc4b888183e4ae51c72b28ce1e9ce436880889c7ee5b2dd3694c48d42e50c3f10e01b
|
7
|
+
data.tar.gz: 9437852eaf93cac4e7769f7f04359a86233a122f231ba78db1540e8e4cf9803325d856a2ba9175e33a2b650c5cfc4b252d8bb5d85145c11845b902dba72554d0
|
@@ -11,26 +11,27 @@ module Bootstrap4Helper
|
|
11
11
|
].freeze
|
12
12
|
|
13
13
|
# Class constructor
|
14
|
-
# -
|
15
14
|
#
|
16
15
|
# @param [ActionView] template
|
17
16
|
# @param [Hash] opts
|
18
|
-
# @option opts [String]
|
19
|
-
# @option opts [String]
|
20
|
-
# @option opts [Hash]
|
21
|
-
# @option opts [String]
|
22
|
-
# @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
|
23
23
|
#
|
24
24
|
def initialize(template, opts = {}, &block)
|
25
25
|
super(template)
|
26
26
|
|
27
|
-
@id
|
28
|
-
@class
|
29
|
-
@data
|
30
|
-
@parent
|
31
|
-
@
|
32
|
-
@
|
33
|
-
@
|
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)
|
34
35
|
end
|
35
36
|
|
36
37
|
# Builds a header component for the accordion, which is actually the header
|
@@ -61,9 +62,11 @@ module Bootstrap4Helper
|
|
61
62
|
# @return [String]
|
62
63
|
#
|
63
64
|
def body(opts = {}, &block)
|
64
|
-
data
|
65
|
+
data = { parent: "##{@parent}" } if @parent.present?
|
66
|
+
klass = 'collapse'
|
67
|
+
klass += ' show' if @expanded
|
65
68
|
|
66
|
-
content_tag :div, id: @target, class:
|
69
|
+
content_tag :div, id: @target, class: klass, data: data do
|
67
70
|
@card.body(opts, &block)
|
68
71
|
end
|
69
72
|
end
|
@@ -83,7 +86,7 @@ module Bootstrap4Helper
|
|
83
86
|
end
|
84
87
|
end
|
85
88
|
|
86
|
-
# Checks if the Object reponds to missing.
|
89
|
+
# Checks if the Object reponds to missing.
|
87
90
|
#
|
88
91
|
#
|
89
92
|
def respond_to_missing?(method, include_private = false)
|
@@ -96,7 +99,7 @@ module Bootstrap4Helper
|
|
96
99
|
# @return [String]
|
97
100
|
#
|
98
101
|
def to_s
|
99
|
-
content_tag :div, class: "card #{@class}", data: @data do
|
102
|
+
content_tag :div, id: @id, class: "card #{@class}", data: @data.except(:target) do
|
100
103
|
@content.call(self)
|
101
104
|
end
|
102
105
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Bootstrap4Helper
|
2
|
+
# The InputGroup helper is meant to help you rapidly build Bootstrap input
|
3
|
+
# group components quickly and easily.
|
4
|
+
#
|
5
|
+
class InputGroup < Component
|
6
|
+
VALID_TYPES = %i[append prepend].freeze
|
7
|
+
|
8
|
+
# Class constructor
|
9
|
+
#
|
10
|
+
# @param [Class] template - Template in which your are binding too.
|
11
|
+
# @param [Symbol] type - Whether the component is prepend or append.
|
12
|
+
# @param [Hash] opts
|
13
|
+
# @return [InputGroup]
|
14
|
+
#
|
15
|
+
def initialize(template, type = :prepend, opts = {}, &block)
|
16
|
+
super(template)
|
17
|
+
|
18
|
+
@type = VALID_TYPES.include?(type) ? type : :prepend
|
19
|
+
@id = opts.fetch(:id, nil)
|
20
|
+
@class = opts.fetch(:class, '')
|
21
|
+
@data = opts.fetch(:data, {})
|
22
|
+
@content = block || proc { '' }
|
23
|
+
end
|
24
|
+
|
25
|
+
# This is the element that actually houses the icon or text used
|
26
|
+
# in the input group.
|
27
|
+
#
|
28
|
+
# @param [Hash] opts
|
29
|
+
# @return [String]
|
30
|
+
#
|
31
|
+
def text(opts = {}, &block)
|
32
|
+
opts[:class] = (opts[:class] || '') << " input-group-#{@type}"
|
33
|
+
|
34
|
+
content_tag :div, opts do
|
35
|
+
content_tag :span, class: 'input-group-text', &block
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Used to render out the InputGroup component.
|
40
|
+
#
|
41
|
+
# @return [String]
|
42
|
+
#
|
43
|
+
def to_s
|
44
|
+
content_tag(
|
45
|
+
:div,
|
46
|
+
id: @id,
|
47
|
+
class: "input-group #{@class}",
|
48
|
+
data: @data
|
49
|
+
) do
|
50
|
+
@content.call(self)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
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
|
@@ -7,6 +7,7 @@ module Bootstrap4Helper
|
|
7
7
|
#
|
8
8
|
# @param [ActionView] template
|
9
9
|
# @param [Hash] opts
|
10
|
+
# @option opts [symbol] :type
|
10
11
|
# @option opts [String] :id
|
11
12
|
# @option opts [String] :class
|
12
13
|
# @option opts [Hash] :data
|
@@ -14,6 +15,7 @@ module Bootstrap4Helper
|
|
14
15
|
def initialize(template, opts = {}, &block)
|
15
16
|
super(template)
|
16
17
|
|
18
|
+
@type = opts.fetch(:type, nil)
|
17
19
|
@id = opts.fetch(:id, uuid)
|
18
20
|
@class = opts.fetch(:class, '')
|
19
21
|
@data = opts.fetch(:data, {})
|
@@ -26,10 +28,10 @@ module Bootstrap4Helper
|
|
26
28
|
#
|
27
29
|
def to_s
|
28
30
|
content_tag(
|
29
|
-
config(:page_header, :h1),
|
30
|
-
id:
|
31
|
+
@type || config(:page_header, :h1),
|
32
|
+
id: @id,
|
31
33
|
class: "pb-2 mt-4 mb-2 border-bottom #{@class}",
|
32
|
-
data:
|
34
|
+
data: @data
|
33
35
|
) do
|
34
36
|
@content.call(self)
|
35
37
|
end
|
data/lib/bootstrap4_helper.rb
CHANGED
@@ -457,6 +457,30 @@ module Bootstrap4Helper
|
|
457
457
|
PageHeader.new(self, opts, &block)
|
458
458
|
end
|
459
459
|
|
460
|
+
# Generates a input group component.
|
461
|
+
#
|
462
|
+
# ```erb
|
463
|
+
# <%= input_group_helper do |ig| %>
|
464
|
+
# <%= ig.text do %>
|
465
|
+
# <i class="fas fa-at"></i>
|
466
|
+
# <% end %>
|
467
|
+
# <input type="text" value="" name="email" placeholder="Email" class="form-control" />
|
468
|
+
# <% end %>
|
469
|
+
#
|
470
|
+
# <%= input_group_helper :append do |ig| %>
|
471
|
+
# <input type="text" value="" name="email" placeholder="Email" class="form-control" />
|
472
|
+
# <%= ig.text { "@" } %>
|
473
|
+
# <% end %>
|
474
|
+
# ```
|
475
|
+
#
|
476
|
+
# @param [Symbol] type
|
477
|
+
# @param [Hash] opts
|
478
|
+
# @return [String]
|
479
|
+
#
|
480
|
+
def input_group_helper(type = :prepend, opts = {}, &block)
|
481
|
+
InputGroup.new(self, type, opts, &block)
|
482
|
+
end
|
483
|
+
|
460
484
|
# Generates a Tab component.
|
461
485
|
#
|
462
486
|
# ```erb
|
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.3
|
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-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -44,6 +44,20 @@ dependencies:
|
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: 4.3.1
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: font-awesome-sass
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
47
61
|
- !ruby/object:Gem::Dependency
|
48
62
|
name: jquery-rails
|
49
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -64,14 +78,14 @@ dependencies:
|
|
64
78
|
requirements:
|
65
79
|
- - "~>"
|
66
80
|
- !ruby/object:Gem::Version
|
67
|
-
version: 5.2
|
81
|
+
version: '5.2'
|
68
82
|
type: :development
|
69
83
|
prerelease: false
|
70
84
|
version_requirements: !ruby/object:Gem::Requirement
|
71
85
|
requirements:
|
72
86
|
- - "~>"
|
73
87
|
- !ruby/object:Gem::Version
|
74
|
-
version: 5.2
|
88
|
+
version: '5.2'
|
75
89
|
- !ruby/object:Gem::Dependency
|
76
90
|
name: redcarpet
|
77
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -154,6 +168,7 @@ files:
|
|
154
168
|
- lib/bootstrap4_helper/dropdown.rb
|
155
169
|
- lib/bootstrap4_helper/dropdown/menu.rb
|
156
170
|
- lib/bootstrap4_helper/initialize.rb
|
171
|
+
- lib/bootstrap4_helper/input_group.rb
|
157
172
|
- lib/bootstrap4_helper/modal.rb
|
158
173
|
- lib/bootstrap4_helper/nav.rb
|
159
174
|
- lib/bootstrap4_helper/page_header.rb
|
@@ -182,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
197
|
- !ruby/object:Gem::Version
|
183
198
|
version: '0'
|
184
199
|
requirements: []
|
185
|
-
rubygems_version: 3.1
|
200
|
+
rubygems_version: 3.0.1
|
186
201
|
signing_key:
|
187
202
|
specification_version: 4
|
188
203
|
summary: Library for rapidly building bootstrap 4 components
|