booties 0.1.0 → 0.2.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/README.md +172 -0
- data/Rakefile +5 -4
- data/app/controllers/booties/application_controller.rb +4 -1
- data/app/helpers/booties/application_helper.rb +3 -26
- data/app/helpers/booties/badge_helper.rb +6 -3
- data/app/helpers/booties/breadcrumb_helper.rb +29 -0
- data/app/helpers/booties/button_helper.rb +10 -8
- data/app/helpers/booties/dropdown_helper.rb +71 -0
- data/app/helpers/booties/flag_helper.rb +7 -4
- data/app/helpers/booties/modal_helper.rb +4 -1
- data/app/helpers/booties/panel_helper.rb +3 -1
- data/app/helpers/booties/popover_helper.rb +28 -19
- data/app/helpers/booties/tooltip_helper.rb +12 -8
- data/config/routes.rb +2 -0
- data/lib/booties.rb +3 -1
- data/lib/booties/engine.rb +7 -1
- data/lib/booties/modal.rb +13 -12
- data/lib/booties/panel.rb +21 -18
- data/lib/booties/utils.rb +8 -10
- data/lib/booties/version.rb +3 -1
- data/lib/tasks/booties_tasks.rake +2 -0
- data/test/dummy/Rakefile +1 -1
- data/test/dummy/app/assets/javascripts/application.js +0 -13
- data/test/dummy/app/assets/stylesheets/application.css +0 -15
- data/test/dummy/app/channels/application_cable/channel.rb +4 -0
- data/test/dummy/app/channels/application_cable/connection.rb +4 -0
- data/test/dummy/app/controllers/application_controller.rb +0 -4
- data/test/dummy/app/controllers/samples_controller.rb +28 -0
- data/test/dummy/app/jobs/application_job.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +9 -11
- data/test/dummy/app/views/samples/badges.html.erb +2 -0
- data/test/dummy/app/views/{home → samples}/breadcrumbs.html.erb +2 -1
- data/test/dummy/app/views/samples/buttons.html.erb +2 -0
- data/test/dummy/app/views/samples/dropdowns.html.erb +6 -0
- data/test/dummy/app/views/samples/flags.html.erb +2 -0
- data/test/dummy/app/views/samples/modals.html.erb +12 -0
- data/test/dummy/app/views/samples/panels.html.erb +14 -0
- data/test/dummy/app/views/samples/popovers.html.erb +9 -0
- data/test/dummy/app/views/samples/tooltips.html.erb +3 -0
- data/test/dummy/bin/bundle +1 -1
- data/test/dummy/bin/rails +1 -1
- data/test/dummy/bin/setup +17 -13
- data/test/dummy/bin/update +28 -0
- data/test/dummy/config.ru +2 -1
- data/test/dummy/config/application.rb +13 -12
- data/test/dummy/config/boot.rb +2 -2
- data/test/dummy/config/environment.rb +1 -1
- data/test/dummy/config/environments/development.rb +24 -16
- data/test/dummy/config/environments/production.rb +23 -28
- data/test/dummy/config/environments/test.rb +5 -11
- data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/test/dummy/config/initializers/content_security_policy.rb +25 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +2 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +6 -1
- data/test/dummy/config/locales/en.yml +10 -0
- data/test/dummy/config/puma.rb +34 -0
- data/test/dummy/config/routes.rb +16 -8
- data/test/dummy/config/spring.rb +6 -0
- data/test/dummy/log/test.log +11202 -19551
- data/test/dummy/public/404.html +6 -6
- data/test/dummy/public/422.html +6 -6
- data/test/dummy/public/500.html +6 -6
- data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/test/dummy/public/apple-touch-icon.png +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/33/33EUCQBNqL6TOaGyMFn9wz2v39pHMJ4LOUUFUteIHHM.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/3N/3NnKgR2TsTI1qCXKZpts0uJzp2dRJcoYp3nnFU6YE4o.cache +2 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/7Q/7Q2gtOOyCVPFrfYz4KjmXJsM_m8Yra4MjgsQmfVGxZY.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/8c/8cROjTzeZZQaOFNLPKGuMtXO7EHxNfiEa72qt65UoF4.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/F6/F6RhC2MbCvVanNZZe44hqlJNKAdIrH4NUzRxj5N2_EQ.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/Fc/FcMeZRcfG4LrhIhl3xrAg3EhSZInU4efHmUrjIs4keE.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/H3/H3dfPRbxbWIB6dQXrQ6xA9nDJqy4dOq1ujslocGVY9U.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/LK/LKisVDbQmzgRQKdFoNH5tRbTr72CrlM_2q7MZczv2Pg.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/Mj/MjwYGG9GkHD1fwwH2bg66EBYl3zCA_mqeDF9otey4-U.cache +3 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/Pc/Pce9HMZhc6XmsNfLUN84Enw7mySJ7ZYzys9mXmCVXqA.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/Po/PoftKmjB8lzW06EMKeru1CsqVtULc0MsiTysT2JNqvU.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/Su/SuILTE3Es0N_r-36Ddu2E6h49WcwH_-RsZyG4SPwKFQ.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/cJ/cJG59MHf0x4qJKYES0pa0nLpOFpFF7YwrrvIVKIixyA.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/fw/fwPYklzExHPpgeuv53ew_8OIpJVRyaHj2Jtj2JP9j5A.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/jc/jc_TR7ZZTSFDDRKdgc-KnZskUESr2rLOqcYZej83LvU.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/rV/rVy4-idUuK0Va9FLw3G8pYeZFwJAwmvs_bQcbq6_Cd0.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/rY/rYyeRvy3oIuNfWeDhoriNlAlVjN4Wg4A3_9_OTDFin4.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/tY/tYFbDrMNElXwgmisit50aNXJvRU2zlIFk5g-EJ1CQTc.cache +0 -0
- data/test/helpers/booties/badge_helper_test.rb +7 -5
- data/test/helpers/booties/breadcrumb_helper_test.rb +13 -0
- data/test/helpers/booties/button_helper_test.rb +14 -12
- data/test/helpers/booties/dropdown_helper_test.rb +43 -0
- data/test/helpers/booties/flag_helper_test.rb +7 -5
- data/test/helpers/booties/modal_helper_test.rb +9 -7
- data/test/helpers/booties/panel_helper_test.rb +4 -2
- data/test/helpers/booties/popover_helper_test.rb +33 -42
- data/test/helpers/booties/tooltip_helper_test.rb +19 -40
- data/test/integration/samples_test.rb +103 -0
- data/test/lib/booties/modal_test.rb +193 -0
- data/test/{booties → lib/booties}/panel_test.rb +40 -22
- data/test/lib/booties/utils_test.rb +41 -0
- data/test/stub_view.rb +14 -7
- data/test/test_helper.rb +10 -11
- metadata +124 -98
- data/app/assets/javascripts/booties/application.js +0 -13
- data/app/assets/stylesheets/booties/application.css +0 -15
- data/test/booties/modal_test.rb +0 -170
- data/test/booties/utils_test.rb +0 -26
- data/test/dummy/README.rdoc +0 -28
- data/test/dummy/app/assets/javascripts/home.js +0 -2
- data/test/dummy/app/assets/stylesheets/home.css +0 -4
- data/test/dummy/app/controllers/home_controller.rb +0 -25
- data/test/dummy/app/helpers/home_helper.rb +0 -2
- data/test/dummy/app/views/home/badge.html.erb +0 -3
- data/test/dummy/app/views/home/button.html.erb +0 -2
- data/test/dummy/app/views/home/flag.html.erb +0 -5
- data/test/dummy/app/views/home/modal.html.erb +0 -16
- data/test/dummy/app/views/home/panel.html.erb +0 -25
- data/test/dummy/app/views/home/popover.html.erb +0 -7
- data/test/dummy/app/views/home/tooltip.html.erb +0 -7
- data/test/dummy/config/initializers/assets.rb +0 -11
- data/test/dummy/config/initializers/session_store.rb +0 -3
- data/test/dummy/config/locales/booties.yml +0 -4
- data/test/dummy/config/secrets.yml +0 -22
- data/test/dummy/log/development.log +0 -420
- data/test/dummy/test/controllers/home_controller_test.rb +0 -108
- data/test/helpers/booties/application_helper_test.rb +0 -11
- data/test/integration/navigation_test.rb +0 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 5301ae79aa1fa1d914f905c50fb2e378ec891bef1376c4254b64a5cb67e7b541
|
|
4
|
+
data.tar.gz: dcd9a510e73b48ce9f2eff4278108542be15519f40be8be87f77f1d869cd89d9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1fdffebb63f6b3f80eb4fe7cc221af4373c3834f3e37d9e387f1a79703ebea4613eb0ae66555bcb65cdfaccf8b4dc152a78fb7b12129802842846386fb3bf078
|
|
7
|
+
data.tar.gz: 16e301945dde99932e76659185ca81093d6c16a48779aad1400f6476386b4e69f6d1a83436103ce1281a8743112aaf6a71eae5db3f0f4761d585dfcda564489c
|
data/README.md
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# [](http://badge.fury.io/rb/booties) [](https://travis-ci.org/jparker/booties)
|
|
2
|
+
|
|
3
|
+
# Booties
|
|
4
|
+
|
|
5
|
+
Booties provides a variety of helpers for using
|
|
6
|
+
[Twitter Bootstrap](http://getbootstrap.com/) within a Rails application.
|
|
7
|
+
|
|
8
|
+
NB: This is the Rails 5 development branch. There will likely be no visible
|
|
9
|
+
change in syntax or behavior, but some of the tests had to be rewritten.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
Add this line to your application's Gemfile:
|
|
14
|
+
|
|
15
|
+
```ruby
|
|
16
|
+
gem 'booties'
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
And then execute:
|
|
20
|
+
```bash
|
|
21
|
+
$ bundle
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
You also need to make sure you include Bootstrap in your application. The way
|
|
25
|
+
you accomplish this is left up to you, but one easy way to do this is to
|
|
26
|
+
include the [bootstrap-sass](https://github.com/twbs/bootstrap-sass) gem.
|
|
27
|
+
|
|
28
|
+
## Helpers
|
|
29
|
+
|
|
30
|
+
Booties provides helpers for a variety of Bootstrap components. Below is an
|
|
31
|
+
overview of the available helpers. Examples of how to use them can be found in
|
|
32
|
+
<tt>test/dummy/app/views/samples</tt>.
|
|
33
|
+
|
|
34
|
+
### Badges
|
|
35
|
+
|
|
36
|
+
Booties::BadgeHelper#badge provides Bootstrap
|
|
37
|
+
[Badges](http://getbootstrap.com/components/#badges).
|
|
38
|
+
|
|
39
|
+
```erb
|
|
40
|
+
<%= badge '42' %>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Breadcrumbs
|
|
44
|
+
|
|
45
|
+
Booties::ApplicationHelper#breadcrumbs facilitates adding
|
|
46
|
+
[Breadcrumbs](http://getbootstrap.com/components/#breadcrumbs) to your pages.
|
|
47
|
+
The breadcrumb content is saved as `:breadcrumbs` and can be rendered with
|
|
48
|
+
`yield :breadcrumbs`.
|
|
49
|
+
|
|
50
|
+
```erb
|
|
51
|
+
<%= breadcrumbs do %>
|
|
52
|
+
<li><%= link_to 'Books', :books %></li>
|
|
53
|
+
<li><%= link_to truncate(@book.title), [:edit, @book] %></li>
|
|
54
|
+
<li class="active">Edit</li>
|
|
55
|
+
<% end %>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Buttons
|
|
59
|
+
|
|
60
|
+
Booties::ButtonHelper#btn_link_to renders links configured to be displayed as
|
|
61
|
+
Bootstrap [Buttons](http://getbootstrap.com/css/#buttons).
|
|
62
|
+
|
|
63
|
+
```erb
|
|
64
|
+
<%= btn_link_to 'New', [:new, :widget] %>
|
|
65
|
+
<%= btn_link_to sign_out_path, class: 'btn-xs', context: :danger, method: :delete do %>
|
|
66
|
+
Sign out
|
|
67
|
+
<% end %>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Labels
|
|
71
|
+
|
|
72
|
+
Booties::FlagHelper#flag provides Bootstrap
|
|
73
|
+
[Labels](http://getbootstrap.com/components/#labels).
|
|
74
|
+
|
|
75
|
+
```erb
|
|
76
|
+
<%= flag 'PENDING' %>
|
|
77
|
+
<%= flag 'OPEN', context: :primary %>
|
|
78
|
+
<%= flag 'CLOSED', context: :danger %>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Modals
|
|
82
|
+
|
|
83
|
+
Booties::ModalHelper#modal and Booties::Modal provide Bootstrap
|
|
84
|
+
[Modals](http://getbootstrap.com/javascript/#modals).
|
|
85
|
+
|
|
86
|
+
```erb
|
|
87
|
+
<%= modal 'foo' do |m| %>
|
|
88
|
+
<%= m.header do %>
|
|
89
|
+
Nesciunt qui iste vel a.
|
|
90
|
+
<% end %>
|
|
91
|
+
<%= m.body do %>
|
|
92
|
+
<p>
|
|
93
|
+
Autem atque perferendis veritatis. Molestiae aliquid nam reiciendis
|
|
94
|
+
recusandae facere. Aut non nemo dicta.
|
|
95
|
+
</p>
|
|
96
|
+
<% end %>
|
|
97
|
+
<%= m.footer do %>
|
|
98
|
+
<%= m.dismiss class: 'btn btn-default' do %>
|
|
99
|
+
Dismiss
|
|
100
|
+
<% end %>
|
|
101
|
+
<%= link_to @widget, class: 'btn btn-danger', method: :delete do %>
|
|
102
|
+
Really Delete
|
|
103
|
+
<% end %>
|
|
104
|
+
<% end %>
|
|
105
|
+
<% end %>
|
|
106
|
+
```
|
|
107
|
+
### Panel
|
|
108
|
+
|
|
109
|
+
Booties::PanelHelper#panel and Booties::Modal provide Bootstrap
|
|
110
|
+
[Panels](http://getbootstrap.com/components/#panels).
|
|
111
|
+
|
|
112
|
+
```erb
|
|
113
|
+
<%= panel do |p| %>
|
|
114
|
+
<%= p.heading do %>
|
|
115
|
+
<%= p.title 'Consequatur quibusdam quia vel et sed in.' %>
|
|
116
|
+
<% end %>
|
|
117
|
+
<%= p.body do %>
|
|
118
|
+
<p>
|
|
119
|
+
Est fuga iste reiciendis laudantium dicta. Perspiciatis vero ut autem
|
|
120
|
+
quod vel modi. Ea error omnis aliquam aut est.
|
|
121
|
+
</p>
|
|
122
|
+
<% end %>
|
|
123
|
+
<%= p.footer do %>
|
|
124
|
+
Voluptatibus rerum et est quo dicta perspiciatis.
|
|
125
|
+
<% end %>
|
|
126
|
+
<% end %>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Tooltips
|
|
130
|
+
|
|
131
|
+
Booties::TooltipHelper#tooltip provides Bootstrap
|
|
132
|
+
[Tooltips](http://getbootstrap.com/javascript/#tooltips).
|
|
133
|
+
|
|
134
|
+
```erb
|
|
135
|
+
<%= tooltip title: 'This is a tooltip', placement: :bottom do %>
|
|
136
|
+
This has a tooltip.
|
|
137
|
+
<% end %>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Tooltip behavior is opt-in. The helper will render the necessary tag, but you
|
|
141
|
+
must activate them yourself. One way of doing this is to run the following
|
|
142
|
+
Javascript snippet:
|
|
143
|
+
|
|
144
|
+
```javascript
|
|
145
|
+
$(function() {
|
|
146
|
+
$('[data-toggle="tooltip"]').tooltip();
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Popovers
|
|
151
|
+
|
|
152
|
+
Booties::PopoverHelper#popover provides Bootstrap
|
|
153
|
+
[Popovers](http://getbootstrap.com/javascript/#popovers).
|
|
154
|
+
|
|
155
|
+
```erb
|
|
156
|
+
<%= popover content: 'Lorem ipsum dolor sit amet.', class: 'btn btn-default' do %>
|
|
157
|
+
Button text
|
|
158
|
+
<% end %>
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Popover behavior is opt-in. The helper will render the necessary tag, but you
|
|
162
|
+
must activate them yourself. One way of doing this is to run the following
|
|
163
|
+
Javascript snippet:
|
|
164
|
+
|
|
165
|
+
```javascript
|
|
166
|
+
$(function() {
|
|
167
|
+
$('[data-toggle="popover"]').popover();
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## License
|
|
172
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
begin
|
|
2
4
|
require 'bundler/setup'
|
|
3
5
|
rescue LoadError
|
|
@@ -10,13 +12,13 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
|
10
12
|
rdoc.rdoc_dir = 'rdoc'
|
|
11
13
|
rdoc.title = 'Booties'
|
|
12
14
|
rdoc.options << '--line-numbers'
|
|
13
|
-
rdoc.rdoc_files.include('README.
|
|
15
|
+
rdoc.rdoc_files.include('README.md')
|
|
14
16
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
15
17
|
end
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
load 'rails/tasks/statistics.rake'
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
require 'bundler/gem_tasks'
|
|
20
22
|
|
|
21
23
|
require 'rake/testtask'
|
|
22
24
|
|
|
@@ -27,5 +29,4 @@ Rake::TestTask.new(:test) do |t|
|
|
|
27
29
|
t.verbose = false
|
|
28
30
|
end
|
|
29
31
|
|
|
30
|
-
|
|
31
32
|
task default: :test
|
|
@@ -1,29 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
module ApplicationHelper
|
|
3
|
-
include Utils
|
|
4
|
-
|
|
5
|
-
##
|
|
6
|
-
# Renders an ol tag with the "breadcrumb" class and fills it with the
|
|
7
|
-
# content of the block.
|
|
8
|
-
#
|
|
9
|
-
# Example:
|
|
10
|
-
#
|
|
11
|
-
# <% breadcrumbs do %>
|
|
12
|
-
# <li>Foo</li>
|
|
13
|
-
# <li class="active">Bar</li>
|
|
14
|
-
# <% end %>
|
|
15
|
-
# <%= yield :breadcrumb %>
|
|
16
|
-
#
|
|
17
|
-
# <ol class="breadcrumb">
|
|
18
|
-
# <li>Foo</li>
|
|
19
|
-
# <li class="active">Bar</li>
|
|
20
|
-
# </ol>
|
|
21
|
-
def breadcrumbs(&block)
|
|
22
|
-
content_for :breadcrumbs, render_breadcrumbs(&block)
|
|
23
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
24
2
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
end
|
|
3
|
+
module Booties
|
|
4
|
+
module ApplicationHelper # :nodoc:
|
|
28
5
|
end
|
|
29
6
|
end
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Booties
|
|
2
|
-
module BadgeHelper
|
|
4
|
+
module BadgeHelper # :nodoc:
|
|
3
5
|
include Utils
|
|
4
6
|
|
|
5
7
|
##
|
|
@@ -23,9 +25,10 @@ module Booties
|
|
|
23
25
|
# <%= badge 'foo', class: 'bar' %>
|
|
24
26
|
# <span class="badge bar">foo</span>
|
|
25
27
|
def badge(content = nil, class: nil, **options, &block)
|
|
26
|
-
content ||= capture(&block) if block_given?
|
|
27
28
|
classes = merge_classes ['badge'], binding.local_variable_get(:class)
|
|
28
|
-
|
|
29
|
+
options = { class: classes, **options }
|
|
30
|
+
|
|
31
|
+
content_tag :span, content, options, &block
|
|
29
32
|
end
|
|
30
33
|
end
|
|
31
34
|
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Booties
|
|
4
|
+
module BreadcrumbHelper # :nodoc:
|
|
5
|
+
##
|
|
6
|
+
# Renders an ol tag with the "breadcrumb" class and fills it with the
|
|
7
|
+
# content of the block.
|
|
8
|
+
#
|
|
9
|
+
# Example:
|
|
10
|
+
#
|
|
11
|
+
# <% breadcrumbs do %>
|
|
12
|
+
# <li>Foo</li>
|
|
13
|
+
# <li class="active">Bar</li>
|
|
14
|
+
# <% end %>
|
|
15
|
+
# <%= yield :breadcrumb %>
|
|
16
|
+
#
|
|
17
|
+
# <ol class="breadcrumb">
|
|
18
|
+
# <li>Foo</li>
|
|
19
|
+
# <li class="active">Bar</li>
|
|
20
|
+
# </ol>
|
|
21
|
+
def breadcrumbs(&block)
|
|
22
|
+
content_for :breadcrumbs, render_breadcrumbs(&block)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def render_breadcrumbs(&block) # :nodoc:
|
|
26
|
+
content_tag :ol, class: 'breadcrumb', &block
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Booties
|
|
2
|
-
module ButtonHelper
|
|
4
|
+
module ButtonHelper # :nodoc:
|
|
3
5
|
include Utils
|
|
4
6
|
|
|
5
7
|
##
|
|
@@ -21,13 +23,13 @@ module Booties
|
|
|
21
23
|
# <%= btn_link_to 'Sign out', destroy_user_session_path, context: :danger, class: 'btn-xs', method: :delete %>
|
|
22
24
|
#
|
|
23
25
|
# <a href="/users/sign_out" class="btn btn-danger btn-xs" data-method="delete">Sign out</a>
|
|
24
|
-
def btn_link_to(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
def btn_link_to(name_or_path, path = nil, context: :default, **opts, &block)
|
|
27
|
+
opts[:class] = merge_classes %W[btn btn-#{context}], opts[:class]
|
|
28
|
+
if block_given?
|
|
29
|
+
link_to name_or_path, opts, &block
|
|
30
|
+
else
|
|
31
|
+
link_to name_or_path, path, opts
|
|
32
|
+
end
|
|
31
33
|
end
|
|
32
34
|
end
|
|
33
35
|
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Booties
|
|
4
|
+
module DropdownHelper # :nodoc:
|
|
5
|
+
include Utils
|
|
6
|
+
|
|
7
|
+
##
|
|
8
|
+
# Renders a link to toggle a dropdown menu.
|
|
9
|
+
#
|
|
10
|
+
# Examples:
|
|
11
|
+
#
|
|
12
|
+
# <%= link_to_dropdown do %>
|
|
13
|
+
# Foo
|
|
14
|
+
# <% end %>
|
|
15
|
+
#
|
|
16
|
+
# <%= link_to_dropdown class: 'foo' do %>
|
|
17
|
+
# Foo
|
|
18
|
+
# <% end %>
|
|
19
|
+
def link_to_dropdown(class: nil, &block)
|
|
20
|
+
classes = merge_classes binding.local_variable_get(:class),
|
|
21
|
+
'dropdown-toggle'
|
|
22
|
+
text = capture(&block) + caret
|
|
23
|
+
link_to text, '#',
|
|
24
|
+
class: classes,
|
|
25
|
+
data: { toggle: 'dropdown' },
|
|
26
|
+
role: 'button'
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
##
|
|
30
|
+
# Renders a button to toggle a dropdown menu.
|
|
31
|
+
#
|
|
32
|
+
# Examples:
|
|
33
|
+
#
|
|
34
|
+
# <%= button_to_dropdown do %>
|
|
35
|
+
# Foo
|
|
36
|
+
# <% end %>
|
|
37
|
+
#
|
|
38
|
+
# <%= button_to_dropdown context: :primary, class: 'btn-xs' do %>
|
|
39
|
+
# Foo
|
|
40
|
+
# <% end %>
|
|
41
|
+
def button_to_dropdown(context: :default, class: nil, &block)
|
|
42
|
+
classes = merge_classes binding.local_variable_get(:class),
|
|
43
|
+
%W[btn btn-#{context} dropdown-toggle]
|
|
44
|
+
text = capture(&block) + caret
|
|
45
|
+
button_tag text,
|
|
46
|
+
name: nil,
|
|
47
|
+
class: classes,
|
|
48
|
+
data: { toggle: 'dropdown' },
|
|
49
|
+
type: 'button'
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
##
|
|
53
|
+
# Wraps a block in a dropdown menu list.
|
|
54
|
+
#
|
|
55
|
+
# Examples:
|
|
56
|
+
#
|
|
57
|
+
# <%= dropdown_menu do %>
|
|
58
|
+
# <li><%= link_to 'Foo', foos_path %></li>
|
|
59
|
+
# <li><%= link_to 'Bar', bars_path %></li>
|
|
60
|
+
# <% end %>
|
|
61
|
+
def dropdown_menu(&block)
|
|
62
|
+
content_tag :ul, class: 'dropdown-menu', &block
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
##
|
|
66
|
+
# Renders caret for dropdown menu.
|
|
67
|
+
def caret
|
|
68
|
+
content_tag :span, '', class: 'caret'
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Booties
|
|
2
|
-
module FlagHelper
|
|
4
|
+
module FlagHelper # :nodoc:
|
|
3
5
|
include Utils
|
|
4
6
|
|
|
5
7
|
##
|
|
@@ -27,10 +29,11 @@ module Booties
|
|
|
27
29
|
# <%= flag 'foo', class: 'bar' %>
|
|
28
30
|
# <span class="label label-default bar">foo</span>
|
|
29
31
|
def flag(content = nil, context: :default, class: nil, **options, &block)
|
|
30
|
-
content ||= capture(&block)
|
|
31
32
|
classes = merge_classes %W[label label-#{context}],
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
binding.local_variable_get(:class)
|
|
34
|
+
options = { class: classes, **options }
|
|
35
|
+
|
|
36
|
+
content_tag :span, content, options, &block
|
|
34
37
|
end
|
|
35
38
|
end
|
|
36
39
|
end
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Booties
|
|
2
|
-
module ModalHelper
|
|
4
|
+
module ModalHelper # :nodoc:
|
|
3
5
|
##
|
|
4
6
|
# Renders a modal dialog. The CSS id is provided by +id+. The fade effect
|
|
5
7
|
# will be enabled by default, but it will be disabled if +fade+ is falsey.
|
|
@@ -29,6 +31,7 @@ module Booties
|
|
|
29
31
|
# <% end %>
|
|
30
32
|
# <% end %>
|
|
31
33
|
# <% end %>
|
|
34
|
+
|
|
32
35
|
def modal(id, fade: true, size: nil, with: Modal, **options, &block)
|
|
33
36
|
with.new(self, id: id, fade: fade, size: size).render(**options, &block)
|
|
34
37
|
end
|