bootstrap4_helper 0.0.0 → 1.0.4

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.
@@ -1,5 +1,514 @@
1
- require "bootstrap4_helper/railtie"
1
+ require 'bootstrap4_helper/version'
2
+ require 'bootstrap4_helper/railtie'
3
+ require 'bootstrap4_helper/constants'
2
4
 
5
+ Bootstrap4Helper::Constants::COMPONENTS.each do |component|
6
+ require "bootstrap4_helper/#{component}"
7
+ end
8
+
9
+ require 'bootstrap4_helper/initialize'
10
+
11
+ # This is the module that will get included in your partials.
12
+ #
13
+ #
3
14
  module Bootstrap4Helper
4
- # Your code goes here...
15
+ # Creates a single Accordion element. The header component
16
+ # already provides the DOM element to link the Collapse area.
17
+ # You just need to provide the text or additional markup, if
18
+ # you want it.
19
+ #
20
+ # ```erb
21
+ # <%= accordion_helper do |a| %>
22
+ # <%= a.header do %>
23
+ # // Some HTML or Ruby
24
+ # <% end %>
25
+ # <%= a.body %>
26
+ # // Some HTML or Ruby
27
+ # <% end %>
28
+ # <% end %>
29
+ # ```
30
+ #
31
+ # @param [Hash] opts
32
+ # @return [Accordion]
33
+ #
34
+ def accordion_helper(opts = {}, &block)
35
+ Accordion.new(self, opts, &block)
36
+ end
37
+
38
+ # Creates a group of Accordions that stay in sync with each other.
39
+ # One opens, the other closes.
40
+ #
41
+ # ```erb
42
+ # <%= accordion_group_helper do |grp| %>
43
+ # <%= grp.accordion do |a| %>
44
+ # <%= a.header class: 'text-white bg-primary' do %>
45
+ # // Some HTML or Ruby
46
+ # <% end %>
47
+ # <%= a.body %>
48
+ # // Some HTML or Ruby
49
+ # <% end %>
50
+ # <% end %>
51
+ #
52
+ # <%= grp.accordion do |a| %>
53
+ # <%= a.header class: 'text-white bg-danger' do %>
54
+ # // Some HTML or Ruby
55
+ # <% end %>
56
+ # <%= a.body %>
57
+ # // Some HTML or Ruby
58
+ # <% end %>
59
+ # <% end %>
60
+ # <% end $>
61
+ # ```
62
+ #
63
+ # @param [Mixed] args
64
+ # @return [Accordion]
65
+ #
66
+ def accordion_group_helper(*args, &block)
67
+ AccordionGroup.new(self, *args, &block)
68
+ end
69
+
70
+ # Creates an Alert component.
71
+ #
72
+ # ```erb
73
+ # <%= alert_helper :danger, dismissble: true do %>
74
+ # Something went wrong with your model data...
75
+ # <% end %>
76
+ # ```
77
+ #
78
+ # @param [Mixed] args
79
+ # @return [String]
80
+ #
81
+ def alert_helper(*args, &block)
82
+ Alert.new(self, *args, &block)
83
+ end
84
+
85
+ # Creates a badge component. Badges have a context variable. Providing nothing
86
+ # will give you the `secondary` context.
87
+ #
88
+ # ```erb
89
+ # <li>
90
+ # Messages: <%= badge_helper(:primary) { @messages.count } %>
91
+ # </li>
92
+ # <li>
93
+ # Notifications: <%= badge_healper { @notifications.count } %>
94
+ # </li>
95
+ # ```
96
+ #
97
+ # @param [Mixed] args
98
+ # @return [String]
99
+ #
100
+ def badge_helper(*args, &block)
101
+ Badge.new(self, *args, &block)
102
+ end
103
+
104
+ # Creates a Card component.
105
+ #
106
+ #
107
+ # ```erb
108
+ #
109
+ # <%# Regular %>
110
+ #
111
+ # <%= card_helper do |c| %>
112
+ # <%= c.header class: 'text-white bg-primary' do %>
113
+ # <h4>This is the header...</h4>
114
+ # <% end %>
115
+ # <%= c.body do %>
116
+ # <%= c.title { 'This is the title' } %>
117
+ # <%= c.text { 'This card body' } %>
118
+ # <ul>
119
+ # <% [1, 2, 3].each do |x| %>
120
+ # <li>Item: <%= x %></li>
121
+ # <% end %>
122
+ # </ul>
123
+ # <% end %>
124
+ # <%= c.footer do %>
125
+ # This is the footer...
126
+ # <% end %>
127
+ # <% end %>
128
+ #
129
+ # <%# Horizontal %>
130
+ #
131
+ # <div class="row">
132
+ # <div class="col-sm mt-3 mb-3">
133
+ # <%= card_helper do |c| %>
134
+ # <div class="row no-gutters">
135
+ # <div class="col-md-4">
136
+ # <%= image_tag 'placeholder.svg', class: 'card-img' %>
137
+ # </div>
138
+ # <div class="col-md-8">
139
+ # <%= c.body do %>
140
+ # <%= c.title { "Card title" } %>
141
+ # <%= c.text { "This is a wider card with supporting text below as a natural lead-in to additional content." } %>
142
+ # <%= c.text do %>
143
+ # <small class="text-muted">Last updated 3 mins ago</small>
144
+ # <% end %>
145
+ # <% end %>
146
+ # </div>
147
+ # </div>
148
+ # <% end %>
149
+ # </div>
150
+ # </div>
151
+ # ```
152
+ #
153
+ # @param [Hash] opts
154
+ # @return [String]
155
+ #
156
+ def card_helper(opts = {}, &block)
157
+ Card.new(self, opts, &block)
158
+ end
159
+
160
+ # Builds a card group.
161
+ #
162
+ # ```erb
163
+ # <%= card_group_helper do |group| %>
164
+ # <%= group.card do |c| %>
165
+ # <%= c.body do %>
166
+ # <%= c.title { 'This is the title one' } %>
167
+ # <%= c.text { 'This card body' } %>
168
+ # <ul>
169
+ # <% [1, 2, 3, 4, 5, 6, 7].each do |x| %>
170
+ # <li>Item: <%= x %></li>
171
+ # <% end %>
172
+ # </ul>
173
+ # <% end %>
174
+ # <%= c.footer do %>
175
+ # This is the footer...
176
+ # <% end %>
177
+ # <% end %>
178
+ #
179
+ # <%= group.card do |c| %>
180
+ # <%= c.body do %>
181
+ # <%= c.title { 'This is the title two' } %>
182
+ # <%= c.text { 'This card body' } %>
183
+ # <ul>
184
+ # <% [1, 2, 3].each do |x| %>
185
+ # <li>Item: <%= x %></li>
186
+ # <% end %>
187
+ # </ul>
188
+ # <% end %>
189
+ # <%= c.footer do %>
190
+ # This is the footer...
191
+ # <% end %>
192
+ # <% end %>
193
+ #
194
+ # <%= group.card do |c| %>
195
+ # <%= c.body do %>
196
+ # <%= c.title { 'This is the title three' } %>
197
+ # <%= c.text { 'This card body' } %>
198
+ # <ul>
199
+ # <% [1, 2, 3].each do |x| %>
200
+ # <li>Item: <%= x %></li>
201
+ # <% end %>
202
+ # </ul>
203
+ # <% end %>
204
+ # <%= c.footer do %>
205
+ # This is the footer...
206
+ # <% end %>
207
+ # <% end %>
208
+ # <% end %>
209
+ # ```
210
+ #
211
+ # @param [Hash] opts
212
+ # @return [String]
213
+ #
214
+ def card_group_helper(opts = {}, &block)
215
+ CardGroup.new(self, opts, &block)
216
+ end
217
+
218
+ # Builds a card deck.
219
+ #
220
+ # ```erb
221
+ # <%= card_deck_helper do |deck| %>
222
+ # <%= deck.card do |c| %>
223
+ # <%= c.body do %>
224
+ # <%= c.title { 'This is the title one' } %>
225
+ # <%= c.text { 'This card body' } %>
226
+ # <ul>
227
+ # <% [1, 2, 3, 4, 5, 6, 7].each do |x| %>
228
+ # <li>Item: <%= x %></li>
229
+ # <% end %>
230
+ # </ul>
231
+ # <% end %>
232
+ # <%= c.footer do %>
233
+ # This is the footer...
234
+ # <% end %>
235
+ # <% end %>
236
+ #
237
+ # <%= deck.card do |c| %>
238
+ # <%= c.body do %>
239
+ # <%= c.title { 'This is the title two' } %>
240
+ # <%= c.text { 'This card body' } %>
241
+ # <ul>
242
+ # <% [1, 2, 3].each do |x| %>
243
+ # <li>Item: <%= x %></li>
244
+ # <% end %>
245
+ # </ul>
246
+ # <% end %>
247
+ # <%= c.footer do %>
248
+ # This is the footer...
249
+ # <% end %>
250
+ # <% end %>
251
+ #
252
+ # <%= deck.card do |c| %>
253
+ # <%= c.body do %>
254
+ # <%= c.title { 'This is the title three' } %>
255
+ # <%= c.text { 'This card body' } %>
256
+ # <ul>
257
+ # <% [1, 2, 3].each do |x| %>
258
+ # <li>Item: <%= x %></li>
259
+ # <% end %>
260
+ # </ul>
261
+ # <% end %>
262
+ # <%= c.footer do %>
263
+ # This is the footer...
264
+ # <% end %>
265
+ # <% end %>
266
+ # <% end %>
267
+ # ```
268
+ #
269
+ # @param [Hash] opts
270
+ # @return [String]
271
+ #
272
+ def card_deck_helper(opts = {}, &block)
273
+ CardDeck.new(self, opts, &block)
274
+ end
275
+
276
+ # Builds a card column.
277
+ #
278
+ # ```erb
279
+ # <%= card_column_helper do |column| %>
280
+ # <%= column.card do |c| %>
281
+ # <%= c.body do %>
282
+ # <%= c.title { 'This is the title one' } %>
283
+ # <%= c.text { 'This card body' } %>
284
+ # <ul>
285
+ # <% [1, 2, 3, 4, 5, 6, 7].each do |x| %>
286
+ # <li>Item: <%= x %></li>
287
+ # <% end %>
288
+ # </ul>
289
+ # <% end %>
290
+ # <%= c.footer do %>
291
+ # This is the footer...
292
+ # <% end %>
293
+ # <% end %>
294
+ #
295
+ # <%= column.card do |c| %>
296
+ # <%= c.body do %>
297
+ # <%= c.title { 'This is the title two' } %>
298
+ # <%= c.text { 'This card body' } %>
299
+ # <ul>
300
+ # <% [1, 2, 3].each do |x| %>
301
+ # <li>Item: <%= x %></li>
302
+ # <% end %>
303
+ # </ul>
304
+ # <% end %>
305
+ # <%= c.footer do %>
306
+ # This is the footer...
307
+ # <% end %>
308
+ # <% end %>
309
+ #
310
+ # <%= column.card do |c| %>
311
+ # <%= c.body do %>
312
+ # <%= c.title { 'This is the title three' } %>
313
+ # <%= c.text { 'This card body' } %>
314
+ # <ul>
315
+ # <% [1, 2, 3].each do |x| %>
316
+ # <li>Item: <%= x %></li>
317
+ # <% end %>
318
+ # </ul>
319
+ # <% end %>
320
+ # <%= c.footer do %>
321
+ # This is the footer...
322
+ # <% end %>
323
+ # <% end %>
324
+ # <% end %>
325
+ # ```
326
+ #
327
+ # @param [Hash] opts
328
+ # @return [String]
329
+ #
330
+ def card_column_helper(opts = {}, &block)
331
+ CardColumn.new(self, opts, &block)
332
+ end
333
+
334
+ # Generates a Dropdown component. Default type `:dropdown`. For inline buttons, use
335
+ # `:group`.
336
+ #
337
+ # ```erb
338
+ # <%= dropdown_helper do |dropdown| %>
339
+ # <%= dropdown.button(:primary) { "Action" } %>
340
+ # <%= dropdown.menu do |menu| %>
341
+ # <%= menu.link 'Edit', '#' %>
342
+ # <%= menu.link 'Delete', '#' %>
343
+ # <%= menu.text 'Static text' %>
344
+ # <% end %>
345
+ # <% end %>
346
+ #
347
+ # <%= dropdown_helper :group, class: 'dropright' do |dropdown| %>
348
+ # <button type="button" class="btn btn-danger">Action 2</button>
349
+ # <%= dropdown.button(:danger, split: true) %>
350
+ # <%= dropdown.menu do |menu| %>
351
+ # <%= menu.header "Crud operations" %>
352
+ # <%= menu.divider %>
353
+ # <%= menu.link 'Edit', '#' %>
354
+ # <%= menu.link 'Delete', '#' %>
355
+ # <% end %>
356
+ # <% end %>
357
+ #
358
+ # <%= dropdown_helper do |dropdown| %>
359
+ # <%= dropdown.button :primary do %>
360
+ # Login
361
+ # <% end %>
362
+ # <%= dropdown.menu do |menu| %>
363
+ # <form class="px-4 py-3">
364
+ # <div class="form-group">
365
+ # <label for="exampleDropdownFormEmail1">Email address</label>
366
+ # <input type="email" class="form-control" id="exampleDropdownFormEmail1" placeholder="email@example.com">
367
+ # </div>
368
+ # <div class="form-group">
369
+ # <label for="exampleDropdownFormPassword1">Password</label>
370
+ # <input type="password" class="form-control" id="exampleDropdownFormPassword1" placeholder="Password">
371
+ # </div>
372
+ # <div class="form-group">
373
+ # <div class="form-check">
374
+ # <input type="checkbox" class="form-check-input" id="dropdownCheck">
375
+ # <label class="form-check-label" for="dropdownCheck">
376
+ # Remember me
377
+ # </label>
378
+ # </div>
379
+ # </div>
380
+ # <button type="submit" class="btn btn-primary">Sign in</button>
381
+ # </form>
382
+ # <%= menu.divider %>
383
+ # <%= menu.link "New around here? Sign up", "#" %>
384
+ # <%= menu.link "Forgot password", "#" %>
385
+ # <% end %>
386
+ # <% end %>
387
+ # ```
388
+ #
389
+ # @param [Mixed] args
390
+ # @return [String]
391
+ #
392
+ def dropdown_helper(*args, &block)
393
+ Dropdown.new(self, *args, &block)
394
+ end
395
+
396
+ # Generates Modal windows.
397
+ #
398
+ # ```erb
399
+ # <%= modal_helper id: 'exampleModal' do |m| %>
400
+ # <%= m.header do %>
401
+ # <%= m.title { 'Example Modal' } %>
402
+ # <%= m.close_button %>
403
+ # <% end %>
404
+ # <%= m.body do %>
405
+ # Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel nisi tempora, eius iste sit nobis
406
+ # earum in harum optio dolore explicabo. Eveniet reprehenderit harum itaque ad fuga beatae, quasi
407
+ # sequi! Laborum ea porro nihil ipsam repudiandae vel harum voluptates minima corrupti unde quas,
408
+ # dolore possimus doloribus voluptatem sint fuga dolores odio dignissimos at molestias earum.
409
+ # <% end %>
410
+ # <%= m.footer do %>
411
+ # <%= m.close_button class: 'btn btn-secondary' do %>
412
+ # Close
413
+ # <% end %>
414
+ # <% end %>
415
+ # <% end %>
416
+ # ```
417
+ #
418
+ # @param [Hash] opts
419
+ # @return [String]
420
+ #
421
+ def modal_helper(opts = {}, &block)
422
+ Modal.new(self, opts, &block)
423
+ end
424
+
425
+ # Generates Nav components.
426
+ #
427
+ # ```erb
428
+ # <%= nav_helper do |nav| %>
429
+ # <%= nav.link "Item 1", "https://www.google.com" %>
430
+ # <%= nav.link "Item 2", "#" %>
431
+ # <%= nav.link "Item 3", "#" %>
432
+ # <%= nav.dropdown :more do |menu| %>
433
+ # <%= menu.link 'People', '#' %>
434
+ # <%= menu.link 'Records', '#' %>
435
+ # <% end %>
436
+ #
437
+ # <%= nav.dropdown "More 2" do |menu| %>
438
+ # <%= menu.link 'People', '#' %>
439
+ # <%= menu.link 'Records', '#' %>
440
+ # <% end %>
441
+ # <% end %>
442
+ # ```
443
+ #
444
+ # @param [Hash] opts
445
+ # @return [String]
446
+ #
447
+ def nav_helper(opts = {}, &block)
448
+ Nav.new(self, opts, &block)
449
+ end
450
+
451
+ # Generates a Tab component.
452
+ #
453
+ # ```erb
454
+ # <%= tab_helper do |tab| %>
455
+ # <%= tab.nav do |nav| %>
456
+ # <%= nav.item :item1 do %>
457
+ # Item 1
458
+ # <% end %>
459
+ # <%= nav.item(:item2, class: 'active') { "Item 2" } %>
460
+ # <%= nav.item(:item3) { "Item 3" } %>
461
+ # <%= nav.item :item4 %>
462
+ # <%= nav.dropdown 'More' do |dropdown| %>
463
+ # <%= dropdown.item :item5 %>
464
+ # <%= dropdown.item(:item6) { 'Item 6' } %>
465
+ # <% end %>
466
+ # <% end %>
467
+ #
468
+ # <%= tab.content do |content| %>
469
+ # <%= content.pane :item1, class: 'mt-3' do %>
470
+ # Content 1
471
+ # <% end %>
472
+ #
473
+ # <%= content.pane :item2, class: 'active mt-3' do %>
474
+ # Content 2
475
+ # <% end %>
476
+ #
477
+ # <%= content.pane :item3, class: 'mt-3' do %>
478
+ # Content 3
479
+ # <% end %>
480
+ #
481
+ # <%= content.pane :item4, class: 'mt-3' do %>
482
+ # Content 4
483
+ # <% end %>
484
+ #
485
+ # <%= content.pane :item5, class: 'mt-3' do %>
486
+ # Content 5
487
+ # <% end %>
488
+ #
489
+ # <%= content.pane :item6, class: 'mt-3' do %>
490
+ # Content 6
491
+ # <% end %>
492
+ # <% end %>
493
+ # <% end %>
494
+ # ```
495
+ # @param [Mixed] args
496
+ # @return [String]
497
+ #
498
+ def tab_helper(*args, &block)
499
+ Tab.new(self, *args, &block)
500
+ end
501
+
502
+ # Generates spinner annimations.
503
+ #
504
+ # ```erb
505
+ # <%= spinner_helper class: 'text-warning' %>
506
+ # <%= spinner_helper type: :grow, class: 'text-danger', id: 'loadingRecords' %>
507
+ # ```
508
+ # @param [Mixed] args
509
+ # @return [String]
510
+ #
511
+ def spinner_helper(*args, &block)
512
+ Spinner.new(self, *args, &block)
513
+ end
5
514
  end