bootstrap4_helper 1.0.1 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +484 -6
- data/lib/bootstrap4_helper.rb +10 -1
- data/lib/bootstrap4_helper/accordion.rb +1 -0
- data/lib/bootstrap4_helper/configuration.rb +2 -1
- data/lib/bootstrap4_helper/constants.rb +1 -0
- data/lib/bootstrap4_helper/page_header.rb +38 -0
- data/lib/bootstrap4_helper/tab/content.rb +3 -2
- data/lib/bootstrap4_helper/version.rb +1 -1
- metadata +16 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5955ec587e3cd9c46b93382fdbfefdb8e19283307e266e3d0d40ff60378c78f5
|
4
|
+
data.tar.gz: 9c6dd4decbd54700ca73bbfc2372fc78360218a6b5fa3b8a21ee08e5b1d39058
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86c09350eb4ed4514d1aa07d1346617920d99c9164e426f1d43c767539a4cd952f86674d4e14c506c3d911c7e0c1998ab0dce41c8ce4f710268b58d874dbb7c6
|
7
|
+
data.tar.gz: 76dd20e7db8086165f1b78c97ebc4de3465db2b44393f847439a1da2ef60a95e1be4a180f6e73da7eb5a16f998604b889b8c613b3e1699f8423f424d7ab6a3ae
|
data/README.md
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
# Bootstrap4Helper
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
## Usage
|
6
|
-
|
7
|
-
How to use my plugin.
|
3
|
+
Simple template helper to build Bootstrap 4 components in Rails views easier.
|
8
4
|
|
9
5
|
## Installation
|
10
6
|
|
@@ -26,9 +22,491 @@ Or install it yourself as:
|
|
26
22
|
$ gem install bootstrap4_helper
|
27
23
|
```
|
28
24
|
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
All of the helpers will be available inside your views. If you wish to stop that behavior and only include the helpers on the views of your choosing, pass the following to the `config` object in a intializer:
|
28
|
+
|
29
|
+
<em>config/initializers/bootstrap4-helper.rb</em>
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
Bootstrap4Helper.config do |config|
|
33
|
+
config.autoload_in_views = false
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
> Note: Almost all the helpers support attributes for `id`, `class` and `data` HTML attributes.
|
38
|
+
|
39
|
+
### Accordion:
|
40
|
+
|
41
|
+
For use with a single, collapsible accordion.
|
42
|
+
|
43
|
+
```erb
|
44
|
+
<%= accordion_helper class: 'text-white bg-primary' do |a| %>
|
45
|
+
<%= a.header do %>
|
46
|
+
// Some HTML or Ruby
|
47
|
+
<% end %>
|
48
|
+
<%= a.body %>
|
49
|
+
// Some HTML or Ruby
|
50
|
+
<% end %>
|
51
|
+
<% end %>
|
52
|
+
```
|
53
|
+
|
54
|
+
### Accordion Groups:
|
55
|
+
|
56
|
+
Use the group helper when you want to have a group of accordions, where one opens and the previous one closes.
|
57
|
+
|
58
|
+
> Note: The helper will handle all the linking of the elements together. If you do pass an id to the parent Dom Element - accordion_grou_helper id: 'some_id', that id will be used for the linking of the element. But you don't have to, unless you have a specific need to.
|
59
|
+
|
60
|
+
```erb
|
61
|
+
<%= accordion_group_helper do |grp| %>
|
62
|
+
<%= grp.accordion do |a| %>
|
63
|
+
<%= a.header class: 'text-white bg-primary' do %>
|
64
|
+
// Some HTML or Ruby
|
65
|
+
<% end %>
|
66
|
+
<%= a.body %>
|
67
|
+
// Some HTML or Ruby
|
68
|
+
<% end %>
|
69
|
+
<% end %>
|
70
|
+
|
71
|
+
<%= grp.accordion do |a| %>
|
72
|
+
<%= a.header class: 'text-white bg-danger' do %>
|
73
|
+
// Some HTML or Ruby
|
74
|
+
<% end %>
|
75
|
+
<%= a.body %>
|
76
|
+
// Some HTML or Ruby
|
77
|
+
<% end %>
|
78
|
+
<% end %>
|
79
|
+
<% end $>
|
80
|
+
```
|
81
|
+
|
82
|
+
### Alerts
|
83
|
+
|
84
|
+
Alerts use the contextual helper, where you can pass one of the states to the object and it will render the appropriate colors.
|
85
|
+
|
86
|
+
```erb
|
87
|
+
<%= alert_helper :danger, dismissble: true do %>
|
88
|
+
Something went wrong with your model data...
|
89
|
+
<% end %>
|
90
|
+
```
|
91
|
+
|
92
|
+
### Badges
|
93
|
+
|
94
|
+
The badge helper will build badges realitively quickly. If you are just passing a String, use the shorter curly brace block syntax. If you plan on building other HTML elements of using other Ruby proceedures, use the do/end method.
|
95
|
+
|
96
|
+
```erb
|
97
|
+
<li>
|
98
|
+
Messages: <%= badge_helper(:primary) { @messages.count } %>
|
99
|
+
</li>
|
100
|
+
<li>
|
101
|
+
Notifications: <%= badge_healper { @notifications.count } %>
|
102
|
+
</li>
|
103
|
+
<li>
|
104
|
+
Users: <%= badge_helper :danger do %>Some HTML / Ruby <% end %>
|
105
|
+
</li>
|
106
|
+
```
|
107
|
+
|
108
|
+
### Cards
|
109
|
+
|
110
|
+
Cards support a few methods that make building them easier:
|
111
|
+
|
112
|
+
- `body`
|
113
|
+
- `header`
|
114
|
+
- `footer`
|
115
|
+
- `image_overlay`
|
116
|
+
- `text`
|
117
|
+
- `title`
|
118
|
+
|
119
|
+
For usage on various card sub components, @see https://getbootstrap.com/docs/4.0/components/card/
|
120
|
+
|
121
|
+
```erb
|
122
|
+
<%# Regular %>
|
123
|
+
|
124
|
+
<%= card_helper do |c| %>
|
125
|
+
<%= c.header class: 'text-white bg-primary' do %>
|
126
|
+
<h4>This is the header...</h4>
|
127
|
+
<% end %>
|
128
|
+
<%= c.body do %>
|
129
|
+
<%= c.title { 'This is the title' } %>
|
130
|
+
<%= c.text { 'This card body' } %>
|
131
|
+
<ul>
|
132
|
+
<% [1, 2, 3].each do |x| %>
|
133
|
+
<li>Item: <%= x %></li>
|
134
|
+
<% end %>
|
135
|
+
</ul>
|
136
|
+
<% end %>
|
137
|
+
<%= c.footer do %>
|
138
|
+
This is the footer...
|
139
|
+
<% end %>
|
140
|
+
<% end %>
|
141
|
+
|
142
|
+
<%# Horizontal %>
|
143
|
+
|
144
|
+
<div class="row">
|
145
|
+
<div class="col-sm mt-3 mb-3">
|
146
|
+
<%= card_helper do |c| %>
|
147
|
+
<div class="row no-gutters">
|
148
|
+
<div class="col-md-4">
|
149
|
+
<%= image_tag 'placeholder.svg', class: 'card-img' %>
|
150
|
+
</div>
|
151
|
+
<div class="col-md-8">
|
152
|
+
<%= c.body do %>
|
153
|
+
<%= c.title { "Card title" } %>
|
154
|
+
<%= c.text { "This is a wider card with supporting text below as a natural lead-in to additional content." } %>
|
155
|
+
<%= c.text do %>
|
156
|
+
<small class="text-muted">Last updated 3 mins ago</small>
|
157
|
+
<% end %>
|
158
|
+
<% end %>
|
159
|
+
</div>
|
160
|
+
</div>
|
161
|
+
<% end %>
|
162
|
+
</div>
|
163
|
+
</div>
|
164
|
+
```
|
165
|
+
|
166
|
+
### Card Groups
|
167
|
+
|
168
|
+
Card Groups are a group of cards.
|
169
|
+
|
170
|
+
> Use card groups to render cards as a single, attached element with equal width and height columns. Card groups use display: flex; to achieve their uniform sizing. - Bootstrap Docs
|
171
|
+
|
172
|
+
```erb
|
173
|
+
<%= card_group_helper do |group| %>
|
174
|
+
<%= group.card do |c| %>
|
175
|
+
<%= c.body do %>
|
176
|
+
<%= c.title { 'This is the title one' } %>
|
177
|
+
<%= c.text { 'This card body' } %>
|
178
|
+
<ul>
|
179
|
+
<% [1, 2, 3, 4, 5, 6, 7].each do |x| %>
|
180
|
+
<li>Item: <%= x %></li>
|
181
|
+
<% end %>
|
182
|
+
</ul>
|
183
|
+
<% end %>
|
184
|
+
<%= c.footer do %>
|
185
|
+
This is the footer...
|
186
|
+
<% end %>
|
187
|
+
<% end %>
|
188
|
+
<%= group.card do |c| %>
|
189
|
+
<%= c.body do %>
|
190
|
+
<%= c.title { 'This is the title two' } %>
|
191
|
+
<%= c.text { 'This card body' } %>
|
192
|
+
<ul>
|
193
|
+
<% [1, 2, 3].each do |x| %>
|
194
|
+
<li>Item: <%= x %></li>
|
195
|
+
<% end %>
|
196
|
+
</ul>
|
197
|
+
<% end %>
|
198
|
+
<%= c.footer do %>
|
199
|
+
This is the footer...
|
200
|
+
<% end %>
|
201
|
+
<% end %>
|
202
|
+
<%= group.card do |c| %>
|
203
|
+
<%= c.body do %>
|
204
|
+
<%= c.title { 'This is the title three' } %>
|
205
|
+
<%= c.text { 'This card body' } %>
|
206
|
+
<ul>
|
207
|
+
<% [1, 2, 3].each do |x| %>
|
208
|
+
<li>Item: <%= x %></li>
|
209
|
+
<% end %>
|
210
|
+
</ul>
|
211
|
+
<% end %>
|
212
|
+
<%= c.footer do %>
|
213
|
+
This is the footer...
|
214
|
+
<% end %>
|
215
|
+
<% end %>
|
216
|
+
<% end %>
|
217
|
+
```
|
218
|
+
|
219
|
+
### Card Decks
|
220
|
+
|
221
|
+
Card Decks are for, well, decks of cards :D
|
222
|
+
|
223
|
+
> Need a set of equal width and height cards that aren’t attached to one another? Use card decks. - Bootstrap 4 Docs
|
224
|
+
|
225
|
+
```erb
|
226
|
+
<%= card_deck_helper do |deck| %>
|
227
|
+
<%= deck.card do |c| %>
|
228
|
+
<%= c.body do %>
|
229
|
+
<%= c.title { 'This is the title one' } %>
|
230
|
+
<%= c.text { 'This card body' } %>
|
231
|
+
<ul>
|
232
|
+
<% [1, 2, 3, 4, 5, 6, 7].each do |x| %>
|
233
|
+
<li>Item: <%= x %></li>
|
234
|
+
<% end %>
|
235
|
+
</ul>
|
236
|
+
<% end %>
|
237
|
+
<%= c.footer do %>
|
238
|
+
This is the footer...
|
239
|
+
<% end %>
|
240
|
+
<% end %>
|
241
|
+
<%= deck.card do |c| %>
|
242
|
+
<%= c.body do %>
|
243
|
+
<%= c.title { 'This is the title two' } %>
|
244
|
+
<%= c.text { 'This card body' } %>
|
245
|
+
<ul>
|
246
|
+
<% [1, 2, 3].each do |x| %>
|
247
|
+
<li>Item: <%= x %></li>
|
248
|
+
<% end %>
|
249
|
+
</ul>
|
250
|
+
<% end %>
|
251
|
+
<%= c.footer do %>
|
252
|
+
This is the footer...
|
253
|
+
<% end %>
|
254
|
+
<% end %>
|
255
|
+
<%= deck.card do |c| %>
|
256
|
+
<%= c.body do %>
|
257
|
+
<%= c.title { 'This is the title three' } %>
|
258
|
+
<%= c.text { 'This card body' } %>
|
259
|
+
<ul>
|
260
|
+
<% [1, 2, 3].each do |x| %>
|
261
|
+
<li>Item: <%= x %></li>
|
262
|
+
<% end %>
|
263
|
+
</ul>
|
264
|
+
<% end %>
|
265
|
+
<%= c.footer do %>
|
266
|
+
This is the footer...
|
267
|
+
<% end %>
|
268
|
+
<% end %>
|
269
|
+
<% end %>
|
270
|
+
```
|
271
|
+
|
272
|
+
### Card Columns
|
273
|
+
|
274
|
+
Build Card Columns.
|
275
|
+
|
276
|
+
> Cards are built with CSS column properties instead of flexbox for easier alignment. Cards are ordered from top to bottom and left to right.
|
277
|
+
>
|
278
|
+
> Heads up! Your mileage with card columns may vary. To prevent cards breaking across columns, we must set them to display: inline-block as column-break-inside: avoid isn’t a bulletproof solution yet. <br>- Bootstrap Docs
|
279
|
+
|
280
|
+
```erb
|
281
|
+
<%= card_column_helper do |column| %>
|
282
|
+
<%= column.card do |c| %>
|
283
|
+
<%= c.body do %>
|
284
|
+
<%= c.title { 'This is the title one' } %>
|
285
|
+
<%= c.text { 'This card body' } %>
|
286
|
+
<ul>
|
287
|
+
<% [1, 2, 3, 4, 5, 6, 7].each do |x| %>
|
288
|
+
<li>Item: <%= x %></li>
|
289
|
+
<% end %>
|
290
|
+
</ul>
|
291
|
+
<% end %>
|
292
|
+
<%= c.footer do %>
|
293
|
+
This is the footer...
|
294
|
+
<% end %>
|
295
|
+
<% end %>
|
296
|
+
<%= column.card do |c| %>
|
297
|
+
<%= c.body do %>
|
298
|
+
<%= c.title { 'This is the title two' } %>
|
299
|
+
<%= c.text { 'This card body' } %>
|
300
|
+
<ul>
|
301
|
+
<% [1, 2, 3].each do |x| %>
|
302
|
+
<li>Item: <%= x %></li>
|
303
|
+
<% end %>
|
304
|
+
</ul>
|
305
|
+
<% end %>
|
306
|
+
<%= c.footer do %>
|
307
|
+
This is the footer...
|
308
|
+
<% end %>
|
309
|
+
<% end %>
|
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
|
+
### Dropdowns
|
328
|
+
|
329
|
+
Generates a Dropdown component. Default type `:dropdown`. For inline buttons, use `:group`.
|
330
|
+
|
331
|
+
Dropdowns support the following methods:
|
332
|
+
|
333
|
+
- `button`
|
334
|
+
- `menu`
|
335
|
+
- `item` - Use this method when you are using the item in the menu as trigger for tab content.
|
336
|
+
- `link` - Use this method when the item in the menu is nothing more than a hyperlink.
|
337
|
+
- `text` - simple text
|
338
|
+
- `header` - Is a header item
|
339
|
+
- `divider` - A dividing element
|
340
|
+
|
341
|
+
```erb
|
342
|
+
<%= dropdown_helper do |dropdown| %>
|
343
|
+
<%= dropdown.button(:primary) { "Action" } %>
|
344
|
+
<%= dropdown.menu do |menu| %>
|
345
|
+
<%= menu.link 'Edit', '#' %>
|
346
|
+
<%= menu.link 'Delete', '#' %>
|
347
|
+
<%= menu.text 'Static text' %>
|
348
|
+
<% end %>
|
349
|
+
<% end %>
|
350
|
+
|
351
|
+
<%= dropdown_helper :group, class: 'dropright' do |dropdown| %>
|
352
|
+
<button type="button" class="btn btn-danger">Action 2</button>
|
353
|
+
<%= dropdown.button(:danger, split: true) %>
|
354
|
+
<%= dropdown.menu do |menu| %>
|
355
|
+
<%= menu.header "Crud operations" %>
|
356
|
+
<%= menu.divider %>
|
357
|
+
<%= menu.link 'Edit', 'SOME-URL' %>
|
358
|
+
<%= menu.link 'Delete', 'SOME-URL' %>
|
359
|
+
<% end %>
|
360
|
+
<% end %>
|
361
|
+
|
362
|
+
<%= dropdown_helper do |dropdown| %>
|
363
|
+
<%= dropdown.button :primary do %>
|
364
|
+
<i class="fas fa-users"></i> User
|
365
|
+
<% end %>
|
366
|
+
<%= dropdown.menu do |menu| %>
|
367
|
+
<form class="px-4 py-3">
|
368
|
+
<div class="form-group">
|
369
|
+
<label for="exampleDropdownFormEmail1">Email address</label>
|
370
|
+
<input type="email" class="form-control" id="exampleDropdownFormEmail1" placeholder="email@example.com">
|
371
|
+
</div>
|
372
|
+
<div class="form-group">
|
373
|
+
<label for="exampleDropdownFormPassword1">Password</label>
|
374
|
+
<input type="password" class="form-control" id="exampleDropdownFormPassword1" placeholder="Password">
|
375
|
+
</div>
|
376
|
+
<div class="form-group">
|
377
|
+
<div class="form-check">
|
378
|
+
<input type="checkbox" class="form-check-input" id="dropdownCheck">
|
379
|
+
<label class="form-check-label" for="dropdownCheck">
|
380
|
+
Remember me
|
381
|
+
</label>
|
382
|
+
</div>
|
383
|
+
</div>
|
384
|
+
<button type="submit" class="btn btn-primary">Sign in</button>
|
385
|
+
</form>
|
386
|
+
<%= menu.divider %>
|
387
|
+
<%= menu.link "New around here? Sign up", "#" %>
|
388
|
+
<%= menu.link "Forgot password", "#" %>
|
389
|
+
<% end %>
|
390
|
+
<% end %>
|
391
|
+
```
|
392
|
+
|
393
|
+
### Modals
|
394
|
+
|
395
|
+
Builds a modal window.
|
396
|
+
|
397
|
+
> Note: When the `close_button` is not passed a block, it will default to the X icon.
|
398
|
+
|
399
|
+
```erb
|
400
|
+
<%= modal_helper id: 'exampleModal' do |m| %>
|
401
|
+
<%= m.header do %>
|
402
|
+
<%= m.title { 'Example Modal' } %>
|
403
|
+
<%= m.close_button %>
|
404
|
+
<% end %>
|
405
|
+
<%= m.body do %>
|
406
|
+
Lorem ipsum dolor sit amet consectetur adipisicing elit. Vel nisi tempora, eius iste sit nobis
|
407
|
+
earum in harum optio dolore explicabo. Eveniet reprehenderit harum itaque ad fuga beatae, quasi
|
408
|
+
sequi! Laborum ea porro nihil ipsam repudiandae vel harum voluptates minima corrupti unde quas,
|
409
|
+
dolore possimus doloribus voluptatem sint fuga dolores odio dignissimos at molestias earum.
|
410
|
+
<% end %>
|
411
|
+
<%= m.footer do %>
|
412
|
+
<%= m.close_button class: 'btn btn-secondary' do %>
|
413
|
+
Close
|
414
|
+
<% end %>
|
415
|
+
<% end %>
|
416
|
+
<% end %>
|
417
|
+
```
|
418
|
+
|
419
|
+
### Navs
|
420
|
+
|
421
|
+
For building nav components. The Nav compoent has the following methods:
|
422
|
+
|
423
|
+
- `dropwdown` - @see Dropdown for list of methods
|
424
|
+
- `item`
|
425
|
+
- `link`
|
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
|
+
### Tabs
|
445
|
+
|
446
|
+
For building Tab components.
|
447
|
+
|
448
|
+
> Note: The tab helper responds to the `type:` and there are two types, `:tabs` and `:pills`. The default is `:tabs`.
|
449
|
+
>
|
450
|
+
> Example:
|
451
|
+
> `<%= tab_helper type: :pills do |tab| %>`
|
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
|
+
|
496
|
+
### Spinners
|
497
|
+
|
498
|
+
Creates CSS spinner components. Supports two types: `:border` and `:grow`. Teh default is `:border`
|
499
|
+
|
500
|
+
```erb
|
501
|
+
<%= spinner_helper class: 'text-warning' %>
|
502
|
+
<%= spinner_helper type: :grow, class: 'text-danger', id: 'loadingRecords' %>
|
503
|
+
```
|
504
|
+
|
29
505
|
## Contributing
|
30
506
|
|
31
|
-
|
507
|
+
If you would like to contribution, by all means, do a PR and send up your suggestions.
|
508
|
+
|
509
|
+
If there are components you would like to see added, open an issue and I will try to get to them, or you can do a PR and add them yourself :D
|
32
510
|
|
33
511
|
## License
|
34
512
|
|
data/lib/bootstrap4_helper.rb
CHANGED
@@ -82,7 +82,7 @@ module Bootstrap4Helper
|
|
82
82
|
Alert.new(self, *args, &block)
|
83
83
|
end
|
84
84
|
|
85
|
-
# Creates a badge component.
|
85
|
+
# Creates a badge component. Badges have a context variable. Providing nothing
|
86
86
|
# will give you the `secondary` context.
|
87
87
|
#
|
88
88
|
# ```erb
|
@@ -448,6 +448,15 @@ module Bootstrap4Helper
|
|
448
448
|
Nav.new(self, opts, &block)
|
449
449
|
end
|
450
450
|
|
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
|
+
|
451
460
|
# Generates a Tab component.
|
452
461
|
#
|
453
462
|
# ```erb
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Bootstrap4Helper
|
2
|
+
# Builds a simple CSS spinner component.
|
3
|
+
#
|
4
|
+
#
|
5
|
+
class PageHeader < Component
|
6
|
+
# Class constructor
|
7
|
+
#
|
8
|
+
# @param [ActionView] template
|
9
|
+
# @param [Hash] opts
|
10
|
+
# @option opts [String] :id
|
11
|
+
# @option opts [String] :class
|
12
|
+
# @option opts [Hash] :data
|
13
|
+
#
|
14
|
+
def initialize(template, opts = {}, &block)
|
15
|
+
super(template)
|
16
|
+
|
17
|
+
@id = opts.fetch(:id, uuid)
|
18
|
+
@class = opts.fetch(:class, '')
|
19
|
+
@data = opts.fetch(:data, {})
|
20
|
+
@content = block || proc { '' }
|
21
|
+
end
|
22
|
+
|
23
|
+
# String representation of the object.
|
24
|
+
#
|
25
|
+
# @return [String]
|
26
|
+
#
|
27
|
+
def to_s
|
28
|
+
content_tag(
|
29
|
+
config(:page_header, :h1),
|
30
|
+
id: @id,
|
31
|
+
class: "pb-2 mt-4 mb-2 border-bottom #{@class}",
|
32
|
+
data: @data
|
33
|
+
) do
|
34
|
+
@content.call(self)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -24,18 +24,19 @@ module Bootstrap4Helper
|
|
24
24
|
# Builds the pane for the tab.
|
25
25
|
#
|
26
26
|
# @param [Symbol] source
|
27
|
-
# @param [Hash]
|
27
|
+
# @param [Hash] opts
|
28
28
|
# @option opts [String] :class
|
29
29
|
# @option opts [Hash] :data
|
30
30
|
# @return [String]
|
31
31
|
#
|
32
32
|
def pane(source, opts = {}, &block)
|
33
|
+
id = opts.fetch(:id, source)
|
33
34
|
klass = opts.fetch(:class, '')
|
34
35
|
data = opts.fetch(:data, {})
|
35
36
|
|
36
37
|
content_tag(
|
37
38
|
:div,
|
38
|
-
id:
|
39
|
+
id: id,
|
39
40
|
class: "tab-pane #{klass}",
|
40
41
|
role: 'tabpanel',
|
41
42
|
data: data,
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstrap4_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
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-
|
11
|
+
date: 2020-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '4.2'
|
20
|
+
- - "<="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 7.0.0
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '4.2'
|
30
|
+
- - "<="
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
32
|
+
version: 7.0.0
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: bootstrap
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +64,14 @@ dependencies:
|
|
58
64
|
requirements:
|
59
65
|
- - "~>"
|
60
66
|
- !ruby/object:Gem::Version
|
61
|
-
version: 5.2.
|
67
|
+
version: 5.2.4
|
62
68
|
type: :development
|
63
69
|
prerelease: false
|
64
70
|
version_requirements: !ruby/object:Gem::Requirement
|
65
71
|
requirements:
|
66
72
|
- - "~>"
|
67
73
|
- !ruby/object:Gem::Version
|
68
|
-
version: 5.2.
|
74
|
+
version: 5.2.4
|
69
75
|
- !ruby/object:Gem::Dependency
|
70
76
|
name: redcarpet
|
71
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,6 +156,7 @@ files:
|
|
150
156
|
- lib/bootstrap4_helper/initialize.rb
|
151
157
|
- lib/bootstrap4_helper/modal.rb
|
152
158
|
- lib/bootstrap4_helper/nav.rb
|
159
|
+
- lib/bootstrap4_helper/page_header.rb
|
153
160
|
- lib/bootstrap4_helper/railtie.rb
|
154
161
|
- lib/bootstrap4_helper/spinner.rb
|
155
162
|
- lib/bootstrap4_helper/tab.rb
|
@@ -175,8 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
182
|
- !ruby/object:Gem::Version
|
176
183
|
version: '0'
|
177
184
|
requirements: []
|
178
|
-
|
179
|
-
rubygems_version: 2.7.6
|
185
|
+
rubygems_version: 3.1.3
|
180
186
|
signing_key:
|
181
187
|
specification_version: 4
|
182
188
|
summary: Library for rapidly building bootstrap 4 components
|