bootstrap-navbar 3.0.4 → 3.1.1

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: a7672f76fb3d9804811d5e76193473f84b9a6c098df2407481d11a0cf8faf69a
4
- data.tar.gz: bc88570acfb419681764a420d7be1e34fa98e70e94fda91429a3b53d5c577c06
3
+ metadata.gz: 3445728612483f40949783e8114c602586ae724d5dc87aad2b40ccb206451851
4
+ data.tar.gz: 7be996d67556fce1e26cd5ba7c2312e5f4bb94d77bdda23af9ef1380d8d7863b
5
5
  SHA512:
6
- metadata.gz: ae5680d5d6dd7930d69914673bbf920556e615a9b3f4b7b0dcf543b74b6fb15799a4f4858cac5eb71c69e7d13535f0409cc71e053ba9c32360583c9cc80ee62d
7
- data.tar.gz: af6c272f6fb2f21c38a93c374ad172c6bc41ae28193747c70adfc4ecf9f073af23b0376bc7f600158c7963abc8a4f663e2bd43a3a8878d375193f25200ea4100
6
+ metadata.gz: c6f775024975cbeb5c0cb9de3330cb38d2b47f7fdf89d940a4dc19312d1127068cd98bbe9ca9960fe18c0c3da311035bd6d4e78c79ffaf278d8591d0805495a8
7
+ data.tar.gz: 51c165a6e7464b77a44dbe1ab8c8e5f86c1bceac6dde177c5aa8a6e6f8e289dc573ae293031d7b481b463264a5b0d66c266fd72a379e4148fe8e2f32e30f925a
data/README.md CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/bootstrap-navbar.png)](http://badge.fury.io/rb/bootstrap-navbar)
4
4
  [![Build Status](https://secure.travis-ci.org/bootstrap-ruby/bootstrap-navbar.png)](http://travis-ci.org/bootstrap-ruby/bootstrap-navbar)
5
- [![Dependency Status](https://gemnasium.com/bootstrap-ruby/bootstrap-navbar.png)](https://gemnasium.com/bootstrap-ruby/bootstrap-navbar)
6
5
  [![Code Climate](https://codeclimate.com/github/bootstrap-ruby/bootstrap-navbar.png)](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(&block)
14
+ container container do
15
+ prepare_html <<~HTML
16
+ #{brand}
17
+ #{capture(&block) if block_given?}
18
+ HTML
19
+ end
8
20
  else
9
- capture(&block) if block_given?
21
+ prepare_html <<~HTML
22
+ #{brand}
23
+ #{capture(&block) if block_given?}
24
+ HTML
10
25
  end
11
26
  end
12
27
  end
@@ -26,29 +41,33 @@ module BootstrapNavbar::Helpers::Bootstrap4
26
41
  'aria-expanded' => false,
27
42
  'aria-label' => 'Toggle navigation'
28
43
  )
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
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 <<-HTML.chomp!
44
- <ul#{attributes}>
45
- #{capture(&block) if block_given?}
46
- </ul>
47
- HTML
58
+ prepare_html <<~HTML
59
+ <ul#{attributes}>
60
+ #{capture(&block) if block_given?}
61
+ </ul>
62
+ HTML
63
+ end
64
+
65
+ def navbar_text(text)
66
+ %(<span class="navbar-text">#{text}</span>)
48
67
  end
49
68
 
50
69
  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?
70
+ text, url, list_item_options, link_options = capture(&block), text, (url || {}), list_item_options if block_given?
52
71
  url ||= '#'
53
72
  list_item_options = list_item_options ? list_item_options.dup : {}
54
73
  link_options = link_options ? link_options.dup : {}
@@ -58,89 +77,92 @@ HTML
58
77
  link_options[:class] = link_options[:class].join(' ')
59
78
  list_item_attributes = attributes_for_tag(list_item_options)
60
79
  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
80
+ prepare_html <<~HTML
81
+ <li#{list_item_attributes}>
82
+ <a href="#{url}"#{link_attributes}>
83
+ #{text}
84
+ </a>
85
+ </li>
86
+ HTML
68
87
  end
69
88
 
70
- def navbar_dropdown(text, id = '', list_item_options = {}, link_options = {}, &block)
89
+ def navbar_dropdown(text, list_item_options = {}, link_options = {}, wrapper_options = {}, &block)
71
90
  list_item_options, link_options = list_item_options.dup, link_options.dup
72
91
  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
92
  list_item_attributes = attributes_for_tag(list_item_options)
75
93
  link_options[:class] = [link_options[:class], 'nav-link', 'dropdown-toggle'].compact.join(' ')
76
- id ||= "navbarDropdownMenuLink#{text}"
77
94
  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
95
+ wrapper_options = { class: [*wrapper_options.delete(:class), 'dropdown-menu'].compact.join(' ') }
96
+ if id = link_options[:id]
97
+ wrapper_options[:'aria-labelledby'] = id
98
+ end
99
+ wrapper_attributes = attributes_for_tag(wrapper_options)
100
+ prepare_html <<~HTML
101
+ <li#{list_item_attributes}>
102
+ <a href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" role="button"#{link_attributes}>#{text}</a>
103
+ <div#{wrapper_attributes}>
104
+ #{capture(&block) if block_given?}
105
+ </div>
106
+ </li>
107
+ HTML
86
108
  end
87
109
 
88
- def navbar_dropdown_item(text, url = '#', link_options = {}, &block)
110
+ def navbar_dropdown_item(text, url = nil, link_options = {}, &block)
111
+ text, url, link_options = capture(&block), text, (url || {}) if block_given?
112
+ url ||= '#'
89
113
  link_options = link_options.dup
90
114
  link_options[:class] = [link_options[:class], 'dropdown-item'].compact
91
115
  link_options[:class] << 'active' if current_url_or_sub_url?(url)
92
116
  link_options[:class] = link_options[:class].join(' ')
93
117
  link_attributes = attributes_for_tag(link_options)
94
- prepare_html <<-HTML.chomp!
95
- <a href="#{url}"#{link_attributes}>
96
- #{text}
97
- </a>
98
- HTML
118
+ prepare_html <<~HTML
119
+ <a href="#{url}"#{link_attributes}>
120
+ #{text}
121
+ </a>
122
+ HTML
99
123
  end
100
124
 
101
125
  def navbar_dropdown_divider
102
- prepare_html <<-HTML.chomp!
103
- <div class="dropdown-divider"></div>
104
- HTML
126
+ '<div class="dropdown-divider"></div>'
105
127
  end
106
128
 
107
129
  private
108
130
 
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
131
+ def container(container, &block)
132
+ container_class = [
133
+ 'container',
134
+ (container unless container == true)
135
+ ].compact.join('-')
136
+ attributes = attributes_for_tag(class: container_class)
137
+ prepare_html <<~HTML
138
+ <div#{attributes}>
139
+ #{capture(&block) if block_given?}
140
+ </div>
141
+ HTML
123
142
  end
124
143
 
125
144
  def wrapper(options, &block)
126
145
  options = options.dup
127
146
  options[:class] = [options[:class], 'navbar'].compact
128
147
  options[:class] << "navbar-#{options.key?(:color_scheme) ? options.delete(:color_scheme) : 'dark'}"
129
- options[:class] << "bg-#{options.delete(:bg) || 'dark'}" unless options[:bg] == false
148
+ if bg = options.delete(:bg)
149
+ options[:class] << "bg-#{bg == true ? 'dark' : bg}"
150
+ end
130
151
  if options.key?(:sticky) && options.delete(:sticky) === true
131
152
  options[:class] << 'sticky-top'
132
153
  elsif options.key?(:placement)
133
154
  options[:class] << "fixed-#{options.delete(:placement)}"
134
155
  end
135
- options[:class] << "navbar-expand-#{options.delete(:expand_at) || 'sm'}"
156
+ expand_at = options.delete(:expand_at)
157
+ unless expand_at == true
158
+ options[:class] << "navbar-expand#{"-#{expand_at}" if expand_at}"
159
+ end
136
160
  options[:class] = options[:class].join(' ')
137
- brand = brand_link(options.delete(:brand), options.delete(:brand_url)) if options[:brand]
138
161
  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
162
+ prepare_html <<~HTML
163
+ <nav#{attributes}>
164
+ #{capture(&block) if block_given?}
165
+ </nav>
166
+ HTML
145
167
  end
146
168
  end
@@ -1,3 +1,3 @@
1
1
  module BootstrapNavbar
2
- VERSION = '3.0.4'
2
+ VERSION = '3.1.1'
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.4
4
+ version: 3.1.1
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: 2018-10-25 00:00:00.000000000 Z
11
+ date: 2020-12-19 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
- rubyforge_project:
172
- rubygems_version: 2.7.6
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: