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