bootstrap-navbar 3.0.5 → 3.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bootstrap-navbar/helpers.rb +1 -1
- data/lib/bootstrap-navbar/helpers/bootstrap4.rb +92 -66
- data/lib/bootstrap-navbar/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 664b31ec11c5eddd161c8fe611031cd1b37c666ec1e61e49e2ba2fcd479e6a5c
|
4
|
+
data.tar.gz: 8a78830ec8d7ac5e6a8f53c55bd9a84ab6ff35087d4556514575ca5dafbbc8be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e56ee486db7f8aece5742eb7057dddc947786e531579fddfdffe4d81382b8441f2c0b8fd56cb09ac7378dc6eceb290a2078c52c9a4827f8ca9df27848c4324c3
|
7
|
+
data.tar.gz: 5bf3af265d451b97eb0e04ec80b89ad362683cbb0690209ca8d7c11d865a2c714e7e975398a41d089ceba9c35cd2dd7bd526255935e35d720bd922cba5cca505
|
@@ -2,11 +2,30 @@ 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
|
+
brand_url = options.delete(:brand_url)
|
7
|
+
element, attributes = brand_url == false ? ['span', {}] : ['a', { href: brand_url || '/' }]
|
8
|
+
attributes[:class] = 'navbar-brand'
|
9
|
+
|
10
|
+
prepare_html <<~HTML
|
11
|
+
<#{element}#{attributes_for_tag(attributes)}>
|
12
|
+
#{options.delete(:brand)}
|
13
|
+
</#{element}>
|
14
|
+
HTML
|
15
|
+
end
|
5
16
|
wrapper options do
|
6
17
|
if container
|
7
|
-
container
|
18
|
+
container container do
|
19
|
+
prepare_html <<~HTML
|
20
|
+
#{brand}
|
21
|
+
#{capture(&block) if block_given?}
|
22
|
+
HTML
|
23
|
+
end
|
8
24
|
else
|
9
|
-
|
25
|
+
prepare_html <<~HTML
|
26
|
+
#{brand}
|
27
|
+
#{capture(&block) if block_given?}
|
28
|
+
HTML
|
10
29
|
end
|
11
30
|
end
|
12
31
|
end
|
@@ -26,29 +45,33 @@ module BootstrapNavbar::Helpers::Bootstrap4
|
|
26
45
|
'aria-expanded' => false,
|
27
46
|
'aria-label' => 'Toggle navigation'
|
28
47
|
)
|
29
|
-
prepare_html
|
30
|
-
<button#{toggler_attributes}>
|
31
|
-
|
32
|
-
</button>
|
33
|
-
<div#{attributes}>
|
34
|
-
|
35
|
-
</div>
|
36
|
-
HTML
|
48
|
+
prepare_html <<~HTML
|
49
|
+
<button#{toggler_attributes}>
|
50
|
+
<span class="navbar-toggler-icon"></span>
|
51
|
+
</button>
|
52
|
+
<div#{attributes}>
|
53
|
+
#{capture(&block) if block_given?}
|
54
|
+
</div>
|
55
|
+
HTML
|
37
56
|
end
|
38
57
|
|
39
58
|
def navbar_group(options = {}, &block)
|
40
59
|
options = options.dup
|
41
60
|
options[:class] = [options[:class], 'navbar-nav'].compact.join(' ')
|
42
61
|
attributes = attributes_for_tag(options)
|
43
|
-
prepare_html
|
44
|
-
<ul#{attributes}>
|
45
|
-
|
46
|
-
</ul>
|
47
|
-
HTML
|
62
|
+
prepare_html <<~HTML
|
63
|
+
<ul#{attributes}>
|
64
|
+
#{capture(&block) if block_given?}
|
65
|
+
</ul>
|
66
|
+
HTML
|
67
|
+
end
|
68
|
+
|
69
|
+
def navbar_text(text)
|
70
|
+
%(<span class="navbar-text">#{text}</span>)
|
48
71
|
end
|
49
72
|
|
50
73
|
def navbar_item(text, url = nil, list_item_options = nil, link_options = nil, &block)
|
51
|
-
text, url, list_item_options, link_options = capture(&block), text, url, list_item_options if block_given?
|
74
|
+
text, url, list_item_options, link_options = capture(&block), text, (url || {}), list_item_options if block_given?
|
52
75
|
url ||= '#'
|
53
76
|
list_item_options = list_item_options ? list_item_options.dup : {}
|
54
77
|
link_options = link_options ? link_options.dup : {}
|
@@ -58,89 +81,92 @@ HTML
|
|
58
81
|
link_options[:class] = link_options[:class].join(' ')
|
59
82
|
list_item_attributes = attributes_for_tag(list_item_options)
|
60
83
|
link_attributes = attributes_for_tag(link_options)
|
61
|
-
prepare_html
|
62
|
-
<li#{list_item_attributes}>
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
</li>
|
67
|
-
HTML
|
84
|
+
prepare_html <<~HTML
|
85
|
+
<li#{list_item_attributes}>
|
86
|
+
<a href="#{url}"#{link_attributes}>
|
87
|
+
#{text}
|
88
|
+
</a>
|
89
|
+
</li>
|
90
|
+
HTML
|
68
91
|
end
|
69
92
|
|
70
|
-
def navbar_dropdown(text,
|
93
|
+
def navbar_dropdown(text, list_item_options = {}, link_options = {}, wrapper_options = {}, &block)
|
71
94
|
list_item_options, link_options = list_item_options.dup, link_options.dup
|
72
95
|
list_item_options[:class] = [list_item_options[:class], 'nav-item', 'dropdown'].compact.join(' ')
|
73
|
-
wrapper_class = [*list_item_options.delete(:wrapper_class), 'dropdown-menu'].compact.join(' ')
|
74
96
|
list_item_attributes = attributes_for_tag(list_item_options)
|
75
97
|
link_options[:class] = [link_options[:class], 'nav-link', 'dropdown-toggle'].compact.join(' ')
|
76
|
-
id ||= "navbarDropdownMenuLink#{text}"
|
77
98
|
link_attributes = attributes_for_tag(link_options)
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
99
|
+
wrapper_options = { class: [*wrapper_options.delete(:class), 'dropdown-menu'].compact.join(' ') }
|
100
|
+
if id = link_options[:id]
|
101
|
+
wrapper_options[:'aria-labelledby'] = id
|
102
|
+
end
|
103
|
+
wrapper_attributes = attributes_for_tag(wrapper_options)
|
104
|
+
prepare_html <<~HTML
|
105
|
+
<li#{list_item_attributes}>
|
106
|
+
<a href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" role="button"#{link_attributes}>#{text}</a>
|
107
|
+
<div#{wrapper_attributes}>
|
108
|
+
#{capture(&block) if block_given?}
|
109
|
+
</div>
|
110
|
+
</li>
|
111
|
+
HTML
|
86
112
|
end
|
87
113
|
|
88
|
-
def navbar_dropdown_item(text, url =
|
114
|
+
def navbar_dropdown_item(text, url = nil, link_options = {}, &block)
|
115
|
+
text, url, link_options = capture(&block), text, (url || {}) if block_given?
|
116
|
+
url ||= '#'
|
89
117
|
link_options = link_options.dup
|
90
118
|
link_options[:class] = [link_options[:class], 'dropdown-item'].compact
|
91
119
|
link_options[:class] << 'active' if current_url_or_sub_url?(url)
|
92
120
|
link_options[:class] = link_options[:class].join(' ')
|
93
121
|
link_attributes = attributes_for_tag(link_options)
|
94
|
-
prepare_html
|
95
|
-
<a href="#{url}"#{link_attributes}>
|
96
|
-
|
97
|
-
</a>
|
98
|
-
|
122
|
+
prepare_html <<~HTML
|
123
|
+
<a href="#{url}"#{link_attributes}>
|
124
|
+
#{text}
|
125
|
+
</a>
|
126
|
+
HTML
|
99
127
|
end
|
100
128
|
|
101
129
|
def navbar_dropdown_divider
|
102
|
-
|
103
|
-
<div class="dropdown-divider"></div>
|
104
|
-
HTML
|
130
|
+
'<div class="dropdown-divider"></div>'
|
105
131
|
end
|
106
132
|
|
107
133
|
private
|
108
134
|
|
109
|
-
def container(&block)
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
#{text}
|
121
|
-
</a>
|
122
|
-
HTML
|
135
|
+
def container(container, &block)
|
136
|
+
container_class = [
|
137
|
+
'container',
|
138
|
+
(container unless container == true)
|
139
|
+
].compact.join('-')
|
140
|
+
attributes = attributes_for_tag(class: container_class)
|
141
|
+
prepare_html <<~HTML
|
142
|
+
<div#{attributes}>
|
143
|
+
#{capture(&block) if block_given?}
|
144
|
+
</div>
|
145
|
+
HTML
|
123
146
|
end
|
124
147
|
|
125
148
|
def wrapper(options, &block)
|
126
149
|
options = options.dup
|
127
150
|
options[:class] = [options[:class], 'navbar'].compact
|
128
151
|
options[:class] << "navbar-#{options.key?(:color_scheme) ? options.delete(:color_scheme) : 'dark'}"
|
129
|
-
|
152
|
+
if bg = options.delete(:bg)
|
153
|
+
options[:class] << "bg-#{bg == true ? 'dark' : bg}"
|
154
|
+
end
|
130
155
|
if options.key?(:sticky) && options.delete(:sticky) === true
|
131
156
|
options[:class] << 'sticky-top'
|
132
157
|
elsif options.key?(:placement)
|
133
158
|
options[:class] << "fixed-#{options.delete(:placement)}"
|
134
159
|
end
|
135
|
-
|
160
|
+
expand_at = options.delete(:expand_at)
|
161
|
+
unless expand_at == true
|
162
|
+
options[:class] << "navbar-expand#{"-#{expand_at}" if expand_at}"
|
163
|
+
end
|
136
164
|
options[:class] = options[:class].join(' ')
|
137
|
-
brand = brand_link(options.delete(:brand), options.delete(:brand_url)) if options[:brand]
|
138
165
|
attributes = attributes_for_tag(options)
|
139
|
-
prepare_html
|
140
|
-
<nav#{attributes}>
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
HTML
|
166
|
+
prepare_html <<~HTML
|
167
|
+
<nav#{attributes}>
|
168
|
+
#{capture(&block) if block_given?}
|
169
|
+
</nav>
|
170
|
+
HTML
|
145
171
|
end
|
146
172
|
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.
|
4
|
+
version: 3.1.2
|
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-12-21 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,8 +168,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
168
|
- !ruby/object:Gem::Version
|
169
169
|
version: '0'
|
170
170
|
requirements: []
|
171
|
-
rubygems_version: 3.
|
172
|
-
signing_key:
|
171
|
+
rubygems_version: 3.1.3
|
172
|
+
signing_key:
|
173
173
|
specification_version: 4
|
174
174
|
summary: Helpers to generate a Bootstrap style navbar
|
175
175
|
test_files:
|