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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb5218185e5ba6cc70a64c3911abedebdc32a2297f80ad22ab4049e8738a65ff
4
- data.tar.gz: 102ec9fcf068836389359a03e3092d401287cc003e40e2f3c114d030f284c643
3
+ metadata.gz: 664b31ec11c5eddd161c8fe611031cd1b37c666ec1e61e49e2ba2fcd479e6a5c
4
+ data.tar.gz: 8a78830ec8d7ac5e6a8f53c55bd9a84ab6ff35087d4556514575ca5dafbbc8be
5
5
  SHA512:
6
- metadata.gz: fa3f5f64c868a3e5dff75a2f379181cd5a7b47b2a271fe1fcd30b56c20941b67009978f832376adcad285b21b45eb97692b0bedb5408660636d61abd5f8d5731
7
- data.tar.gz: a62bd84aac9b3776d481643dbcbc162391ec2863a4194d226c88f9bb1849821307045e2f414c8dc7e4ece4c1ed324f0bba43109a3cb039e135f57fb4a1452b67
6
+ metadata.gz: e56ee486db7f8aece5742eb7057dddc947786e531579fddfdffe4d81382b8441f2c0b8fd56cb09ac7378dc6eceb290a2078c52c9a4827f8ca9df27848c4324c3
7
+ data.tar.gz: 5bf3af265d451b97eb0e04ec80b89ad362683cbb0690209ca8d7c11d865a2c714e7e975398a41d089ceba9c35cd2dd7bd526255935e35d720bd922cba5cca505
@@ -15,7 +15,7 @@ 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
@@ -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(&block)
18
+ container container do
19
+ prepare_html <<~HTML
20
+ #{brand}
21
+ #{capture(&block) if block_given?}
22
+ HTML
23
+ end
8
24
  else
9
- capture(&block) if block_given?
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 <<-HTML.chomp!
30
- <button#{toggler_attributes}>
31
- <span class="navbar-toggler-icon"></span>
32
- </button>
33
- <div#{attributes}>
34
- #{capture(&block) if block_given?}
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 <<-HTML.chomp!
44
- <ul#{attributes}>
45
- #{capture(&block) if block_given?}
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 <<-HTML.chomp!
62
- <li#{list_item_attributes}>
63
- <a href="#{url}"#{link_attributes}>
64
- #{text}
65
- </a>
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, id = '', list_item_options = {}, link_options = {}, &block)
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
- prepare_html <<-HTML.chomp!
79
- <li#{list_item_attributes}>
80
- <a href="#" data-toggle="dropdown" id="##{id}" aria-haspopup="true" aria-expanded="false" role="button" #{link_attributes}>#{text}</a>
81
- <div class="#{wrapper_class}" aria-labelledby="#{id}">
82
- #{capture(&block) if block_given?}
83
- </div>
84
- </li>
85
- HTML
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 = '#', link_options = {}, &block)
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 <<-HTML.chomp!
95
- <a href="#{url}"#{link_attributes}>
96
- #{text}
97
- </a>
98
- HTML
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
- prepare_html <<-HTML.chomp!
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
- prepare_html <<-HTML.chomp!
111
- <div class="container">
112
- #{capture(&block) if block_given?}
113
- </div>
114
- HTML
115
- end
116
-
117
- def brand_link(text, url = nil)
118
- prepare_html <<-HTML.chomp!
119
- <a href="#{url || '/'}" class="navbar-brand">
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
- options[:class] << "bg-#{options.delete(:bg) || 'dark'}" unless options[:bg] == false
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
- options[:class] << "navbar-expand-#{options.delete(:expand_at) || 'sm'}"
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 <<-HTML.chomp!
140
- <nav#{attributes}>
141
- #{brand}
142
- #{capture(&block) if block_given?}
143
- </nav>
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
@@ -1,3 +1,3 @@
1
1
  module BootstrapNavbar
2
- VERSION = '3.0.5'
2
+ VERSION = '3.1.2'
3
3
  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.5
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: 2019-06-11 00:00:00.000000000 Z
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.0.2
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: