bootstrap-navbar 3.0.2 → 3.0.7
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31c1c11b16764f02d05e907c90ec1485dc0ca435032b1492d873f3d79c3818c6
|
4
|
+
data.tar.gz: 1e8dfe8093cc0455703c9ce05eb80590ade4bcb93f8b01fc53d8fd7f3b41595d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f5b2f052f44d4c98533712ed45e6fe323c1d15a6f041d7e1a67cb8590122bc12cbbc9b4564995da40280c194b58500855609257be197f08928013547b011064
|
7
|
+
data.tar.gz: 65ceeca8fe2f44d3ca81fecc926876936bf7b1907adbd35061befddea130d7d4593e8a8726b0d3e79701c21c64d8320792c419465e83a5b31013a97c9fca5e9a
|
data/README.md
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
[](http://badge.fury.io/rb/bootstrap-navbar)
|
4
4
|
[](http://travis-ci.org/bootstrap-ruby/bootstrap-navbar)
|
5
|
-
[](https://gemnasium.com/bootstrap-ruby/bootstrap-navbar)
|
6
5
|
[](https://codeclimate.com/github/bootstrap-ruby/bootstrap-navbar)
|
7
6
|
|
8
7
|
Helpers to generate a Bootstrap style navbar
|
@@ -103,3 +102,7 @@ See [CHANGELOG](CHANGELOG.md)
|
|
103
102
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
104
103
|
4. Push to the branch (`git push origin my-new-feature`)
|
105
104
|
5. Create new Pull Request
|
105
|
+
|
106
|
+
## Support
|
107
|
+
|
108
|
+
If you like this project, consider [buying me a coffee](https://www.buymeacoffee.com/279lcDtbF)! :)
|
@@ -15,14 +15,14 @@ module BootstrapNavbar::Helpers
|
|
15
15
|
def attributes_for_tag(hash)
|
16
16
|
string = hash.map { |k, v| %(#{k}="#{v}") }.join(' ')
|
17
17
|
if string.length > 0
|
18
|
-
' ' << string
|
18
|
+
' '.dup << string
|
19
19
|
else
|
20
20
|
string
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
def current_url_or_sub_url?(url)
|
25
|
-
return false if url == '#'
|
25
|
+
return false if url == '#' || url =~ /\Atel:/
|
26
26
|
uri, current_uri = [url, current_url].map do |url|
|
27
27
|
URI.parse(url)
|
28
28
|
end
|
@@ -2,11 +2,26 @@ module BootstrapNavbar::Helpers::Bootstrap4
|
|
2
2
|
def navbar(options = {}, &block)
|
3
3
|
options = options.dup
|
4
4
|
container = options.key?(:container) ? options.delete(:container) : false
|
5
|
+
brand = if options[:brand]
|
6
|
+
prepare_html <<~HTML
|
7
|
+
<a href="#{options.delete(:brand_url) || '/'}" class="navbar-brand">
|
8
|
+
#{options.delete(:brand)}
|
9
|
+
</a>
|
10
|
+
HTML
|
11
|
+
end
|
5
12
|
wrapper options do
|
6
13
|
if container
|
7
|
-
container
|
14
|
+
container container do
|
15
|
+
prepare_html <<~HTML
|
16
|
+
#{brand}
|
17
|
+
#{capture(&block) if block_given?}
|
18
|
+
HTML
|
19
|
+
end
|
8
20
|
else
|
9
|
-
|
21
|
+
prepare_html <<~HTML
|
22
|
+
#{brand}
|
23
|
+
#{capture(&block) if block_given?}
|
24
|
+
HTML
|
10
25
|
end
|
11
26
|
end
|
12
27
|
end
|
@@ -26,25 +41,25 @@ module BootstrapNavbar::Helpers::Bootstrap4
|
|
26
41
|
'aria-expanded' => false,
|
27
42
|
'aria-label' => 'Toggle navigation'
|
28
43
|
)
|
29
|
-
prepare_html
|
30
|
-
<button#{toggler_attributes}>
|
31
|
-
|
32
|
-
</button>
|
33
|
-
<div#{attributes}>
|
34
|
-
|
35
|
-
</div>
|
36
|
-
HTML
|
44
|
+
prepare_html <<~HTML
|
45
|
+
<button#{toggler_attributes}>
|
46
|
+
<span class="navbar-toggler-icon"></span>
|
47
|
+
</button>
|
48
|
+
<div#{attributes}>
|
49
|
+
#{capture(&block) if block_given?}
|
50
|
+
</div>
|
51
|
+
HTML
|
37
52
|
end
|
38
53
|
|
39
54
|
def navbar_group(options = {}, &block)
|
40
55
|
options = options.dup
|
41
56
|
options[:class] = [options[:class], 'navbar-nav'].compact.join(' ')
|
42
57
|
attributes = attributes_for_tag(options)
|
43
|
-
prepare_html
|
44
|
-
<ul#{attributes}>
|
45
|
-
|
46
|
-
</ul>
|
47
|
-
HTML
|
58
|
+
prepare_html <<~HTML
|
59
|
+
<ul#{attributes}>
|
60
|
+
#{capture(&block) if block_given?}
|
61
|
+
</ul>
|
62
|
+
HTML
|
48
63
|
end
|
49
64
|
|
50
65
|
def navbar_item(text, url = nil, list_item_options = nil, link_options = nil, &block)
|
@@ -58,30 +73,31 @@ HTML
|
|
58
73
|
link_options[:class] = link_options[:class].join(' ')
|
59
74
|
list_item_attributes = attributes_for_tag(list_item_options)
|
60
75
|
link_attributes = attributes_for_tag(link_options)
|
61
|
-
prepare_html
|
62
|
-
<li#{list_item_attributes}>
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
</li>
|
67
|
-
HTML
|
76
|
+
prepare_html <<~HTML
|
77
|
+
<li#{list_item_attributes}>
|
78
|
+
<a href="#{url}"#{link_attributes}>
|
79
|
+
#{text}
|
80
|
+
</a>
|
81
|
+
</li>
|
82
|
+
HTML
|
68
83
|
end
|
69
84
|
|
70
85
|
def navbar_dropdown(text, id = '', list_item_options = {}, link_options = {}, &block)
|
71
86
|
list_item_options, link_options = list_item_options.dup, link_options.dup
|
72
87
|
list_item_options[:class] = [list_item_options[:class], 'nav-item', 'dropdown'].compact.join(' ')
|
88
|
+
wrapper_class = [*list_item_options.delete(:wrapper_class), 'dropdown-menu'].compact.join(' ')
|
73
89
|
list_item_attributes = attributes_for_tag(list_item_options)
|
74
90
|
link_options[:class] = [link_options[:class], 'nav-link', 'dropdown-toggle'].compact.join(' ')
|
75
91
|
id ||= "navbarDropdownMenuLink#{text}"
|
76
92
|
link_attributes = attributes_for_tag(link_options)
|
77
|
-
prepare_html
|
78
|
-
<li#{list_item_attributes}>
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
</li>
|
84
|
-
HTML
|
93
|
+
prepare_html <<~HTML
|
94
|
+
<li#{list_item_attributes}>
|
95
|
+
<a href="#" data-toggle="dropdown" id="##{id}" aria-haspopup="true" aria-expanded="false" role="button" #{link_attributes}>#{text}</a>
|
96
|
+
<div class="#{wrapper_class}" aria-labelledby="#{id}">
|
97
|
+
#{capture(&block) if block_given?}
|
98
|
+
</div>
|
99
|
+
</li>
|
100
|
+
HTML
|
85
101
|
end
|
86
102
|
|
87
103
|
def navbar_dropdown_item(text, url = '#', link_options = {}, &block)
|
@@ -90,36 +106,39 @@ HTML
|
|
90
106
|
link_options[:class] << 'active' if current_url_or_sub_url?(url)
|
91
107
|
link_options[:class] = link_options[:class].join(' ')
|
92
108
|
link_attributes = attributes_for_tag(link_options)
|
93
|
-
prepare_html
|
94
|
-
<a href="#{url}"#{link_attributes}>
|
95
|
-
|
96
|
-
</a>
|
97
|
-
|
109
|
+
prepare_html <<~HTML
|
110
|
+
<a href="#{url}"#{link_attributes}>
|
111
|
+
#{text}
|
112
|
+
</a>
|
113
|
+
HTML
|
98
114
|
end
|
99
115
|
|
100
|
-
|
101
|
-
|
102
|
-
def container(&block)
|
103
|
-
prepare_html <<-HTML.chomp!
|
104
|
-
<div class="container">
|
105
|
-
#{capture(&block) if block_given?}
|
106
|
-
</div>
|
107
|
-
HTML
|
116
|
+
def navbar_dropdown_divider
|
117
|
+
'<div class="dropdown-divider"></div>'
|
108
118
|
end
|
109
119
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
120
|
+
private
|
121
|
+
|
122
|
+
def container(container, &block)
|
123
|
+
container_class = [
|
124
|
+
'container',
|
125
|
+
(container unless container == true)
|
126
|
+
].compact.join('-')
|
127
|
+
attributes = attributes_for_tag(class: container_class)
|
128
|
+
prepare_html <<~HTML
|
129
|
+
<div#{attributes}>
|
130
|
+
#{capture(&block) if block_given?}
|
131
|
+
</div>
|
132
|
+
HTML
|
116
133
|
end
|
117
134
|
|
118
135
|
def wrapper(options, &block)
|
119
136
|
options = options.dup
|
120
137
|
options[:class] = [options[:class], 'navbar'].compact
|
121
138
|
options[:class] << "navbar-#{options.key?(:color_scheme) ? options.delete(:color_scheme) : 'dark'}"
|
122
|
-
|
139
|
+
if bg = options.delete(:bg)
|
140
|
+
options[:class] << "bg-#{bg == true ? 'dark' : bg}"
|
141
|
+
end
|
123
142
|
if options.key?(:sticky) && options.delete(:sticky) === true
|
124
143
|
options[:class] << 'sticky-top'
|
125
144
|
elsif options.key?(:placement)
|
@@ -127,13 +146,11 @@ HTML
|
|
127
146
|
end
|
128
147
|
options[:class] << "navbar-expand-#{options.delete(:expand_at) || 'sm'}"
|
129
148
|
options[:class] = options[:class].join(' ')
|
130
|
-
brand = brand_link(options.delete(:brand), options.delete(:brand_url)) if options[:brand]
|
131
149
|
attributes = attributes_for_tag(options)
|
132
|
-
prepare_html
|
133
|
-
<nav#{attributes}>
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
HTML
|
150
|
+
prepare_html <<~HTML
|
151
|
+
<nav#{attributes}>
|
152
|
+
#{capture(&block) if block_given?}
|
153
|
+
</nav>
|
154
|
+
HTML
|
138
155
|
end
|
139
156
|
end
|
@@ -38,7 +38,7 @@ describe BootstrapNavbar::Helpers::Bootstrap4 do
|
|
38
38
|
|
39
39
|
context 'with "placement" parameter' do
|
40
40
|
it 'generates the correct HTML' do
|
41
|
-
%w(
|
41
|
+
%w(top bottom).each do |placement|
|
42
42
|
expect(renderer.navbar(placement: placement)).to have_tag(:nav, with: { class: "navbar navbar-dark bg-dark fixed-#{placement}" })
|
43
43
|
end
|
44
44
|
end
|
@@ -141,4 +141,22 @@ describe BootstrapNavbar::Helpers::Bootstrap4 do
|
|
141
141
|
end
|
142
142
|
end
|
143
143
|
end
|
144
|
+
|
145
|
+
describe '#navbar_dropdown' do
|
146
|
+
context 'with block' do
|
147
|
+
it 'generates the correct HTML' do
|
148
|
+
expect(renderer.navbar_dropdown('Foo', 'foo') { 'link-text' }).to have_tag(:li, with: { class: 'nav-item dropdown'}) do
|
149
|
+
with_tag :div, with: { class: 'dropdown-menu' }
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
context 'with right aligned menu' do
|
155
|
+
it 'generates the correct HTML' do
|
156
|
+
expect(renderer.navbar_dropdown('Foo', 'foo', { wrapper_class: 'dropdown-menu-right' }) { 'link-text' }).to have_tag(:li, with: { class: 'nav-item dropdown' }) do
|
157
|
+
with_tag :div, with: { class: 'dropdown-menu dropdown-menu-right' }
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
144
162
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstrap-navbar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manuel Meurer
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -153,7 +153,7 @@ homepage: http://bootstrap-ruby.github.io/bootstrap-navbar
|
|
153
153
|
licenses:
|
154
154
|
- MIT
|
155
155
|
metadata: {}
|
156
|
-
post_install_message:
|
156
|
+
post_install_message:
|
157
157
|
rdoc_options: []
|
158
158
|
require_paths:
|
159
159
|
- lib
|
@@ -168,9 +168,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
168
|
- !ruby/object:Gem::Version
|
169
169
|
version: '0'
|
170
170
|
requirements: []
|
171
|
-
|
172
|
-
|
173
|
-
signing_key:
|
171
|
+
rubygems_version: 3.1.3
|
172
|
+
signing_key:
|
174
173
|
specification_version: 4
|
175
174
|
summary: Helpers to generate a Bootstrap style navbar
|
176
175
|
test_files:
|