bootstrap4_helper 1.0.0 → 1.0.1
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/README.md +7 -0
- data/lib/bootstrap4_helper.rb +58 -69
- data/lib/bootstrap4_helper/accordion.rb +18 -21
- data/lib/bootstrap4_helper/accordion_group.rb +9 -13
- data/lib/bootstrap4_helper/alert.rb +6 -31
- data/lib/bootstrap4_helper/badge.rb +8 -13
- data/lib/bootstrap4_helper/card.rb +52 -39
- data/lib/bootstrap4_helper/card_column.rb +3 -6
- data/lib/bootstrap4_helper/card_deck.rb +3 -6
- data/lib/bootstrap4_helper/card_group.rb +3 -6
- data/lib/bootstrap4_helper/card_grouping.rb +6 -8
- data/lib/bootstrap4_helper/component.rb +28 -32
- data/lib/bootstrap4_helper/configuration.rb +7 -9
- data/lib/bootstrap4_helper/constants.rb +2 -5
- data/lib/bootstrap4_helper/dropdown.rb +23 -20
- data/lib/bootstrap4_helper/dropdown/menu.rb +42 -25
- data/lib/bootstrap4_helper/initialize.rb +2 -7
- data/lib/bootstrap4_helper/modal.rb +54 -37
- data/lib/bootstrap4_helper/nav.rb +32 -19
- data/lib/bootstrap4_helper/railtie.rb +1 -1
- data/lib/bootstrap4_helper/spinner.rb +12 -9
- data/lib/bootstrap4_helper/tab.rb +20 -16
- data/lib/bootstrap4_helper/tab/content.rb +24 -17
- data/lib/bootstrap4_helper/version.rb +1 -1
- metadata +50 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecce74ed3cfecf92336b00a39382a3f08421677a5d19960c9258d75b408ff3ae
|
4
|
+
data.tar.gz: 502e141e6a43ff40a0b5c1d3b5df7a6595de3ba8d9cb87b1cbb24036f2b919e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3638e8d509347594f2e5491a5a3ebd024795f0dce99113946b656e029f1e5c27ef4fb019c45949b0954c010fe90b3485d8f630f34f7025b09d34395f5cf4565d
|
7
|
+
data.tar.gz: f352adbb8fdc083faf28e2bce76e3f7763c208c4d00fd328532a9e24fafe4fcf324d05ab3c96389ecc7c3ac4c4d00134d5a3acfa77b3bf8f188ebc9270e1d597
|
data/README.md
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
# Bootstrap4Helper
|
2
|
+
|
2
3
|
Short description and motivation.
|
3
4
|
|
4
5
|
## Usage
|
6
|
+
|
5
7
|
How to use my plugin.
|
6
8
|
|
7
9
|
## Installation
|
10
|
+
|
8
11
|
Add this line to your application's Gemfile:
|
9
12
|
|
10
13
|
```ruby
|
@@ -12,17 +15,21 @@ gem 'bootstrap4_helper'
|
|
12
15
|
```
|
13
16
|
|
14
17
|
And then execute:
|
18
|
+
|
15
19
|
```bash
|
16
20
|
$ bundle
|
17
21
|
```
|
18
22
|
|
19
23
|
Or install it yourself as:
|
24
|
+
|
20
25
|
```bash
|
21
26
|
$ gem install bootstrap4_helper
|
22
27
|
```
|
23
28
|
|
24
29
|
## Contributing
|
30
|
+
|
25
31
|
Contribution directions go here.
|
26
32
|
|
27
33
|
## License
|
34
|
+
|
28
35
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/lib/bootstrap4_helper.rb
CHANGED
@@ -8,19 +8,16 @@ end
|
|
8
8
|
|
9
9
|
require 'bootstrap4_helper/initialize'
|
10
10
|
|
11
|
-
#
|
12
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
29
|
+
# ```
|
33
30
|
#
|
34
|
-
# @param
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
61
|
+
# ```
|
66
62
|
#
|
67
|
-
# @param
|
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
|
-
#
|
75
|
-
# - Creates an Alert component.
|
70
|
+
# Creates an Alert component.
|
76
71
|
#
|
77
|
-
#
|
72
|
+
# ```erb
|
78
73
|
# <%= alert_helper :danger, dismissble: true do %>
|
79
74
|
# Something went wrong with your model data...
|
80
75
|
# <% end %>
|
81
|
-
#
|
76
|
+
# ```
|
82
77
|
#
|
83
|
-
# @
|
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
|
-
#
|
91
|
-
# - Creates a badge component. Bades have a context variable. Providing nothing
|
85
|
+
# Creates a badge component. Bades have a context variable. Providing nothing
|
92
86
|
# will give you the `secondary` context.
|
93
87
|
#
|
94
|
-
#
|
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
|
-
#
|
95
|
+
# ```
|
102
96
|
#
|
103
|
-
# @
|
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
|
-
#
|
111
|
-
# - Creates a Card component.
|
104
|
+
# Creates a Card component.
|
112
105
|
#
|
113
106
|
#
|
114
|
-
#
|
107
|
+
# ```erb
|
115
108
|
#
|
116
|
-
#
|
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
|
-
#
|
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
|
-
#
|
151
|
+
# ```
|
159
152
|
#
|
160
|
-
# @param
|
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
|
-
#
|
168
|
-
# - Builds a card group.
|
160
|
+
# Builds a card group.
|
169
161
|
#
|
170
|
-
#
|
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
|
-
#
|
209
|
+
# ```
|
218
210
|
#
|
219
|
-
# @param
|
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
|
-
#
|
227
|
-
# - Builds a card deck.
|
218
|
+
# Builds a card deck.
|
228
219
|
#
|
229
|
-
#
|
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
|
-
#
|
267
|
+
# ```
|
277
268
|
#
|
278
|
-
# @param
|
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
|
-
#
|
286
|
-
# - Builds a card column.
|
276
|
+
# Builds a card column.
|
287
277
|
#
|
288
|
-
#
|
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
|
-
#
|
325
|
+
# ```
|
336
326
|
#
|
337
|
-
# @param
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
387
|
+
# ```
|
399
388
|
#
|
400
|
-
# @param
|
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
|
-
#
|
408
|
-
# - Generates Modal windows.
|
396
|
+
# Generates Modal windows.
|
409
397
|
#
|
410
|
-
#
|
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
|
-
#
|
416
|
+
# ```
|
429
417
|
#
|
430
|
-
# @param
|
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
|
-
#
|
438
|
-
# - Generates Nav components.
|
425
|
+
# Generates Nav components.
|
439
426
|
#
|
440
|
-
#
|
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,18 @@ module Bootstrap4Helper
|
|
452
439
|
# <%= menu.link 'Records', '#' %>
|
453
440
|
# <% end %>
|
454
441
|
# <% end %>
|
455
|
-
#
|
442
|
+
# ```
|
456
443
|
#
|
457
|
-
# @param
|
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
|
-
#
|
465
|
-
# - Generates a Tab component.
|
451
|
+
# Generates a Tab component.
|
466
452
|
#
|
467
|
-
#
|
453
|
+
# ```erb
|
468
454
|
# <%= tab_helper do |tab| %>
|
469
455
|
# <%= tab.nav do |nav| %>
|
470
456
|
# <%= nav.item :item1 do %>
|
@@ -505,19 +491,22 @@ module Bootstrap4Helper
|
|
505
491
|
# <% end %>
|
506
492
|
# <% end %>
|
507
493
|
# <% end %>
|
508
|
-
#
|
494
|
+
# ```
|
495
|
+
# @param [Mixed] args
|
496
|
+
# @return [String]
|
509
497
|
#
|
510
498
|
def tab_helper(*args, &block)
|
511
499
|
Tab.new(self, *args, &block)
|
512
500
|
end
|
513
501
|
|
514
|
-
#
|
515
|
-
# - Generates spinner annimations.
|
502
|
+
# Generates spinner annimations.
|
516
503
|
#
|
517
|
-
#
|
504
|
+
# ```erb
|
518
505
|
# <%= spinner_helper class: 'text-warning' %>
|
519
506
|
# <%= spinner_helper type: :grow, class: 'text-danger', id: 'loadingRecords' %>
|
520
|
-
#
|
507
|
+
# ```
|
508
|
+
# @param [Mixed] args
|
509
|
+
# @return [String]
|
521
510
|
#
|
522
511
|
def spinner_helper(*args, &block)
|
523
512
|
Spinner.new(self, *args, &block)
|
@@ -1,9 +1,6 @@
|
|
1
|
-
# @root
|
2
|
-
#
|
3
|
-
#
|
4
1
|
module Bootstrap4Helper
|
5
|
-
#
|
6
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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
|
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
|
-
#
|
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
|
-
#
|
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
|
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
|
-
#
|
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
|
-
#
|
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
|
-
#
|
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]
|