bootstrap4_helper 1.1.1 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5955ec587e3cd9c46b93382fdbfefdb8e19283307e266e3d0d40ff60378c78f5
4
- data.tar.gz: 9c6dd4decbd54700ca73bbfc2372fc78360218a6b5fa3b8a21ee08e5b1d39058
3
+ metadata.gz: 4a23f132c519e3621ae8a9ce0c6b9cdd4a253ec17377cd5dee9874993140e7f0
4
+ data.tar.gz: 72d27fda2a64db784d5bd8f248f4a59d9ce8621d01ba98007f262ffa66873478
5
5
  SHA512:
6
- metadata.gz: 86c09350eb4ed4514d1aa07d1346617920d99c9164e426f1d43c767539a4cd952f86674d4e14c506c3d911c7e0c1998ab0dce41c8ce4f710268b58d874dbb7c6
7
- data.tar.gz: 76dd20e7db8086165f1b78c97ebc4de3465db2b44393f847439a1da2ef60a95e1be4a180f6e73da7eb5a16f998604b889b8c613b3e1699f8423f424d7ab6a3ae
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] :id
19
- # @option opts [String] :class
20
- # @option opts [Hash] :data
21
- # @option opts [String] :parent
22
- # @option opts [String] :target
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 = opts.fetch(:id, uuid)
28
- @class = opts.fetch(:class, '')
29
- @data = opts.fetch(:data, {})
30
- @parent = opts.fetch(:parent, nil)
31
- @target = @data.fetch(:target, uuid)
32
- @content = block || proc { '' }
33
- @card = Card.new(@template)
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 = { parent: "##{@parent}" } if @parent.present?
65
+ data = { parent: "##{@parent}" } if @parent.present?
66
+ klass = 'collapse'
67
+ klass += ' show' if @expanded
65
68
 
66
- content_tag :div, id: @target, class: 'collapse', data: data do
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
@@ -17,6 +17,7 @@ module Bootstrap4Helper
17
17
  configuration
18
18
  dropdown
19
19
  dropdown/menu
20
+ input_group
20
21
  modal
21
22
  nav
22
23
  page_header
@@ -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: 'button',
88
+ type: 'button',
87
89
  class: block_given? ? klass : 'close',
88
- data: { dismiss: 'modal' },
89
- aria: { label: 'Close' }
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: id,
138
+ id: id,
137
139
  class: "modal-#{type} #{klass}",
138
- data: 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: @id,
31
+ @type || config(:page_header, :h1),
32
+ id: @id,
31
33
  class: "pb-2 mt-4 mb-2 border-bottom #{@class}",
32
- data: @data
34
+ data: @data
33
35
  ) do
34
36
  @content.call(self)
35
37
  end
@@ -1,3 +1,3 @@
1
1
  module Bootstrap4Helper
2
- VERSION = '1.1.1'.freeze
2
+ VERSION = '1.2.3'.freeze
3
3
  end
@@ -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.1.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: 2020-07-16 00:00:00.000000000 Z
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.4
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.4
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.3
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