bootstrap5_helper 1.1.1 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 69fbf952577b44a22763e9f054dc768bb4a1ad7d2f47ba094dda42612dc2f5b7
4
- data.tar.gz: 2d656ebf99bc33d65e49c4ef2f661266958e31366fdfb7730dc9ed08cc782996
3
+ metadata.gz: 19522a2350e79f5f8dc104a998c2af7da568feb05de8747adc3b2a530eb86ccc
4
+ data.tar.gz: 15c5cd096185cff3d04305451d10551541eb6abdaaf2fe8886dc0828d212ae67
5
5
  SHA512:
6
- metadata.gz: aab79e3287bea1f7cbb4d5ddd761840691d8cc319aa6eddfc89d5b87a5aedfe8ff8ce2ad271b75d6155a6e58586c305fb04db88bdfdaca240c9b3375663bca69
7
- data.tar.gz: 992edacb8fd535b478cf3e4cfbf1191425d62ea9cf4b7093ce4a374fcb041feb294f96a21e252b2d14f9323b73cc863fe3869a542adad395917d1e3f87a76ac2
6
+ metadata.gz: cbfadc39eb05885160db4b02a115f984c82d4a434568a777e891fe16ea2d484330a6713944c95a4736d347b1f3c9edb1734764289e404e364f1059f8bb57a1bd
7
+ data.tar.gz: 565e02e9240376cdbb95a5dfc43eaf034a1af210d041269085b99ddac8f3a87cd38d732e87b4d3f3739d96dde35507ec658d4c0abf8de72b6b96c0a71bc61f1a
data/README.md CHANGED
@@ -49,11 +49,10 @@ end
49
49
  # @option opts [Hash] :data
50
50
  # @option opts [Boolean] :always_open
51
51
  # @option opts [Boolean] :flush
52
+ # @yield [Accordion]
52
53
  # @return [Accordion]
53
54
  #
54
- def accordion_helper(opts = {}, &block)
55
- Accordion.new(self, opts, &block)
56
- end
55
+ accordion_helper(opts = {}, &block)
57
56
  ```
58
57
 
59
58
  #### Example:
@@ -99,9 +98,7 @@ Alerts use the context helper, where you can pass the context of the object and
99
98
  #
100
99
  # @return [String]
101
100
  #
102
- def alert_helper(*args, &block)
103
- Alert.new(self, *args, &block)
104
- end
101
+ alert_helper(*args, &block)
105
102
  ```
106
103
 
107
104
  #### Example:
@@ -132,9 +129,7 @@ The badge helper will build badges realitively quickly. If you are just passing
132
129
  #
133
130
  # @return [String]
134
131
  #
135
- def badge_helper(*args, &block)
136
- Badge.new(self, *args, &block)
137
- end
132
+ badge_helper(*args, &block)
138
133
  ```
139
134
 
140
135
  #### Example
@@ -164,18 +159,15 @@ Cards support a few methods that make building them easier:
164
159
  - `text`
165
160
  - `title`
166
161
 
167
- For usage on various card sub components, @see https://getbootstrap.com/docs/4.0/components/card/
168
-
169
162
  ```ruby
170
163
  # @param [Hash] opts
171
164
  # @option opts [String] :id
172
165
  # @option opts [String] :class
173
166
  # @option opts [Hash] :data
174
- # @return [String]
167
+ # @yield [Card]
168
+ # @return [Card]
175
169
  #
176
- def card_helper(opts = {}, &block)
177
- Card.new(self, opts, &block)
178
- end
170
+ card_helper(opts = {}, &block)
179
171
  ```
180
172
 
181
173
  #### Example
@@ -236,79 +228,70 @@ Dropdowns support the following methods:
236
228
  - `divider` - A dividing element
237
229
 
238
230
  ```ruby
239
- # @overload dropdown_helper(type, opts)
240
- # @param [Symbol|String] type - :dropdown, :dropup, :dropstart, :dropend
241
- # @param [Hash] opts
231
+ # @overload dropdown_helper(tag, opts)
232
+ # @param [Symbol|String] tag - The HTML element to use to wrap the component.
233
+ # @param [Hash] opts
242
234
  # @option opts [String] :id
243
235
  # @option opts [String] :class
244
236
  # @option opts [Hash] :data
245
- # @option opts [Boolean] :split
237
+ # @option opts [Boolean] :centered
246
238
  #
247
- # @overload dropdown(opts)
248
- # @param [Hash] opts
239
+ # @overload dropdown_helper(opts)
240
+ # @param [Hash] opts
249
241
  # @option opts [String] :id
250
242
  # @option opts [String] :class
251
243
  # @option opts [Hash] :data
252
- # @option opts [Boolean] :split
244
+ # @option opts [Boolean] :centered
253
245
  #
254
- # @return [String]
246
+ # @yield [Dropdown]
247
+ # @return [Dropdown]
255
248
  #
256
- def dropdown_helper(*args, &block)
257
- Dropdown.new(self, *args, &block)
258
- end
249
+ dropdown_helper(*args, &block)
259
250
  ```
260
251
 
261
252
  #### Example
262
253
 
263
254
  ```erb
264
- <%= dropdown_helper do |dropdown| %>
265
- <%= dropdown.button(:primary) { "Action" } %>
266
- <%= dropdown.menu do |menu| %>
267
- <%= menu.link 'Edit', '#' %>
268
- <%= menu.link 'Delete', '#' %>
269
- <%= menu.text 'Static text' %>
270
- <% end %>
255
+ <%= dropdown_helper class: "btn-group" do |dropdown| %>
256
+ <button type="button" class="btn btn-primary">Dropdown</button>
257
+ <%= dropdown.caret :primary >
258
+ <%= dropdown.menu do |menu| %>
259
+ <%= menu.link 'Dropdown Link', '#' %>
260
+ <%= menu.link 'Dropdown Link', '#' %>
261
+ <% end %>
271
262
  <% end %>
272
263
 
273
- <%= dropdown_helper :group, class: 'dropright' do |dropdown| %>
274
- <button type="button" class="btn btn-danger">Action 2</button>
275
- <%= dropdown.button(:danger, split: true) %>
276
- <%= dropdown.menu do |menu| %>
277
- <%= menu.header "Crud operations" %>
278
- <%= menu.divider %>
279
- <%= menu.link 'Edit', 'SOME-URL' %>
280
- <%= menu.link 'Delete', 'SOME-URL' %>
281
- <% end %>
282
- <% end %>
264
+
265
+ // Dropdown menu with a login form inside the menu
283
266
 
284
267
  <%= dropdown_helper do |dropdown| %>
285
- <%= dropdown.button :primary do %>
286
- <i class="fas fa-users"></i> User
287
- <% end %>
288
- <%= dropdown.menu do |menu| %>
289
- <form class="px-4 py-3">
290
- <div class="form-group">
291
- <label for="exampleDropdownFormEmail1">Email address</label>
292
- <input type="email" class="form-control" id="exampleDropdownFormEmail1" placeholder="email@example.com">
293
- </div>
294
- <div class="form-group">
295
- <label for="exampleDropdownFormPassword1">Password</label>
296
- <input type="password" class="form-control" id="exampleDropdownFormPassword1" placeholder="Password">
297
- </div>
298
- <div class="form-group">
299
- <div class="form-check">
300
- <input type="checkbox" class="form-check-input" id="dropdownCheck">
301
- <label class="form-check-label" for="dropdownCheck">
302
- Remember me
303
- </label>
304
- </div>
305
- </div>
306
- <button type="submit" class="btn btn-primary">Sign in</button>
307
- </form>
308
- <%= menu.divider %>
309
- <%= menu.link "New around here? Sign up", "#" %>
310
- <%= menu.link "Forgot password", "#" %>
311
- <% end %>
268
+ <%= dropdown.button :primary do %>
269
+ Login
270
+ <% end %>
271
+ <%= dropdown.menu do |menu| %>
272
+ <form class="px-4 py-3">
273
+ <div class="form-group">
274
+ <label for="exampleDropdownFormEmail1">Email address</label>
275
+ <input type="email" class="form-control" id="exampleDropdownFormEmail1" placeholder="email@example.com">
276
+ </div>
277
+ <div class="form-group">
278
+ <label for="exampleDropdownFormPassword1">Password</label>
279
+ <input type="password" class="form-control" id="exampleDropdownFormPassword1" placeholder="Password">
280
+ </div>
281
+ <div class="form-group">
282
+ <div class="form-check">
283
+ <input type="checkbox" class="form-check-input" id="dropdownCheck">
284
+ <label class="form-check-label" for="dropdownCheck">
285
+ Remember me
286
+ </label>
287
+ </div>
288
+ </div>
289
+ <button type="submit" class="btn btn-primary">Sign in</button>
290
+ </form>
291
+ <%= menu.divider %>
292
+ <%= menu.link "New around here? Sign up", "#" %>
293
+ <%= menu.link "Forgot password", "#" %>
294
+ <% end %>
312
295
  <% end %>
313
296
  ```
314
297
 
@@ -324,11 +307,10 @@ end
324
307
  # @option opts [Boolean] :static
325
308
  # @option opts [Boolean|Symbol] :fullscreen - true, :sm, :lg, :xl etc
326
309
  # @option opts [Symbol] :size - :sm, :md, :lg etc
327
- # @return [String]
310
+ # @yield [Modal]
311
+ # @return [Modal]
328
312
  #
329
- def modal_helper(opts = {}, &block)
330
- Modal.new(self, opts, &block)
331
- end
313
+ modal_helper(opts = {}, &block)
332
314
  ```
333
315
 
334
316
  > Note: When the `close_button` is not passed a block, it will default to the X icon.
@@ -381,9 +363,7 @@ The Nav component has the following methods:
381
363
  #
382
364
  # @return [String]
383
365
  #
384
- def nav_helper(*args, &block)
385
- Nav.new(self, *args, &block)
386
- end
366
+ nav_helper(*args, &block)
387
367
  ```
388
368
 
389
369
  #### Example
@@ -405,10 +385,60 @@ end
405
385
  <% end %>
406
386
  ```
407
387
 
388
+ ### Offcanvas
389
+
390
+ ```ruby
391
+ # @overload offcanvas_helper(position, options)
392
+ # @param [Symbol] position - :start, :end, :top, :bottom
393
+ # @param [Hash] opts
394
+ # @option opts [String] :id
395
+ # @option opts [String] :class
396
+ # @option opts [Hash] :data
397
+ # @option opts [Hash] :aria
398
+ # @option opts [Boolean] :scrollable
399
+ # @option opts [Boolean|String] :backdrop - true, false, 'static'
400
+ #
401
+ # @overload offcanvas_helper(options)
402
+ # @param [Hash] opts
403
+ # @option opts [String] :id
404
+ # @option opts [String] :class
405
+ # @option opts [Hash] :data
406
+ # @option opts [Hash] :aria
407
+ # @option opts [Boolean] :scrollable
408
+ # @option opts [Boolean|String] :backdrop - true, false, 'static'
409
+ #
410
+ # @yield [Offcanvas]
411
+ # @return [Offcanvas]
412
+ #
413
+ def offcanvas_helper(*args, &block)
414
+ ```
415
+
416
+ #### Example
417
+
418
+ ```erb
419
+ <%= offcanvas_helper scrollable: true do |off| %>
420
+ <%= off.link class: 'btn btn-danger' do %>
421
+ <strong>*</strong> Open sidebar
422
+ <% end %>
423
+
424
+ <%= off.content do |c| %>
425
+ <%= c.header do %>
426
+ <%= c.title { 'Sidebar content' } %>
427
+ <%= c.close_button class: 'btn btn-info' do %>
428
+ Close
429
+ <% end %>
430
+ <% end %>
431
+ <%= c.body do %>
432
+ <p>Some content in the sidebar!</p>
433
+ <% end %>
434
+ <% end %>
435
+ <% end %>
436
+ ```
437
+
408
438
  ### Tabs
409
439
 
410
440
  ```ruby
411
- # @overload tab_helper(type, opts)
441
+ # @overload tab_helper(type, opts)
412
442
  # @param [Symbol|String] type - :tabs, :pills
413
443
  # @param [Hash] opts
414
444
  # @option opts [String] :id
@@ -421,11 +451,10 @@ end
421
451
  # @option opts [String] :class
422
452
  # @option opts [Hash] :data
423
453
  #
424
- # @return [String]
454
+ # @yield [Tab]
455
+ # @return [Tab]
425
456
  #
426
457
  def tab_helper(*args, &block)
427
- Tab.new(self, *args, &block)
428
- end
429
458
  ```
430
459
 
431
460
  #### Example
@@ -478,14 +507,13 @@ end
478
507
  ```ruby
479
508
  # @param [Hash] args
480
509
  # @option opts [Symbol] :type - :border, :grow
510
+ # @option opts [Symbol] :size - :sm
481
511
  # @option opts [String] :id
482
512
  # @option opts [String] :class
483
513
  # @option opts [Hash] :data
484
- # @return [String]
514
+ # @return [Spinner]
485
515
  #
486
- def spinner_helper(opts = {}, &block)
487
- Spinner.new(self, opts, &block)
488
- end
516
+ spinner_helper(opts = {}, &block)
489
517
  ```
490
518
 
491
519
  #### Example
@@ -19,6 +19,7 @@ module Bootstrap5Helper
19
19
 
20
20
  @id = args.fetch(:id, uuid)
21
21
  @class = args.fetch(:class, '')
22
+ @data = args.fetch(:data, {})
22
23
  @dismissible = args.fetch(:dismissible, false)
23
24
  @content = block || proc { '' }
24
25
  end
@@ -42,7 +43,7 @@ module Bootstrap5Helper
42
43
  # @return [String]
43
44
  #
44
45
  def to_s
45
- content_tag :div, id: @id, class: container_class do
46
+ content_tag(:div, id: @id, class: container_class, data: @data) do
46
47
  concat(@dismissible ? close_button : '')
47
48
  @content.call(self)
48
49
  end
@@ -195,7 +195,7 @@ module Bootstrap5Helper
195
195
  # @return [String]
196
196
  #
197
197
  def image(src, opts = {})
198
- (opts[:class] ||= '') << 'card-img'
198
+ (opts[:class] ||= '') << ' card-img'
199
199
  @template.image_tag(src, opts)
200
200
  end
201
201
 
@@ -207,7 +207,7 @@ module Bootstrap5Helper
207
207
  # @return [String]
208
208
  #
209
209
  def image_cap(src, type = :top, opts = {})
210
- (opts[:class] ||= '') << "card-img-#{type}"
210
+ (opts[:class] ||= '') << " card-img-#{type}"
211
211
  @template.image_tag(src, opts)
212
212
  end
213
213
 
@@ -48,7 +48,7 @@ module Bootstrap5Helper
48
48
  #
49
49
  def nav(*tag_or_options, &block)
50
50
  tag, args = parse_tag_or_options(*tag_or_options, {})
51
- args[:class] = (args[:class] || '') << 'nav-tabs card-header-tabs'
51
+ args[:class] = (args[:class] || '') << ' nav-tabs card-header-tabs'
52
52
  args[:data] = (args[:data] || {}).merge('bs-toggle' => 'tab')
53
53
  args[:child] = (args[:child] || {}).merge(
54
54
  data: {
@@ -80,7 +80,12 @@ module Bootstrap5Helper
80
80
  #
81
81
  #
82
82
  def to_s
83
- content_tag :div, class: "card with-nav-tabs-#{@context}" do
83
+ content_tag(
84
+ :div,
85
+ class: "card with-nav-tabs-#{@context} #{@class}",
86
+ id: @id,
87
+ data: @data
88
+ ) do
84
89
  @content.call(self)
85
90
  end
86
91
  end
@@ -197,7 +197,7 @@ module Bootstrap5Helper
197
197
  when TrueClass
198
198
  'modal-fullscreen'
199
199
  when String, Symbol
200
- "modal-fullscreen-#{@fullscreen}-down "
200
+ "modal-fullscreen-#{@fullscreen}-down "
201
201
  else
202
202
  ''
203
203
  end
@@ -117,7 +117,7 @@ module Bootstrap5Helper
117
117
  # @return [String]
118
118
  #
119
119
  def to_s
120
- content_tag(@tag, id: @id, class: "nav #{@class}") do
120
+ content_tag(@tag, id: @id, class: "nav #{@class}", data: @data) do
121
121
  @content.call(self)
122
122
  end
123
123
  end
@@ -146,12 +146,15 @@ module Bootstrap5Helper
146
146
 
147
147
  # Renders the component as a String, but only to the output bugger.
148
148
  #
149
- # @return [NilClass]
149
+ # @note Was updated to return an empty string opposed to nil.
150
+ # @see changelog.md
151
+ #
152
+ # @return [String]
150
153
  #
151
154
  def to_s
152
155
  @content.call(self)
153
156
 
154
- nil
157
+ ''
155
158
  end
156
159
 
157
160
  private
@@ -32,8 +32,13 @@ module Bootstrap5Helper
32
32
  # @return [String]
33
33
  #
34
34
  def link(name = nil, options = nil, html_options = nil, &block)
35
- html_options ||= {}
36
- html_options[:class] = (html_options[:class] || '') << ' dropdown-item'
35
+ if block_given?
36
+ options ||= {}
37
+ options[:class] = (options[:class] || '') << ' dropdown-item'
38
+ else
39
+ html_options ||= {}
40
+ html_options[:class] = (html_options[:class] || '') << ' dropdown-item'
41
+ end
37
42
 
38
43
  nav_item_wrapper do
39
44
  @template.link_to(name, options, html_options, &block)
@@ -92,7 +92,7 @@ module Bootstrap5Helper
92
92
  end
93
93
  end
94
94
 
95
- # Used to create a new <tt>Dropdown::Menu</tt>
95
+ # Used to create a new <tt>Overlay::Menu</tt>
96
96
  #
97
97
  # @param [Hash] opts
98
98
  # @option opts [String] :id
@@ -68,13 +68,13 @@ module Bootstrap5Helper
68
68
  # string or DOM element, we want to return nil, so that only the output buffer on the sub components are
69
69
  # returned.
70
70
  #
71
- # If we return the return value of the block, we will get the last element added to the input
72
- # buffer as an unescaped string.
71
+ # @note Was updated to return an empty string opposed to nil.
72
+ # @see changelog.md
73
73
  #
74
74
  def to_s
75
75
  @content.call(self)
76
76
 
77
- nil
77
+ ''
78
78
  end
79
79
 
80
80
  def type_or_options(*args)
@@ -1,3 +1,3 @@
1
1
  module Bootstrap5Helper
2
- VERSION = '1.1.1'.freeze
2
+ VERSION = '1.1.3'.freeze
3
3
  end
@@ -101,7 +101,7 @@ module Bootstrap5Helper
101
101
  Badge.new(self, *args, &block)
102
102
  end
103
103
 
104
- # Internal helper, used with personal Bootstrap modifications.
104
+ # @note Internal helper, used with personal Bootstrap modifications.
105
105
  #
106
106
  #
107
107
  def callout_helper(*args, &block)
@@ -165,6 +165,8 @@ module Bootstrap5Helper
165
165
  Card.new(self, opts, &block)
166
166
  end
167
167
 
168
+ # @note Internal helper, used with personal Bootstrap modifications.
169
+ #
168
170
  # @overload card_with_nav_tab_helper(context, opts)
169
171
  # @param [Symbol|String] context
170
172
  # @param [Hash] opts
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap5_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.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: 2023-01-24 00:00:00.000000000 Z
11
+ date: 2024-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bootstrap
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: solargraph
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -150,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
164
  - !ruby/object:Gem::Version
151
165
  version: '0'
152
166
  requirements: []
153
- rubygems_version: 3.1.6
167
+ rubygems_version: 3.3.26
154
168
  signing_key:
155
169
  specification_version: 4
156
170
  summary: Rails helpers for generating Bootstrap 5 components.