bh 1.3.6 → 6.0.0
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 +5 -5
- data/CHANGELOG.md +4 -0
- data/README.md +8 -138
- data/app/assets/stylesheets/bh.css +29 -0
- data/app/javascript/controllers/bh/theme_controller.js +17 -0
- data/app/views/bh/_grid.html.erb +6 -0
- data/app/views/bh/_table.html.erb +46 -0
- data/bh.gemspec +5 -30
- data/lib/bh/bootstrap_helpers.rb +131 -0
- data/lib/bh/engine.rb +13 -0
- data/lib/bh/version.rb +3 -1
- data/lib/bh.rb +6 -14
- metadata +14 -284
- data/examples/middleman/.gitignore +0 -18
- data/examples/middleman/Gemfile +0 -6
- data/examples/middleman/config.rb +0 -1
- data/examples/middleman/source/index.html.erb +0 -158
- data/examples/padrino/Gemfile +0 -9
- data/examples/padrino/app/app.rb +0 -16
- data/examples/padrino/app/views/index.html.erb +0 -155
- data/examples/padrino/config/apps.rb +0 -5
- data/examples/padrino/config/boot.rb +0 -8
- data/examples/padrino/config.ru +0 -5
- data/examples/rails/.gitignore +0 -12
- data/examples/rails/Gemfile +0 -5
- data/examples/rails/app/controllers/application_controller.rb +0 -6
- data/examples/rails/app/controllers/users_controller.rb +0 -2
- data/examples/rails/app/models/user.rb +0 -15
- data/examples/rails/app/views/application/index.html.erb +0 -160
- data/examples/rails/bin/rails +0 -4
- data/examples/rails/config/application.rb +0 -12
- data/examples/rails/config/boot.rb +0 -3
- data/examples/rails/config/environment.rb +0 -5
- data/examples/rails/config/environments/development.rb +0 -7
- data/examples/rails/config/routes.rb +0 -4
- data/examples/rails/config/secrets.yml +0 -22
- data/examples/rails/config.ru +0 -4
- data/examples/rails/log/.keep +0 -0
- data/lib/bh/classes/alert_box.rb +0 -35
- data/lib/bh/classes/base.rb +0 -125
- data/lib/bh/classes/button.rb +0 -58
- data/lib/bh/classes/button_to.rb +0 -33
- data/lib/bh/classes/cdn.rb +0 -35
- data/lib/bh/classes/dropdown.rb +0 -56
- data/lib/bh/classes/icon.rb +0 -34
- data/lib/bh/classes/link_to.rb +0 -26
- data/lib/bh/classes/modal.rb +0 -68
- data/lib/bh/classes/nav.rb +0 -37
- data/lib/bh/classes/navbar.rb +0 -78
- data/lib/bh/classes/panel.rb +0 -72
- data/lib/bh/classes/panel_row.rb +0 -13
- data/lib/bh/classes/progress_bar.rb +0 -89
- data/lib/bh/classes/stack.rb +0 -19
- data/lib/bh/classes/vertical.rb +0 -27
- data/lib/bh/core_ext/middleman.rb +0 -24
- data/lib/bh/core_ext/padrino.rb +0 -25
- data/lib/bh/core_ext/rails/base_helper.rb +0 -21
- data/lib/bh/core_ext/rails/form/base_helper.rb +0 -150
- data/lib/bh/core_ext/rails/form/check_box_helper.rb +0 -35
- data/lib/bh/core_ext/rails/form/field_helper.rb +0 -15
- data/lib/bh/core_ext/rails/form/fields_for_helper.rb +0 -23
- data/lib/bh/core_ext/rails/form/fieldset_helper.rb +0 -16
- data/lib/bh/core_ext/rails/form/file_field_helper.rb +0 -15
- data/lib/bh/core_ext/rails/form/legend_helper.rb +0 -17
- data/lib/bh/core_ext/rails/form/radio_button_helper.rb +0 -19
- data/lib/bh/core_ext/rails/form/select_helper.rb +0 -16
- data/lib/bh/core_ext/rails/form/static_control_helper.rb +0 -43
- data/lib/bh/core_ext/rails/form/submit_helper.rb +0 -23
- data/lib/bh/core_ext/rails/form_builder.rb +0 -46
- data/lib/bh/core_ext/rails/form_for_helper.rb +0 -41
- data/lib/bh/core_ext/railtie.rb +0 -27
- data/lib/bh/helpers/alert_box_helper.rb +0 -40
- data/lib/bh/helpers/button_helper.rb +0 -40
- data/lib/bh/helpers/button_to_helper.rb +0 -65
- data/lib/bh/helpers/cdn_helper.rb +0 -46
- data/lib/bh/helpers/dropdown_helper.rb +0 -49
- data/lib/bh/helpers/glyphicon_helper.rb +0 -18
- data/lib/bh/helpers/horizontal_helper.rb +0 -35
- data/lib/bh/helpers/icon_helper.rb +0 -27
- data/lib/bh/helpers/link_to_helper.rb +0 -59
- data/lib/bh/helpers/modal_helper.rb +0 -55
- data/lib/bh/helpers/nav_helper.rb +0 -36
- data/lib/bh/helpers/navbar_helper.rb +0 -48
- data/lib/bh/helpers/panel_helper.rb +0 -53
- data/lib/bh/helpers/panel_row_helper.rb +0 -28
- data/lib/bh/helpers/progress_bar_helper.rb +0 -55
- data/lib/bh/helpers/vertical_helper.rb +0 -33
- data/lib/bh/views/bh/_alert_dismiss_button.html +0 -4
- data/lib/bh/views/bh/_dropdown.html.erb +0 -9
- data/lib/bh/views/bh/_dropdown_split.html.erb +0 -10
- data/lib/bh/views/bh/_modal.html.erb +0 -14
- data/lib/bh/views/bh/_navbar.html.erb +0 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 69696e91234843a608d61dc3e40ee1016a5f53b393937edb1f31cef2ec31afe3
|
|
4
|
+
data.tar.gz: 44e44d2395418f1a0fcf9eb87846348bb433aed10e0669e1a8c1279045de1147
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eca07106a30e3638225040b503e983f89f90320ed5f027af5f29f1d1d5ee0d559f7257d6042d52e07b0b948b5d536c643a910698ec8b017ecf09e012f3f49b56
|
|
7
|
+
data.tar.gz: eb1049d9e7f10328eeea23fc229ce0911da5ab37bedf29cfe60c07d734b6fccd3a5c11a0bc1ed1ec1743e8953bcb44fab30a49d572a14846c85412c15143ac1b
|
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,10 @@ For more information about changelogs, check
|
|
|
6
6
|
[Keep a Changelog](http://keepachangelog.com) and
|
|
7
7
|
[Vandamme](http://tech-angels.github.io/vandamme).
|
|
8
8
|
|
|
9
|
+
## 6.0.0 - 2026-02-18
|
|
10
|
+
|
|
11
|
+
* [BREAKING FIXES] Literally everything changed. Moving from Bootstrap 3 to Bootstrap 6.
|
|
12
|
+
|
|
9
13
|
## 1.3.6 - 2015-12-18
|
|
10
14
|
|
|
11
15
|
* [ENHANCEMENT] Bump versions of asset libraries
|
data/README.md
CHANGED
|
@@ -2,149 +2,19 @@ Bh · Bootstrap Helpers
|
|
|
2
2
|
======================
|
|
3
3
|
|
|
4
4
|
A set of Ruby helpers that streamlines the use of
|
|
5
|
-
[Bootstrap
|
|
5
|
+
[Bootstrap 6 components](https://deploy-preview-42067--twbs-bootstrap.netlify.app/) in HTML views.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
[](https://travis-ci.org/Fullscreen/bh)
|
|
10
|
-
[](https://coveralls.io/r/Fullscreen/bh)
|
|
11
|
-
[](https://gemnasium.com/Fullscreen/bh)
|
|
12
|
-
[](https://codeclimate.com/github/Fullscreen/bh)
|
|
13
|
-
[](http://www.rubydoc.info/github/Fullscreen/bh/master/Bh/Helpers)
|
|
14
|
-
[](http://rubygems.org/gems/bh)
|
|
15
|
-
|
|
16
|
-
Bootstrap 3 is a great framework, but requires many lines of HTML code
|
|
7
|
+
Bootstrap 6 is a great framework, but requires many lines of HTML code
|
|
17
8
|
even for simple components.
|
|
18
|
-
For instance, you need to write the following HTML to show a _dismissible alert_:
|
|
19
|
-
|
|
20
|
-
```html
|
|
21
|
-
<div class="alert alert-info alert-dismissible" role="alert">
|
|
22
|
-
<button type="button" class="close" data-dismiss="alert">
|
|
23
|
-
<span aria-hidden="true">×</span>
|
|
24
|
-
<span class="sr-only">Close</span>
|
|
25
|
-
</button>
|
|
26
|
-
You accepted the Terms of service.
|
|
27
|
-
</div>
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
Writing this for every _dismissible alert_ is cumbersome,
|
|
31
|
-
repetitive, and prone to errors.
|
|
32
9
|
|
|
33
|
-
With Bh, you can achieve the same result with
|
|
34
|
-
|
|
35
|
-
```rhtml
|
|
36
|
-
<%= alert_box 'You accepted the Terms of service.', dismissible: true %>
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
`alert_box` is only one of the helpers provided by Bh.
|
|
40
|
-
The other ones are: `bootstrap_css`, `bootstrap_js`, `bootstrap_theme_css`,
|
|
41
|
-
`button_to`, `button`, `dropdown`, `font_awesome_css`, `form_for`,
|
|
42
|
-
`icon`, `modal`, `navbar`, `nav`, `panel_row`, `panel` and `progress_bar`.
|
|
10
|
+
With Bh, you can achieve the same result with fewer lines of code
|
|
43
11
|
|
|
44
12
|
How to install
|
|
45
13
|
==============
|
|
46
14
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
To include the Bh gem in your project:
|
|
50
|
-
|
|
51
|
-
1. Add `gem 'bh', '~> 1.3'` to the `Gemfile` file of your Rails, Padrino or Middleman project.
|
|
52
|
-
2. *Only if you are using Middleman*: open `config.rb` and add `activate :bh`.
|
|
53
|
-
3. *Only if you are using Padrino*: open `app.rb` and add `register Bh`.
|
|
54
|
-
|
|
55
|
-
That’s all!
|
|
56
|
-
From now on, you will be able to use any Bh helper in your views.
|
|
57
|
-
|
|
58
|
-
A comprehensive guide to Bh helpers
|
|
59
|
-
===================================
|
|
60
|
-
|
|
61
|
-
All the helpers available in Bh are detailed on the [Bh homepage](http://fullscreen.github.io/bh):
|
|
62
|
-
|
|
63
|
-
[](http://fullscreen.github.io/bh)
|
|
64
|
-
|
|
65
|
-
Please proceed to [http://fullscreen.github.io/bh](http://fullscreen.github.io/bh) for more details and examples on how to use Bh.
|
|
66
|
-
|
|
67
|
-
How to try it in your browser
|
|
68
|
-
=============================
|
|
69
|
-
|
|
70
|
-
The `examples` folder includes three sample apps that you can rapidly run in
|
|
71
|
-
your browser and edit as you please, in order to visually appreciate the result
|
|
72
|
-
of Bh.
|
|
73
|
-
|
|
74
|
-
If you’d like to run the _test Rails app_:
|
|
75
|
-
|
|
76
|
-
1. Download the source code
|
|
77
|
-
1. `cd` into the `examples/rails` folder
|
|
78
|
-
1. Run `bundle install`
|
|
79
|
-
1. Run `bundle exec rails server`
|
|
80
|
-
1. Point your browser to [http://0.0.0.0:3000](http://0.0.0.0:3000)
|
|
81
|
-
|
|
82
|
-
If you prefer to see the helpers inside a _test Middleman app_:
|
|
83
|
-
|
|
84
|
-
1. Download the source code
|
|
85
|
-
1. `cd` into the `examples/middleman` folder
|
|
86
|
-
1. Run `bundle install`
|
|
87
|
-
1. Run `bundle exec middleman`
|
|
88
|
-
1. Point your browser to [http://0.0.0.0:4567](http://0.0.0.0:4567)
|
|
89
|
-
|
|
90
|
-
If you prefer to see the helpers inside a _test Padrino app_:
|
|
15
|
+
1. Add `gem 'bh'` to the `Gemfile` file of your Rails app.
|
|
16
|
+
2. Add this line to the `config/importmap.rb` file:
|
|
91
17
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
1. Run `bundle padrino start`
|
|
96
|
-
1. Point your browser to [http://0.0.0.0:3000](http://0.0.0.0:3000)
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
How to update
|
|
100
|
-
=============
|
|
101
|
-
|
|
102
|
-
Bh strictly follows [Semantic Versioning](http://semver.org).
|
|
103
|
-
By indicating the version number in the *'~> major.minor'* format in your
|
|
104
|
-
Gemfile, you are guaranteed that that your project won’t break when you
|
|
105
|
-
`bundle update` to a new version.
|
|
106
|
-
|
|
107
|
-
Whenever a new version is released, the [CHANGELOG file](https://github.com/claudiob/bh/blob/master/CHANGELOG.md)
|
|
108
|
-
will include a description of what features have changed and how to upgrade
|
|
109
|
-
your code, if necessary.
|
|
110
|
-
|
|
111
|
-
The full [history of Bh versions](https://gemnasium.com/gems/bh/versions) is also available.
|
|
112
|
-
|
|
113
|
-
To stay updated with the latest releases, to receive code examples,
|
|
114
|
-
implementation details and announcements, please consider subscribing to the
|
|
115
|
-
[Bh mailing list](http://eepurl.com/2Hwfb):
|
|
116
|
-
|
|
117
|
-
[](http://eepurl.com/2Hwfb)
|
|
118
|
-
|
|
119
|
-
How to release new versions
|
|
120
|
-
===========================
|
|
121
|
-
|
|
122
|
-
If you are a manager of this project, remember to upgrade the [Bh gem](http://rubygems.org/gems/bh)
|
|
123
|
-
whenever a new feature is added or a bug gets fixed.
|
|
124
|
-
|
|
125
|
-
Make sure all the tests are passing on [Travis CI](https://travis-ci.org/Fullscreen/bh),
|
|
126
|
-
document the changes in CHANGELOG.md and README.md, bump the version, then run
|
|
127
|
-
|
|
128
|
-
rake release
|
|
129
|
-
|
|
130
|
-
Remember that the bh gem follows [Semantic Versioning](http://semver.org).
|
|
131
|
-
|
|
132
|
-
Any new release that makes backward-compatible bug fixes should bump the *patch* version (1.1.x).
|
|
133
|
-
|
|
134
|
-
Any new release that adds backward-compatible features should bump the *minor* version (1.x.0).
|
|
135
|
-
|
|
136
|
-
Any new version that breaks compatibility should bump the *major* version (2.0.0)
|
|
137
|
-
|
|
138
|
-
How to contribute
|
|
139
|
-
=================
|
|
140
|
-
|
|
141
|
-
Bh needs your support!
|
|
142
|
-
|
|
143
|
-
If you find that a method is missing, fork the project, add the missing code,
|
|
144
|
-
write the appropriate tests, then submit a pull request, and it will gladly
|
|
145
|
-
be merged!
|
|
146
|
-
|
|
147
|
-
To run the tests, simply type `bundle exec rspec` on the command line.
|
|
148
|
-
|
|
149
|
-
Don’t hesitate to send code pull requests through GitHub
|
|
150
|
-
and to spread the love. And [don’t click here](http://bit.ly/move-to-la)! Thanks! :)
|
|
18
|
+
```ruby
|
|
19
|
+
pin_all_from Bh::Engine.root.join('app/javascript/controllers'), under: 'controllers'
|
|
20
|
+
```
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file contains overrides to Bootstrap styles.
|
|
3
|
+
*
|
|
4
|
+
* Each override must be justified and explained with a comment.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/* ensure highlighted text from a search is not separated from the rest of the word */
|
|
8
|
+
mark { padding: 0 }
|
|
9
|
+
|
|
10
|
+
/* make the base font size readable */
|
|
11
|
+
:root {--bs-body-font-size: 1rem}
|
|
12
|
+
|
|
13
|
+
/* ensure a field placeholder is not confused for an actual value */
|
|
14
|
+
.form-control::placeholder { opacity: 0.35 }
|
|
15
|
+
|
|
16
|
+
/* make radio buttons bigger */
|
|
17
|
+
input[type=radio] { transform:scale(1.5); margin-right: .75rem }
|
|
18
|
+
|
|
19
|
+
/* make the label around radio buttons colored when checked */
|
|
20
|
+
label:has(input[type=radio]:checked) { background-color: var(--bs-primary-bg-subtle); border-color: var(--bs-primary-border) }
|
|
21
|
+
|
|
22
|
+
/* Fixes bugs in Bootstrap 6.0@alpha1 where some colors are undefined */
|
|
23
|
+
.form-text { color: var(--bs-secondary-text) }
|
|
24
|
+
:root {
|
|
25
|
+
--bs-form-valid-color: var(--bs-success-text);
|
|
26
|
+
--bs-form-valid-border-color: var(--bs-success-border);
|
|
27
|
+
--bs-form-invalid-color: var(--bs-danger-text);
|
|
28
|
+
--bs-form-invalid-border-color: var(--bs-danger-border);
|
|
29
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
|
2
|
+
|
|
3
|
+
// Toggle color theme between dark and light when the element is clicked.
|
|
4
|
+
export default class extends Controller {
|
|
5
|
+
connect() {
|
|
6
|
+
console.log('connected')
|
|
7
|
+
document.documentElement.setAttribute('data-bs-theme', localStorage.getItem('theme'))
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// Toggle color theme between dark and light when the element is clicked.
|
|
11
|
+
toggle() {
|
|
12
|
+
const oldTheme = localStorage.getItem('theme') || 'light'
|
|
13
|
+
const newTheme = ((oldTheme == 'light') ? 'dark' : 'light')
|
|
14
|
+
document.documentElement.setAttribute('data-bs-theme', newTheme)
|
|
15
|
+
localStorage.setItem('theme', newTheme)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<%# locals: (items:, empty_label:, positioned: false, cached: true, headers: [], pagy: nil) -%>
|
|
2
|
+
<% cache_if cached, [items, (items.unscoped.size if cached)].compact do %>
|
|
3
|
+
<%= turbo_frame_tag :results, data: { turbo_action: :advance }, class: 'w-100' do %>
|
|
4
|
+
<% if items.present? %>
|
|
5
|
+
<table class='table caption-top table-hover table-responsive'>
|
|
6
|
+
<thead>
|
|
7
|
+
<tr>
|
|
8
|
+
<% if positioned %>
|
|
9
|
+
<th scope='col'></th>
|
|
10
|
+
<% end %>
|
|
11
|
+
<% headers.each do |header| %>
|
|
12
|
+
<th scope='col'><%= header %></th>
|
|
13
|
+
<% end %>
|
|
14
|
+
</tr>
|
|
15
|
+
</thead>
|
|
16
|
+
<% if positioned %>
|
|
17
|
+
<tbody class='table-group-divider' data-controller='sortable' data-sortable-handle-value='.sortable-handle' data-sortable-resource-name-value='<%= ActiveModel::Naming.param_key items %>' data-sortable-animation-value='200'>
|
|
18
|
+
<% else %>
|
|
19
|
+
<tbody class='table-group-divider'>
|
|
20
|
+
<% end %>
|
|
21
|
+
<% items.each do |item| %>
|
|
22
|
+
<% if positioned %>
|
|
23
|
+
<tr data-sortable-update-url='<%= url_for(action: :update, id: item) %>'>
|
|
24
|
+
<td class='sortable-handle text-center' style='cursor: pointer; width: 40px'>⇅</td>
|
|
25
|
+
<% else %>
|
|
26
|
+
<tr>
|
|
27
|
+
<% end %>
|
|
28
|
+
<% cache_if (cached && !params.key?(:q)), item do %>
|
|
29
|
+
<%= yield item %>
|
|
30
|
+
<% end %>
|
|
31
|
+
</tr>
|
|
32
|
+
<% end %>
|
|
33
|
+
</tbody>
|
|
34
|
+
</table>
|
|
35
|
+
|
|
36
|
+
<% if pagy %>
|
|
37
|
+
<div class='d-flex align-items-center'>
|
|
38
|
+
<div class='ps-2 flex-grow-1'><%== pagy.info_tag %></div>
|
|
39
|
+
<div class='pe-2'><%== pagy.series_nav(:bootstrap, classes: 'pagination mb-0') if pagy.last > 1 %></div>
|
|
40
|
+
</div>
|
|
41
|
+
<% end %>
|
|
42
|
+
<% else %>
|
|
43
|
+
<p><%= empty_label %>.</p>
|
|
44
|
+
<% end %>
|
|
45
|
+
<% end %>
|
|
46
|
+
<% end %>
|
data/bh.gemspec
CHANGED
|
@@ -1,43 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
-
require 'bh/version'
|
|
1
|
+
require_relative 'lib/bh/version'
|
|
5
2
|
|
|
6
3
|
Gem::Specification.new do |spec|
|
|
7
4
|
spec.name = "bh"
|
|
8
5
|
spec.version = Bh::VERSION
|
|
9
6
|
spec.authors = ["Claudio Baccigalupo"]
|
|
10
|
-
spec.email = ["claudio@
|
|
7
|
+
spec.email = ["claudio@houseaccount.com"]
|
|
11
8
|
spec.description = %q{Bh - Bootstrap Helpers}
|
|
12
9
|
spec.summary = %q{Bh provides a set of powerful helpers that
|
|
13
10
|
streamlines the use of Bootstrap components in Rails views.}
|
|
14
|
-
spec.homepage = "http://github.com/
|
|
11
|
+
spec.homepage = "http://github.com/claudiob/bh"
|
|
15
12
|
spec.license = "MIT"
|
|
16
|
-
|
|
17
|
-
spec.required_ruby_version = '>= 1.9.3'
|
|
13
|
+
spec.required_ruby_version = ">= 3.2.0"
|
|
18
14
|
|
|
19
15
|
spec.files = `git ls-files`.split($/)
|
|
20
16
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
21
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
22
17
|
spec.require_paths = ["lib"]
|
|
23
|
-
|
|
24
|
-
spec.add_dependency 'activesupport' # versioned in gemfiles/
|
|
25
|
-
spec.add_dependency 'actionpack' # versioned in gemfiles/
|
|
26
|
-
|
|
27
|
-
# For development / Code coverage / Documentation
|
|
28
|
-
spec.add_development_dependency 'bundler', '~> 1.1'
|
|
29
|
-
spec.add_development_dependency 'rspec', '~> 3.1'
|
|
30
|
-
spec.add_development_dependency 'rake', '~> 10.3'
|
|
31
|
-
spec.add_development_dependency 'yard', '~> 0.8.7'
|
|
32
|
-
spec.add_development_dependency 'coveralls', '~> 0.8.13'
|
|
33
|
-
spec.add_development_dependency 'activemodel' # versioned in gemfiles/
|
|
34
|
-
|
|
35
|
-
unless ENV['ONLY_RAILS']
|
|
36
|
-
# For spec/dummy
|
|
37
|
-
spec.add_development_dependency 'middleman-core' # versioned in gemfiles/
|
|
38
|
-
|
|
39
|
-
# For Middleman/Padrino tests
|
|
40
|
-
spec.add_development_dependency 'padrino-helpers', '~> 0.12.4'
|
|
41
|
-
spec.add_development_dependency 'padrino-routing', '~> 0.5.0'
|
|
42
|
-
end
|
|
43
|
-
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
module Bh
|
|
2
|
+
module BootstrapHelpers
|
|
3
|
+
def head_tags
|
|
4
|
+
<<~HEAD.html_safe
|
|
5
|
+
<meta name='viewport' content='width=device-width,initial-scale=1'>
|
|
6
|
+
<meta name='view-transition' content='same-origin'>
|
|
7
|
+
<meta name='turbo-refresh-method' content='morph'>
|
|
8
|
+
<meta name='turbo-refresh-scroll' content='preserve'>
|
|
9
|
+
<meta name='apple-mobile-web-app-capable' content='yes'>
|
|
10
|
+
<meta name='mobile-web-app-capable' content='yes'>
|
|
11
|
+
<meta name='color-scheme' content='light dark'>
|
|
12
|
+
#{csrf_meta_tags}
|
|
13
|
+
#{csp_meta_tag}
|
|
14
|
+
<script async src="https://ga.jspm.io/npm:es-module-shims@1.8.2/dist/es-module-shims.js" data-turbo-track="reload"></script>
|
|
15
|
+
#{javascript_importmap_tags}
|
|
16
|
+
<link rel='icon' href="/favicon#{'-dev' if Rails.env.development?}.png" type='image/png'>
|
|
17
|
+
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
|
|
18
|
+
<link href='https://assets.houseaccount.com/css/bootstrap.min.css' rel='stylesheet'>
|
|
19
|
+
<!-- once it's live: <link href="https://cdn.jsdelivr.net/npm/bootstrap@6.0.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-VuYVTUAUbEW1A1EgqVmiLTxfqmvVgsV8yG3KeYZmz8aLednYx2pzlYdT4NS041oo" crossorigin="anonymous"> -->
|
|
20
|
+
#{stylesheet_link_tag :app, 'data-turbo-track': 'reload'}
|
|
21
|
+
#{stylesheet_link_tag :bh, 'data-turbo-track': 'reload'}
|
|
22
|
+
HEAD
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def script_tags
|
|
26
|
+
<<~SCRIPTS.html_safe
|
|
27
|
+
<script src='https://assets.houseaccount.com/js/bootstrap.bundle.min.js'></script>
|
|
28
|
+
<!-- once it's live: <script src="https://cdn.jsdelivr.net/npm/bootstrap@6.0.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-kBqjI9J+3T2+popvAtxRzS3v5xO7BkyKlAyF/GZgnB0kZ2HoQdx6V1I/EX8ljPWj" crossorigin="anonymous"></script> -->
|
|
29
|
+
SCRIPTS
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def navbar(options = {}, &block)
|
|
33
|
+
tag.div class: 'mb-4 border-bottom shadow-sm' do
|
|
34
|
+
tag.nav class: 'navbar navbar-expand-lg' do
|
|
35
|
+
tag.div **options, &block
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def navbar_brand(brand)
|
|
41
|
+
tag.div brand, class: 'navbar-brand', data: { controller: 'bh--theme', action: 'dblclick->bh--theme#toggle' }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def card(tabs:, &block)
|
|
45
|
+
tag.div class: 'card' do
|
|
46
|
+
safe_join [card_header(tabs: tabs), card_body(&block)]
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def nav(pills:)
|
|
51
|
+
tag.ul pills, class:'nav nav-pills border-bottom pb-3 mb-3'
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def navbar_nav(&block)
|
|
55
|
+
tag.ul class: 'nav navbar-nav me-auto', &block
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# @return [String] wraps link_to into a nav-item tab.
|
|
59
|
+
def nav_link_to(name, options, &block)
|
|
60
|
+
options.merge! nav_link_options_for(options) if block_given?
|
|
61
|
+
tag.li(class: 'nav-item') { link_to name, options, nav_link_options_for(options), &block }
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def nav_link_options_for(path)
|
|
65
|
+
if current_page?(path) # request.path.starts_with? path
|
|
66
|
+
{ class: 'nav-link active', aria: { current: :page } }
|
|
67
|
+
else
|
|
68
|
+
{ class: 'nav-link' }
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def navbar_collapsable(&block)
|
|
73
|
+
safe_join [navbar_toggler, navbar_collapse(&block)]
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def navbar_toggler
|
|
77
|
+
tag.button class: 'navbar-toggler', type: 'button', data: {'bs-toggle': 'collapse', 'bs-target': '#navbarSupportedContent'}, aria: {controls: 'navbarSupportedContent', expanded: 'false', label: 'Toggle navigation'} do
|
|
78
|
+
tag.span nil, class: 'navbar-toggler-icon'
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def navbar_collapse(&block)
|
|
83
|
+
tag.div class: 'collapse navbar-collapse', id: 'navbarSupportedContent', &block
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def table(items:, empty_label:, positioned: false, cached: true, headers: [], pagy: nil, &block)
|
|
87
|
+
render 'bh/table', items: items, empty_label: empty_label, positioned: positioned, cached: cached, headers: headers, pagy: pagy, &block
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Renders the block inside a grid row.
|
|
91
|
+
def grid_row(&block)
|
|
92
|
+
tag.div class: 'row p-2 border-bottom border-subtle', &block
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Renders key and value next to each other inside a grid row.
|
|
96
|
+
def grid_column(key, value)
|
|
97
|
+
left = tag.div key, class: 'col-3 p-2 fst-italic'
|
|
98
|
+
right = tag.div value, class: 'col p-2'
|
|
99
|
+
safe_join [ left, right ]
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def grid(item:, cached: true, &block)
|
|
103
|
+
render 'bh/grid', item: item, cached: cached, &block
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Returns a link_to that opens the link outside of the current turbo frame.
|
|
107
|
+
# @note Helpful for links within an administered/table that uses +turbo_action: :advance+.
|
|
108
|
+
def turbo_link_to(name, options, html_options = {})
|
|
109
|
+
link_to name, options, html_options.merge(data: { turbo_frame: '_top' })
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# Display a link with an emoji to edit a resource inside a table.
|
|
113
|
+
def edit_link_to(path)
|
|
114
|
+
tag.td class: 'text-center', style: 'width: 40px' do
|
|
115
|
+
turbo_link_to '➡️', path, class: 'text-decoration-none'
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
private
|
|
120
|
+
|
|
121
|
+
def card_header(tabs:)
|
|
122
|
+
tag.div class:'card-header' do
|
|
123
|
+
tag.ul tabs, class: 'nav nav-tabs card-header-tabs'
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def card_body(&block)
|
|
128
|
+
tag.div class: 'card-body card-row py-4', &block
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
data/lib/bh/engine.rb
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require_relative 'bootstrap_helpers'
|
|
2
|
+
|
|
3
|
+
module Bh
|
|
4
|
+
class Engine < Rails::Engine
|
|
5
|
+
initializer 'bh.view_helpers' do
|
|
6
|
+
ActiveSupport.on_load(:action_view) { include Bh::BootstrapHelpers }
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
initializer 'bh.assets' do |app|
|
|
10
|
+
app.config.assets.paths << root.join('app/javascript')
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
data/lib/bh/version.rb
CHANGED
data/lib/bh.rb
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'bh/version'
|
|
4
|
+
require 'bh/engine' if defined?(Rails)
|
|
3
5
|
|
|
4
|
-
# Bootstrap Helpers
|
|
5
6
|
module Bh
|
|
6
|
-
|
|
7
|
+
class Error < StandardError; end
|
|
8
|
+
# Your code goes here...
|
|
7
9
|
end
|
|
8
|
-
|
|
9
|
-
# Always require every generic helper
|
|
10
|
-
helpers_folder = File.expand_path '../bh/helpers/*_helper.rb', __FILE__
|
|
11
|
-
Dir[helpers_folder].each{|file| require file}
|
|
12
|
-
|
|
13
|
-
# Conditionally require platform-specific helpers
|
|
14
|
-
extension = :railtie if defined?(Rails)
|
|
15
|
-
extension ||= :middleman if defined?(Middleman)
|
|
16
|
-
extension ||= :padrino if defined?(Padrino)
|
|
17
|
-
require "bh/core_ext/#{extension}" if extension
|