bootstrap-view-helpers 0.0.10 → 0.0.11

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,14 @@
1
1
  # Change Log
2
2
 
3
+ ## v 0.0.11
4
+
5
+ * added `nav_bar_text`
6
+ * added `:pull` option to `nav_bar_links`
7
+
8
+ ## v 0.0.10
9
+
10
+ * added alert support
11
+
3
12
  ## v 0.0.9
4
13
 
5
14
  * fixed bug in view path for examples page
data/README.md CHANGED
@@ -83,17 +83,19 @@ Complete [API documentation](http://rubydoc.info/gems/bootstrap-view-helpers/fra
83
83
  <%= brand('MyApp', with_environment: true) %>
84
84
 
85
85
  <%= nav_bar_links do %>
86
-
87
86
  <%= nav_bar_link('Active', '#', active: true) %>
88
- <%= nav_bar_link('Link1', '/link1') %>
89
-
87
+ <%= nav_bar_link('Link 1', '/link1') %>
90
88
  <%= nav_bar_divider %>
89
+ <%= nav_bar_link('Link 2', '/link2') %>
90
+ <% end %>
91
91
 
92
+ <%= nav_bar_links(pull: 'right') do %>
93
+ <%= nav_bar_text('logged in as admin') %>
92
94
  <%= nav_dropdown('Foo') do %>
93
95
  <%= dropdown_item('One', 'foo')%>
94
96
  <% end %>
95
-
96
97
  <% end %>
98
+
97
99
  <% end %>
98
100
  ```
99
101
 
@@ -23,7 +23,7 @@ module Bootstrap::AlertHelper
23
23
  # @overload alert(text, alert_type, options={})
24
24
  # @param text [String] text of the label
25
25
  # @param alert_type [Symbol, String] if present must be one of {Bootstrap::AlertHelper::ALERT_ATTRIBUTES}
26
- # @param options [Hash] html attributes for returned alert <div>
26
+ # @param options [Hash] unrecognized options become html attributes for returned alert <div>
27
27
  # @option options [String] :heading if present, include a heading in the alert
28
28
  # @option options [Boolean] :close if +false+, don't include a close link ('x')
29
29
  # @return [String] Returns html for alert
@@ -32,8 +32,11 @@ module Bootstrap::DropdownHelper
32
32
  # @param [String] text text of dropdown link
33
33
  # @yield yielded block is usually calls to {Bootstrap::NavHelper#dropdown_item} or {Bootstrap::NavHelper#dropdown_divider}
34
34
  # @return [String] '<li class='dropdown'><ul class='dropdown-menu'> with contents of yielded block
35
- def nav_dropdown(text)
36
- content_tag(:li, class: 'dropdown') do
35
+ def nav_dropdown(text, options={})
36
+ options = canonicalize_options(options)
37
+ options = ensure_class(options, 'dropdown')
38
+
39
+ content_tag(:li, options) do
37
40
  nav_dropdown_link(text) + dropdown_ul { yield }
38
41
  end
39
42
  end
@@ -8,17 +8,18 @@
8
8
  # <%= brand('Link Brand', url: '#')%>
9
9
  #
10
10
  # <%= nav_bar_links do %>
11
- #
12
11
  # <%= nav_bar_link('Active', '#', active: true) %>
13
- # <%= nav_bar_link('Link1', '/link1') %>
14
- #
12
+ # <%= nav_bar_link('Link 1', '/link1') %>
15
13
  # <%= nav_bar_divider %>
16
- #
14
+ # <%= nav_bar_link('Link 2', '/link2') %>
15
+ # <% end >
16
+ #
17
+ # <%= nav_dropdown(pull: 'right') %>
17
18
  # <%= nav_dropdown('Foo') do %>
18
19
  # <%= dropdown_item('One', 'foo')%>
19
20
  # <% end %>
20
- #
21
21
  # <% end %>
22
+ #
22
23
  # <% end %>
23
24
  #
24
25
  # @example navigation list (e.g., in sidebar)
@@ -68,16 +69,22 @@ module Bootstrap::NavHelper
68
69
  end
69
70
  end
70
71
 
71
- # Returns <ul> for a group of nav bar links.
72
+ # Returns <div> for a group of nav bar links, <ul>s.
72
73
  #
73
74
  # Usually called in +yield+ block of {Bootstrap::NavHelper#nav_bar}
74
75
  #
76
+ # @param options [Hash] options except for +:pull+ become html attributes of generated <div>
77
+ # @option options [:left, :right] pull will add class of "pull-left|right" for Bootstrap nav bar positioning
75
78
  # @yield block usually consists of calls to {Bootstrap::NavHelper#nav_bar_link} and {Bootstrap::NavHelper#nav_bar_divider}
76
79
  # @return [String] <div class='nav'> containing results of yielded block
77
80
  def nav_bar_links(options={})
78
81
  options = canonicalize_options(options)
79
82
  options = ensure_class(options, 'nav')
80
83
 
84
+ if pull = options.delete(:pull)
85
+ options = ensure_class(options, "pull-#{pull}")
86
+ end
87
+
81
88
  content_tag(:div, options) do
82
89
  yield
83
90
  end
@@ -132,4 +139,29 @@ module Bootstrap::NavHelper
132
139
  def nav_list_header(text)
133
140
  content_tag(:li, text, class: 'nav-header')
134
141
  end
142
+
143
+ # Wraps _text_ so it has proper leading and color for text in a nav bar. Usually
144
+ # in a +nav_bar_links+ block
145
+ #
146
+ # Note that the Bootstrap CSS has no horizontal margins or padding. This method
147
+ # pads with three +\&nbsp;+ at front and back. Use +pad: false+ to suppress padding.
148
+ #
149
+ # @param text [String] text to display
150
+ # @param options [Hash] unknown options become html attributes for the <p>
151
+ # @option options [:left, :right] :pull (:left) adds the Boostrap positioning class
152
+ # @option options [Boolean] :pad (true) include padding around text
153
+ # @return [String]
154
+ def nav_bar_text(text, options={})
155
+ options = canonicalize_options(options)
156
+
157
+ unless options.delete(:pad) == false
158
+ padding = ("&nbsp;" * 3).html_safe
159
+ text = padding + h(text) + padding
160
+ end
161
+
162
+ pull_class = (options.delete(:pull).to_s == 'right' ? 'pull-right' : 'pull-left')
163
+ options = ensure_class(options, [pull_class, 'navbar-text'])
164
+
165
+ content_tag(:p, text, options)
166
+ end
135
167
  end
@@ -5,11 +5,17 @@
5
5
  <%= nav_bar_links do %>
6
6
  <%= nav_bar_link('Application Home', bvh_app_home_link) %>
7
7
  <%= nav_bar_link('Active', '#', active: true) %>
8
- <%= nav_bar_link('Link1', '/link1') %>
8
+ <%= nav_bar_link('Link 1', '#') %>
9
9
  <%= nav_bar_divider %>
10
+ <%= nav_bar_link('Link 2', '#') %>
11
+ <% end %>
12
+
13
+ <%= nav_bar_links(pull: 'right') do %>
10
14
  <%= nav_dropdown('Foo') do %>
11
15
  <%= dropdown_item('One', 'foo') %>
12
16
  <% end %>
13
17
  <% end %>
18
+
19
+ <%= nav_bar_text("Logged in as admin", pull: 'right') %>
14
20
 
15
21
  <% end %>
@@ -1,7 +1,7 @@
1
1
  <h1>Form Helpers</h1>
2
2
 
3
3
  <p>
4
- <%= link_to('API Documentation', 'http://rubydoc.info/gems/bootstrap-view-helpers/frames/file/README.md') %>
4
+ <%= link_to('API Documentation', 'http://rubydoc.info/gems/bootstrap-view-helpers/Bootstrap/FormHelper') %>
5
5
  </p>
6
6
 
7
7
  <h2>Example</h2>
@@ -1,3 +1,3 @@
1
1
  module BootstrapViewHelpers
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap-view-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: