bootstrap4_helper 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,19 +8,16 @@ end
8
8
 
9
9
  require 'bootstrap4_helper/initialize'
10
10
 
11
- # @todo
12
- # - We need a configuration system so people can specify what DOM elements to
13
- # use when building components. Like, so we want <h1> for Card Headers or just
14
- # <div>'s.
11
+ # This is the module that will get included in your partials.
12
+ #
15
13
  #
16
14
  module Bootstrap4Helper
17
- # @description
18
- # - Creates a single Accordion element. The header component
15
+ # Creates a single Accordion element. The header component
19
16
  # already provides the DOM element to link the Collapse area.
20
17
  # You just need to provide the text or additional markup, if
21
18
  # you want it.
22
19
  #
23
- # <code>
20
+ # ```erb
24
21
  # <%= accordion_helper do |a| %>
25
22
  # <%= a.header do %>
26
23
  # // Some HTML or Ruby
@@ -29,20 +26,19 @@ module Bootstrap4Helper
29
26
  # // Some HTML or Ruby
30
27
  # <% end %>
31
28
  # <% end %>
32
- # </code>
29
+ # ```
33
30
  #
34
- # @param [Mixed] args
31
+ # @param [Hash] opts
35
32
  # @return [Accordion]
36
33
  #
37
34
  def accordion_helper(opts = {}, &block)
38
35
  Accordion.new(self, opts, &block)
39
36
  end
40
37
 
41
- # @description
42
- # - Creates a group of Accordions that stay in sync with each other.
38
+ # Creates a group of Accordions that stay in sync with each other.
43
39
  # One opens, the other closes.
44
40
  #
45
- # <code>
41
+ # ```erb
46
42
  # <%= accordion_group_helper do |grp| %>
47
43
  # <%= grp.accordion do |a| %>
48
44
  # <%= a.header class: 'text-white bg-primary' do %>
@@ -62,58 +58,55 @@ module Bootstrap4Helper
62
58
  # <% end %>
63
59
  # <% end %>
64
60
  # <% end $>
65
- # </code>
61
+ # ```
66
62
  #
67
- # @param [Mixed] args
63
+ # @param [Mixed] args
68
64
  # @return [Accordion]
69
65
  #
70
66
  def accordion_group_helper(*args, &block)
71
67
  AccordionGroup.new(self, *args, &block)
72
68
  end
73
69
 
74
- # @description
75
- # - Creates an Alert component.
70
+ # Creates an Alert component.
76
71
  #
77
- # <code>
72
+ # ```erb
78
73
  # <%= alert_helper :danger, dismissble: true do %>
79
74
  # Something went wrong with your model data...
80
75
  # <% end %>
81
- # </code>
76
+ # ```
82
77
  #
83
- # @params [Symbol|String|Hash|NilClass] *args
78
+ # @param [Mixed] args
84
79
  # @return [String]
85
80
  #
86
81
  def alert_helper(*args, &block)
87
82
  Alert.new(self, *args, &block)
88
83
  end
89
84
 
90
- # @description
91
- # - Creates a badge component. Bades have a context variable. Providing nothing
85
+ # Creates a badge component. Badges have a context variable. Providing nothing
92
86
  # will give you the `secondary` context.
93
87
  #
94
- # <code>
88
+ # ```erb
95
89
  # <li>
96
90
  # Messages: <%= badge_helper(:primary) { @messages.count } %>
97
91
  # </li>
98
92
  # <li>
99
93
  # Notifications: <%= badge_healper { @notifications.count } %>
100
94
  # </li>
101
- # </code>
95
+ # ```
102
96
  #
103
- # @params [Symbol|String|Hash|NilClass] *args
97
+ # @param [Mixed] args
104
98
  # @return [String]
105
99
  #
106
100
  def badge_helper(*args, &block)
107
101
  Badge.new(self, *args, &block)
108
102
  end
109
103
 
110
- # @description
111
- # - Creates a Card component.
104
+ # Creates a Card component.
112
105
  #
113
106
  #
114
- # <code>
107
+ # ```erb
115
108
  #
116
- # - Regular
109
+ # <%# Regular %>
117
110
  #
118
111
  # <%= card_helper do |c| %>
119
112
  # <%= c.header class: 'text-white bg-primary' do %>
@@ -133,7 +126,7 @@ module Bootstrap4Helper
133
126
  # <% end %>
134
127
  # <% end %>
135
128
  #
136
- # - Horizontal
129
+ # <%# Horizontal %>
137
130
  #
138
131
  # <div class="row">
139
132
  # <div class="col-sm mt-3 mb-3">
@@ -155,19 +148,18 @@ module Bootstrap4Helper
155
148
  # <% end %>
156
149
  # </div>
157
150
  # </div>
158
- # </code>
151
+ # ```
159
152
  #
160
- # @param [Hash] opts
153
+ # @param [Hash] opts
161
154
  # @return [String]
162
155
  #
163
156
  def card_helper(opts = {}, &block)
164
157
  Card.new(self, opts, &block)
165
158
  end
166
159
 
167
- # @description
168
- # - Builds a card group.
160
+ # Builds a card group.
169
161
  #
170
- # <code>
162
+ # ```erb
171
163
  # <%= card_group_helper do |group| %>
172
164
  # <%= group.card do |c| %>
173
165
  # <%= c.body do %>
@@ -214,19 +206,18 @@ module Bootstrap4Helper
214
206
  # <% end %>
215
207
  # <% end %>
216
208
  # <% end %>
217
- # </code>
209
+ # ```
218
210
  #
219
- # @param [Hash] opts
211
+ # @param [Hash] opts
220
212
  # @return [String]
221
213
  #
222
214
  def card_group_helper(opts = {}, &block)
223
215
  CardGroup.new(self, opts, &block)
224
216
  end
225
217
 
226
- # @description
227
- # - Builds a card deck.
218
+ # Builds a card deck.
228
219
  #
229
- # <code>
220
+ # ```erb
230
221
  # <%= card_deck_helper do |deck| %>
231
222
  # <%= deck.card do |c| %>
232
223
  # <%= c.body do %>
@@ -273,19 +264,18 @@ module Bootstrap4Helper
273
264
  # <% end %>
274
265
  # <% end %>
275
266
  # <% end %>
276
- # </code>
267
+ # ```
277
268
  #
278
- # @param [Hash] opts
269
+ # @param [Hash] opts
279
270
  # @return [String]
280
271
  #
281
272
  def card_deck_helper(opts = {}, &block)
282
273
  CardDeck.new(self, opts, &block)
283
274
  end
284
275
 
285
- # @description
286
- # - Builds a card column.
276
+ # Builds a card column.
287
277
  #
288
- # <code>
278
+ # ```erb
289
279
  # <%= card_column_helper do |column| %>
290
280
  # <%= column.card do |c| %>
291
281
  # <%= c.body do %>
@@ -332,20 +322,19 @@ module Bootstrap4Helper
332
322
  # <% end %>
333
323
  # <% end %>
334
324
  # <% end %>
335
- # </code>
325
+ # ```
336
326
  #
337
- # @param [Hash] opts
327
+ # @param [Hash] opts
338
328
  # @return [String]
339
329
  #
340
330
  def card_column_helper(opts = {}, &block)
341
331
  CardColumn.new(self, opts, &block)
342
332
  end
343
333
 
344
- # @description
345
- # - Generates a Dropdown component. Default type `:dropdown`. For inline buttons, use
334
+ # Generates a Dropdown component. Default type `:dropdown`. For inline buttons, use
346
335
  # `:group`.
347
336
  #
348
- # <code>
337
+ # ```erb
349
338
  # <%= dropdown_helper do |dropdown| %>
350
339
  # <%= dropdown.button(:primary) { "Action" } %>
351
340
  # <%= dropdown.menu do |menu| %>
@@ -395,19 +384,18 @@ module Bootstrap4Helper
395
384
  # <%= menu.link "Forgot password", "#" %>
396
385
  # <% end %>
397
386
  # <% end %>
398
- # </code>
387
+ # ```
399
388
  #
400
- # @param [Mixed] args
389
+ # @param [Mixed] args
401
390
  # @return [String]
402
391
  #
403
392
  def dropdown_helper(*args, &block)
404
393
  Dropdown.new(self, *args, &block)
405
394
  end
406
395
 
407
- # @description
408
- # - Generates Modal windows.
396
+ # Generates Modal windows.
409
397
  #
410
- # <code>
398
+ # ```erb
411
399
  # <%= modal_helper id: 'exampleModal' do |m| %>
412
400
  # <%= m.header do %>
413
401
  # <%= m.title { 'Example Modal' } %>
@@ -425,19 +413,18 @@ module Bootstrap4Helper
425
413
  # <% end %>
426
414
  # <% end %>
427
415
  # <% end %>
428
- # </code>
416
+ # ```
429
417
  #
430
- # @param [Hash] opts
418
+ # @param [Hash] opts
431
419
  # @return [String]
432
420
  #
433
421
  def modal_helper(opts = {}, &block)
434
422
  Modal.new(self, opts, &block)
435
423
  end
436
424
 
437
- # @description
438
- # - Generates Nav components.
425
+ # Generates Nav components.
439
426
  #
440
- # <code>
427
+ # ```erb
441
428
  # <%= nav_helper do |nav| %>
442
429
  # <%= nav.link "Item 1", "https://www.google.com" %>
443
430
  # <%= nav.link "Item 2", "#" %>
@@ -452,19 +439,27 @@ module Bootstrap4Helper
452
439
  # <%= menu.link 'Records', '#' %>
453
440
  # <% end %>
454
441
  # <% end %>
455
- # </code>
442
+ # ```
456
443
  #
457
- # @param [Hash] opts
444
+ # @param [Hash] opts
458
445
  # @return [String]
459
446
  #
460
447
  def nav_helper(opts = {}, &block)
461
448
  Nav.new(self, opts, &block)
462
449
  end
463
450
 
464
- # @description
465
- # - Generates a Tab component.
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
+
460
+ # Generates a Tab component.
466
461
  #
467
- # <code>
462
+ # ```erb
468
463
  # <%= tab_helper do |tab| %>
469
464
  # <%= tab.nav do |nav| %>
470
465
  # <%= nav.item :item1 do %>
@@ -505,19 +500,22 @@ module Bootstrap4Helper
505
500
  # <% end %>
506
501
  # <% end %>
507
502
  # <% end %>
508
- # </code>
503
+ # ```
504
+ # @param [Mixed] args
505
+ # @return [String]
509
506
  #
510
507
  def tab_helper(*args, &block)
511
508
  Tab.new(self, *args, &block)
512
509
  end
513
510
 
514
- # @description
515
- # - Generates spinner annimations.
511
+ # Generates spinner annimations.
516
512
  #
517
- # <code>
513
+ # ```erb
518
514
  # <%= spinner_helper class: 'text-warning' %>
519
515
  # <%= spinner_helper type: :grow, class: 'text-danger', id: 'loadingRecords' %>
520
- # </code>
516
+ # ```
517
+ # @param [Mixed] args
518
+ # @return [String]
521
519
  #
522
520
  def spinner_helper(*args, &block)
523
521
  Spinner.new(self, *args, &block)
@@ -1,9 +1,6 @@
1
- # @root
2
- #
3
- #
4
1
  module Bootstrap4Helper
5
- # @description
6
- # - Builds a Accordion out of the collapse component of Bootstrap 4.
2
+ # Builds a Accordion out of the collapse component of Bootstrap 4.
3
+ #
7
4
  #
8
5
  class Accordion < Component
9
6
  CARD_METHODS = %i[
@@ -12,11 +9,16 @@ module Bootstrap4Helper
12
9
  image_overlay
13
10
  ].freeze
14
11
 
15
- # @description
12
+ # Class constructor
16
13
  # -
17
14
  #
18
15
  # @param [ActionView] template
19
16
  # @param [Hash] opts
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
20
22
  #
21
23
  def initialize(template, opts = {}, &block)
22
24
  super(template)
@@ -30,11 +32,10 @@ module Bootstrap4Helper
30
32
  @card = Card.new(@template)
31
33
  end
32
34
 
33
- # @description
34
- # - Builds a header component for the accordion, which is actually the header
35
+ # Builds a header component for the accordion, which is actually the header
35
36
  # of a Card.
36
37
  #
37
- # @param [Hash] opts
38
+ # @param [Hash] opts
38
39
  # @return [String]
39
40
  #
40
41
  def header(opts = {}, &block)
@@ -49,15 +50,13 @@ module Bootstrap4Helper
49
50
  end
50
51
  end
51
52
 
52
- # @description
53
- # - Builds the body component for the accordion, which is actually the body
53
+ # Builds the body component for the accordion, which is actually the body
54
54
  # of a Card.
55
55
  #
56
- # @note
57
- # - The `@parent` gets used to set the parent element for the accordion. This
58
- # gets used primarily in the `AccordionGroup`.
56
+ # @note The `@parent` gets used to set the parent element for the accordion. This
57
+ # gets used primarily in the `AccordionGroup`.
59
58
  #
60
- # @param [Hash] opts
59
+ # @param [Hash] opts
61
60
  # @return [String]
62
61
  #
63
62
  def body(opts = {}, &block)
@@ -68,8 +67,7 @@ module Bootstrap4Helper
68
67
  end
69
68
  end
70
69
 
71
- # @description
72
- # - Because Accordions are basically `Cards` with a wrapper, we might as
70
+ # Because Accordions are basically `Cards` with a wrapper, we might as
73
71
  # well catch common `Card` methods and send them to the card object. No
74
72
  # point in creating similar methods for `Accordions`.
75
73
  #
@@ -84,15 +82,14 @@ module Bootstrap4Helper
84
82
  end
85
83
  end
86
84
 
87
- # @description
88
- # -
85
+ # Checks if the Object reponds to missing.
86
+ #
89
87
  #
90
88
  def respond_to_missing?(method, include_private = false)
91
89
  CARD_METHODS.include?(method) || super
92
90
  end
93
91
 
94
- # @description
95
- # - Leaving off the the default `accordion` class because with only 1 accordion,
92
+ # Leaving off the default `accordion` class because with only 1 accordion,
96
93
  # there is no bottom.
97
94
  #
98
95
  # @return [String]
@@ -1,17 +1,15 @@
1
- # @root
2
- #
3
- #
4
1
  module Bootstrap4Helper
5
- # @description
6
- # - Used to build groups of Accordions, that are all synced with each other.
2
+ # Used to build groups of Accordions, that are all synced with each other.
3
+ #
7
4
  #
8
5
  class AccordionGroup < Component
9
- # @description
10
- # -
6
+ # Class constructor
11
7
  #
12
8
  # @param [ActionView] template
13
- # @param [NilClass|String|Symbol|Hash] opts
14
- # @param [Hash]
9
+ # @param [Hash] opts
10
+ # @option opts [String] :id
11
+ # @option opts [String] :class
12
+ # @option opts [Hash] :data
15
13
  #
16
14
  def initialize(template, opts = {}, &block)
17
15
  super(template)
@@ -22,8 +20,7 @@ module Bootstrap4Helper
22
20
  @content = block || proc { '' }
23
21
  end
24
22
 
25
- # @description
26
- # - Used to build a `Accordion` for the `AccordionGroup`.
23
+ # Used to build a `Accordion` for the `AccordionGroup`.
27
24
  #
28
25
  # @param [Mixed] args
29
26
  # @return [Accordion]
@@ -40,8 +37,7 @@ module Bootstrap4Helper
40
37
  Accordion.new(self, *opts, &block)
41
38
  end
42
39
 
43
- # @description
44
- # - Used to get the HTML markup of the `AccordionGroup`
40
+ # Used to get the HTML markup of the `AccordionGroup`
45
41
  #
46
42
  # @return [String]
47
43
  #