simple_navbar 0.1.0
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +3 -0
- data/app/assets/javascript/simple_navbar.js +69 -0
- data/app/assets/javascript/simple_navbar_controller.js +66 -0
- data/app/assets/stylesheets/simple_navbar.css +205 -0
- data/lib/generators/simple_navbar/install_generator.rb +48 -0
- data/lib/simple_navbar/railtie.rb +4 -0
- data/lib/simple_navbar/version.rb +3 -0
- data/lib/simple_navbar.rb +126 -0
- data/lib/tasks/simple_navbar_tasks.rake +4 -0
- metadata +71 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 90ac907a906962e9f5592805f756b00f7ed29b744d02f0f304ce4bc05b6ddcf0
|
4
|
+
data.tar.gz: 2b3d60097667b76189b821b1905a8c73eda2141bcf91795dc61819522b19229a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5b19c8d84daf69fc3c133b3db8037ca113472750ac5b60a84c3def570932b9feb8b019661db560b7c626ea4e8e09b131ebb56b6b36104f67fca587d09daedbe7
|
7
|
+
data.tar.gz: 76dbb79fa63af99bce55d1d78c2f0590c6e5c7f3d15d81c0fde22c124f82764753a7eaed7678fa0533625fbfceda662503892104ff1689cd3dd2206ddd5f8fe1
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright Rômulo Oliveira
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# SimpleNavbar
|
2
|
+
Short description and motivation.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
How to use my plugin.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem "simple_navbar"
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
```bash
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
```bash
|
21
|
+
$ gem install simple_navbar
|
22
|
+
```
|
23
|
+
|
24
|
+
## Contributing
|
25
|
+
Contribution directions go here.
|
26
|
+
|
27
|
+
## License
|
28
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
class MenuController {
|
2
|
+
constructor() {
|
3
|
+
this.menu = document.querySelector(".simple-nav-bar-nav-list-container");
|
4
|
+
this.burgerButton = document.querySelector(".simple-nav-bar-burger-button");
|
5
|
+
this.closeButton = document.querySelector(".simple-nav-bar-close-button");
|
6
|
+
this.dropdownMenu = document.querySelector(".simple-nav-bar-dropdown-menu");
|
7
|
+
this.dropdownToggleTargets = document.querySelectorAll(
|
8
|
+
".simple-nav-bar-dropdown-toggle"
|
9
|
+
);
|
10
|
+
|
11
|
+
this.menuToggle = this.menuToggle.bind(this);
|
12
|
+
this.checkWindowWidth = this.checkWindowWidth.bind(this);
|
13
|
+
this.dropdownToggle = this.dropdownToggle.bind(this);
|
14
|
+
|
15
|
+
this.burgerButton.addEventListener("click", this.menuToggle);
|
16
|
+
this.closeButton.addEventListener("click", this.menuToggle);
|
17
|
+
window.addEventListener("resize", this.checkWindowWidth);
|
18
|
+
|
19
|
+
this.init();
|
20
|
+
}
|
21
|
+
|
22
|
+
isMobile() {
|
23
|
+
return window.innerWidth < 1024;
|
24
|
+
}
|
25
|
+
|
26
|
+
init() {
|
27
|
+
if (this.isMobile()) {
|
28
|
+
this.menu.classList.add("simple-nav-bar-hidden");
|
29
|
+
this.burgerButton.classList.remove("simple-nav-bar-hidden");
|
30
|
+
this.closeButton.classList.add("simple-nav-bar-hidden");
|
31
|
+
}
|
32
|
+
this.dropdownToggleTargets.forEach((dropdownToggle) => {
|
33
|
+
dropdownToggle.addEventListener("click", () =>
|
34
|
+
this.dropdownToggle(dropdownToggle)
|
35
|
+
);
|
36
|
+
});
|
37
|
+
}
|
38
|
+
|
39
|
+
checkWindowWidth() {
|
40
|
+
if (this.isMobile()) {
|
41
|
+
this.menu.classList.add("simple-nav-bar-hidden");
|
42
|
+
this.burgerButton.classList.remove("simple-nav-bar-hidden");
|
43
|
+
this.closeButton.classList.add("simple-nav-bar-hidden");
|
44
|
+
} else {
|
45
|
+
this.menu.classList.remove("simple-nav-bar-hidden");
|
46
|
+
this.burgerButton.classList.add("simple-nav-bar-hidden");
|
47
|
+
this.closeButton.classList.add("simple-nav-bar-hidden");
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
menuToggle() {
|
52
|
+
this.menu.classList.toggle("simple-nav-bar-hidden");
|
53
|
+
this.burgerButton.classList.toggle("simple-nav-bar-hidden");
|
54
|
+
this.closeButton.classList.toggle("simple-nav-bar-hidden");
|
55
|
+
}
|
56
|
+
|
57
|
+
dropdownToggle(dropdown) {
|
58
|
+
const dropdownMenu = dropdown.nextElementSibling;
|
59
|
+
if (dropdownMenu) {
|
60
|
+
dropdownMenu.classList.toggle("simple-nav-bar-hidden");
|
61
|
+
dropdown.children[0].classList.toggle("simple-nav-bar-hidden");
|
62
|
+
dropdown.children[1].classList.toggle("simple-nav-bar-hidden");
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
document.addEventListener("turbo:load", () => {
|
68
|
+
new MenuController();
|
69
|
+
});
|
@@ -0,0 +1,66 @@
|
|
1
|
+
import { Controller } from "@hotwired/stimulus";
|
2
|
+
|
3
|
+
export default class extends Controller {
|
4
|
+
static targets = [
|
5
|
+
"menu",
|
6
|
+
"burgerButton",
|
7
|
+
"closeButton",
|
8
|
+
"dropdownMenu",
|
9
|
+
"dropdownToggle",
|
10
|
+
];
|
11
|
+
|
12
|
+
connect() {
|
13
|
+
console.log("SimpleNavBarController connected");
|
14
|
+
this.checkWindowWidth();
|
15
|
+
this.closeButtonTarget.classList.add("simple-nav-bar-hidden");
|
16
|
+
window.addEventListener("resize", () => this.watchWindowWidth());
|
17
|
+
this.dropdownToggleTargets.forEach((dropdownToggle) => {
|
18
|
+
dropdownToggle.addEventListener("click", () =>
|
19
|
+
this.dropdownToggle(dropdownToggle)
|
20
|
+
);
|
21
|
+
});
|
22
|
+
}
|
23
|
+
|
24
|
+
isMobile() {
|
25
|
+
return window.innerWidth < 1024;
|
26
|
+
}
|
27
|
+
|
28
|
+
watchWindowWidth() {
|
29
|
+
if (this.isMobile()) {
|
30
|
+
this.menuTarget.classList.add("simple-nav-bar-hidden");
|
31
|
+
this.burgerButtonTarget.classList.remove("simple-nav-bar-hidden");
|
32
|
+
this.closeButtonTarget.classList.add("simple-nav-bar-hidden");
|
33
|
+
} else {
|
34
|
+
this.menuTarget.classList.remove("simple-nav-bar-hidden");
|
35
|
+
this.burgerButtonTarget.classList.add("simple-nav-bar-hidden");
|
36
|
+
this.closeButtonTarget.classList.add("simple-nav-bar-hidden");
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
checkWindowWidth() {
|
41
|
+
if (this.isMobile()) {
|
42
|
+
this.menuTarget.classList.add("simple-nav-bar-hidden");
|
43
|
+
this.burgerButtonTarget.classList.remove("simple-nav-bar-hidden");
|
44
|
+
this.closeButtonTarget.classList.add("simple-nav-bar-hidden");
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
menuToggle() {
|
49
|
+
const menu = this.menuTarget;
|
50
|
+
const burger = this.burgerButtonTarget;
|
51
|
+
const close = this.closeButtonTarget;
|
52
|
+
|
53
|
+
if (menu) menu.classList.toggle("simple-nav-bar-hidden");
|
54
|
+
if (burger) burger.classList.toggle("simple-nav-bar-hidden");
|
55
|
+
if (close) close.classList.toggle("simple-nav-bar-hidden");
|
56
|
+
}
|
57
|
+
|
58
|
+
dropdownToggle(dropdown) {
|
59
|
+
const dropdownMenu = dropdown.nextElementSibling;
|
60
|
+
if (dropdownMenu) {
|
61
|
+
dropdownMenu.classList.toggle("simple-nav-bar-hidden");
|
62
|
+
dropdown.children[0].classList.toggle("simple-nav-bar-hidden");
|
63
|
+
dropdown.children[1].classList.toggle("simple-nav-bar-hidden");
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
@@ -0,0 +1,205 @@
|
|
1
|
+
/* Custom colors*/
|
2
|
+
:root {
|
3
|
+
--bg-color: #ffffff;
|
4
|
+
--text-color: #333333;
|
5
|
+
--shadow: rgba(0, 0, 0, 0.1);
|
6
|
+
--container-sm: 768px;
|
7
|
+
--container-md: 1024px;
|
8
|
+
--container-lg: 1280px;
|
9
|
+
}
|
10
|
+
|
11
|
+
[data-theme="dark"] {
|
12
|
+
--bg-color: #282a36;
|
13
|
+
--text-color: #f8f9fa;
|
14
|
+
--shadow: rgba(0, 0, 0, 0.3);
|
15
|
+
}
|
16
|
+
|
17
|
+
/* Navbar styles */
|
18
|
+
|
19
|
+
.simple-nav-bar-hidden {
|
20
|
+
display: none !important;
|
21
|
+
}
|
22
|
+
|
23
|
+
.simple-nav-bar {
|
24
|
+
position: fixed;
|
25
|
+
background-color: var(--bg-color);
|
26
|
+
color: var(--text-color);
|
27
|
+
padding: 16px;
|
28
|
+
z-index: 100;
|
29
|
+
width: 100%;
|
30
|
+
box-shadow: 0 4px 6px -1px var(--shadow);
|
31
|
+
}
|
32
|
+
|
33
|
+
.simple-nav-bar-container {
|
34
|
+
width: 100%;
|
35
|
+
margin-left: auto;
|
36
|
+
margin-right: auto;
|
37
|
+
display: flex;
|
38
|
+
flex-wrap: wrap;
|
39
|
+
align-items: center;
|
40
|
+
}
|
41
|
+
|
42
|
+
.simple-nav-bar-brand-link {
|
43
|
+
flex: 1;
|
44
|
+
display: flex;
|
45
|
+
align-items: center;
|
46
|
+
gap: 0.5rem;
|
47
|
+
}
|
48
|
+
|
49
|
+
.simple-nav-bar-brand-title {
|
50
|
+
font-size: 1.125rem;
|
51
|
+
font-weight: 700;
|
52
|
+
}
|
53
|
+
|
54
|
+
.simple-nav-bar-brand-logo {
|
55
|
+
width: 4rem;
|
56
|
+
height: 4rem;
|
57
|
+
}
|
58
|
+
|
59
|
+
.simple-nav-bar-burger-button {
|
60
|
+
display: block;
|
61
|
+
}
|
62
|
+
|
63
|
+
.simple-nav-bar-burger-line {
|
64
|
+
display: block;
|
65
|
+
width: 1rem;
|
66
|
+
height: 0.125rem;
|
67
|
+
background-color: var(--text-color);
|
68
|
+
margin-bottom: 0.25rem;
|
69
|
+
border-radius: 0.125rem;
|
70
|
+
}
|
71
|
+
|
72
|
+
.simple-nav-bar-burger-line:last-child {
|
73
|
+
margin-bottom: 0;
|
74
|
+
}
|
75
|
+
|
76
|
+
.simple-nav-bar-close-button {
|
77
|
+
position: relative;
|
78
|
+
z-index: 1000;
|
79
|
+
width: 1.5rem;
|
80
|
+
height: 1.5rem;
|
81
|
+
display: flex;
|
82
|
+
align-items: center;
|
83
|
+
justify-content: center;
|
84
|
+
color: white;
|
85
|
+
}
|
86
|
+
|
87
|
+
.simple-nav-bar-close-line {
|
88
|
+
display: block;
|
89
|
+
position: absolute;
|
90
|
+
width: 1rem;
|
91
|
+
height: 0.125rem;
|
92
|
+
background-color: var(--text-color);
|
93
|
+
}
|
94
|
+
|
95
|
+
.simple-nav-bar-close-line:first-child {
|
96
|
+
transform: rotate(45deg);
|
97
|
+
}
|
98
|
+
|
99
|
+
.simple-nav-bar-close-line:last-child {
|
100
|
+
transform: rotate(-45deg);
|
101
|
+
}
|
102
|
+
|
103
|
+
.simple-nav-bar-nav-list-container {
|
104
|
+
width: 100%;
|
105
|
+
}
|
106
|
+
|
107
|
+
.simple-nav-bar-nav-list {
|
108
|
+
font-size: 1.25rem;
|
109
|
+
text-align: start;
|
110
|
+
align-items: center;
|
111
|
+
column-gap: 1.25rem;
|
112
|
+
padding-top: 1rem;
|
113
|
+
}
|
114
|
+
|
115
|
+
/* Dropdown styles */
|
116
|
+
|
117
|
+
.simple-nav-bar-nav-item-dropdown {
|
118
|
+
position: relative;
|
119
|
+
}
|
120
|
+
|
121
|
+
.simple-nav-bar-dropdown-arrow-up,
|
122
|
+
.simple-nav-bar-dropdown-arrow-down {
|
123
|
+
font-size: 0.9rem;
|
124
|
+
margin-left: 6px;
|
125
|
+
padding: 0;
|
126
|
+
}
|
127
|
+
|
128
|
+
.simple-nav-bar-nav-item {
|
129
|
+
padding-top: 0.5rem;
|
130
|
+
padding-bottom: 0.5rem;
|
131
|
+
}
|
132
|
+
|
133
|
+
.simple-nav-bar-nav-link:hover {
|
134
|
+
color: rgb(156, 163, 175);
|
135
|
+
}
|
136
|
+
|
137
|
+
.simple-nav-bar-dropdown-menu {
|
138
|
+
position: absolute;
|
139
|
+
background-color: var(--bg-color);
|
140
|
+
z-index: 100;
|
141
|
+
top: 36px;
|
142
|
+
right: 0;
|
143
|
+
left: 0;
|
144
|
+
width: fit-content;
|
145
|
+
flex-direction: column;
|
146
|
+
padding: 12px;
|
147
|
+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
|
148
|
+
0 2px 4px -1px rgba(0, 0, 0, 0.06), 0 8px 10px -2px rgba(0, 0, 0, 0.1),
|
149
|
+
0 3px 6px -2px rgba(0, 0, 0, 0.05);
|
150
|
+
}
|
151
|
+
|
152
|
+
.simple-nav-bar-dropdown-item {
|
153
|
+
display: block;
|
154
|
+
padding: 0.5rem 1rem;
|
155
|
+
text-decoration: none;
|
156
|
+
}
|
157
|
+
|
158
|
+
/* Media queries */
|
159
|
+
|
160
|
+
@media (min-width: 768px) {
|
161
|
+
.simple-nav-bar-container {
|
162
|
+
max-width: var(--container-sm);
|
163
|
+
}
|
164
|
+
|
165
|
+
.simple-nav-bar-nav-items {
|
166
|
+
column-gap: 1rem;
|
167
|
+
}
|
168
|
+
}
|
169
|
+
|
170
|
+
@media (min-width: 1024px) {
|
171
|
+
.simple-nav-bar-container {
|
172
|
+
max-width: var(--container-md);
|
173
|
+
}
|
174
|
+
|
175
|
+
.simple-nav-bar-burger-button,
|
176
|
+
.simple-nav-bar-close-button {
|
177
|
+
display: none;
|
178
|
+
}
|
179
|
+
|
180
|
+
.simple-nav-bar-nav-list-container {
|
181
|
+
display: flex;
|
182
|
+
align-items: center;
|
183
|
+
width: auto;
|
184
|
+
}
|
185
|
+
|
186
|
+
.simple-nav-bar-nav-list {
|
187
|
+
font-size: 1.125rem;
|
188
|
+
display: flex;
|
189
|
+
padding-top: 0;
|
190
|
+
}
|
191
|
+
|
192
|
+
.simple-nav-bar-nav-item {
|
193
|
+
padding: 0;
|
194
|
+
}
|
195
|
+
}
|
196
|
+
|
197
|
+
@media (min-width: 1280px) {
|
198
|
+
.simple-nav-bar-container {
|
199
|
+
max-width: var(--container-lg);
|
200
|
+
}
|
201
|
+
|
202
|
+
.simple-nav-bar-dropdown-menu {
|
203
|
+
top: 28px;
|
204
|
+
}
|
205
|
+
}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "rails/generators"
|
2
|
+
|
3
|
+
module SimpleNavbar
|
4
|
+
class InstallGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path("../../../", __dir__)
|
6
|
+
|
7
|
+
class_option :stimulus, type: :boolean, default: false, desc: "Copy Stimulus controller instead of plain JavaScript"
|
8
|
+
class_option :legacy, type: :boolean, default: false, desc: "Copy to app/assets/javascripts instead of app/javascript"
|
9
|
+
|
10
|
+
def copy_stylesheet
|
11
|
+
copy_file "app/assets/stylesheets/simple_navbar.css", "app/assets/stylesheets/simple_navbar.css"
|
12
|
+
end
|
13
|
+
|
14
|
+
def copy_javascript
|
15
|
+
if options[:legacy]
|
16
|
+
copy_to_assets_folder
|
17
|
+
else
|
18
|
+
copy_to_javascript_folder
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def include_helper_in_application_controller
|
23
|
+
inject_into_class "app/controllers/application_controller.rb", ApplicationController, " helper SimpleNavbar\n"
|
24
|
+
end
|
25
|
+
|
26
|
+
def include_javascript_tag_in_layout
|
27
|
+
unless options[:stimulus]
|
28
|
+
inject_into_file "app/views/layouts/application.html.erb", before: "</head>\n" do
|
29
|
+
" <%= javascript_include_tag 'custom/simple_navbar' %>\n"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def copy_to_javascript_folder
|
37
|
+
if options[:stimulus]
|
38
|
+
copy_file "app/assets/javascript/simple_navbar_controller.js", "app/javascript/controllers/simple_navbar_controller.js"
|
39
|
+
else
|
40
|
+
copy_file "app/assets/javascript/simple_navbar.js", "app/javascript/custom/simple_navbar.js"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def copy_to_assets_folder
|
45
|
+
copy_file "app/assets/javascript/simple_navbar.js", "app/assets/javascripts/simple_navbar.js"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
require "simple_navbar/version"
|
2
|
+
require "simple_navbar/railtie"
|
3
|
+
|
4
|
+
module SimpleNavbar
|
5
|
+
def simple_navbar(brand: {}, links: [])
|
6
|
+
content_tag :nav, class: "simple-nav-bar" do
|
7
|
+
content_tag(:div, class: "simple-nav-bar-container") do
|
8
|
+
concat(
|
9
|
+
content_tag(:a, href: brand[:url], class: "simple-nav-bar-brand-link") do
|
10
|
+
concat content_tag(:h1, brand[:title], class: "simple-nav-bar-brand-title") if brand[:title].present?
|
11
|
+
concat image_tag(brand[:logo], class: "simple-nav-bar-brand-logo") if brand[:logo].present?
|
12
|
+
end
|
13
|
+
)
|
14
|
+
|
15
|
+
concat(
|
16
|
+
content_tag(:button, class: "simple-nav-bar-burger-button") do
|
17
|
+
concat content_tag(:span, "", class: "simple-nav-bar-burger-line")
|
18
|
+
concat content_tag(:span, "", class: "simple-nav-bar-burger-line")
|
19
|
+
concat content_tag(:span, "", class: "simple-nav-bar-burger-line")
|
20
|
+
end
|
21
|
+
)
|
22
|
+
|
23
|
+
concat(
|
24
|
+
content_tag(:button, class: "simple-nav-bar-close-button") do
|
25
|
+
concat content_tag(:span, "", class: "simple-nav-bar-close-line")
|
26
|
+
concat content_tag(:span, "", class: "simple-nav-bar-close-line")
|
27
|
+
end
|
28
|
+
)
|
29
|
+
|
30
|
+
concat(
|
31
|
+
content_tag(:div, class: "simple-nav-bar-nav-list-container") do
|
32
|
+
content_tag(:nav) do
|
33
|
+
content_tag(:ul, class: "simple-nav-bar-nav-list") do
|
34
|
+
links.map do |link|
|
35
|
+
if link[:dropdown]
|
36
|
+
concat(
|
37
|
+
content_tag(:li, class: "simple-nav-bar-nav-item simple-nav-bar-nav-item-dropdown") do
|
38
|
+
concat(
|
39
|
+
content_tag(:button, class: "simple-nav-bar-nav-link simple-nav-bar-dropdown-toggle") do
|
40
|
+
concat link[:dropdown][:label]
|
41
|
+
concat content_tag(:span, "▼", class: "simple-nav-bar-dropdown-arrow-down")
|
42
|
+
concat content_tag(:span, "▲", class: "simple-nav-bar-dropdown-arrow-up simple-nav-bar-hidden")
|
43
|
+
end
|
44
|
+
)
|
45
|
+
concat(
|
46
|
+
content_tag(:ul, class: "simple-nav-bar-dropdown-menu simple-nav-bar-hidden", data: { simple_navbar_target: "dropdownMenu" }) do
|
47
|
+
link[:dropdown][:links].map do |sublink|
|
48
|
+
concat content_tag(:li, link_to(sublink[:label], sublink[:url], class: "simple-nav-bar-dropdown-item"))
|
49
|
+
end.join.html_safe
|
50
|
+
end
|
51
|
+
)
|
52
|
+
end
|
53
|
+
)
|
54
|
+
else
|
55
|
+
concat content_tag(:li, link_to(link[:label], link[:url], class: "simple-nav-bar-nav-link"), class: "simple-nav-bar-nav-item")
|
56
|
+
end
|
57
|
+
end.join.html_safe
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def simple_navbar_s(brand: {}, links: [])
|
67
|
+
content_tag :nav, class: "simple-nav-bar", data: { controller: "simple-navbar" } do
|
68
|
+
content_tag(:div, class: "simple-nav-bar-container") do
|
69
|
+
concat(
|
70
|
+
content_tag(:a, href: brand[:url], class: "simple-nav-bar-brand-link") do
|
71
|
+
concat content_tag(:h1, brand[:title], class: "simple-nav-bar-brand-title") if brand[:title].present?
|
72
|
+
concat image_tag(brand[:logo], class: "simple-nav-bar-brand-logo") if brand[:logo].present?
|
73
|
+
end
|
74
|
+
)
|
75
|
+
|
76
|
+
concat(
|
77
|
+
content_tag(:button, class: "simple-nav-bar-burger-button", data: { action: "click->simple-navbar#menuToggle", simple_navbar_target: "burgerButton" }) do
|
78
|
+
concat content_tag(:span, "", class: "simple-nav-bar-burger-line")
|
79
|
+
concat content_tag(:span, "", class: "simple-nav-bar-burger-line")
|
80
|
+
concat content_tag(:span, "", class: "simple-nav-bar-burger-line")
|
81
|
+
end
|
82
|
+
)
|
83
|
+
|
84
|
+
concat(
|
85
|
+
content_tag(:button, class: "simple-nav-bar-close-button", data: { action: "click->simple-navbar#menuToggle", simple_navbar_target: "closeButton" }) do
|
86
|
+
concat content_tag(:span, "", class: "simple-nav-bar-close-line")
|
87
|
+
concat content_tag(:span, "", class: "simple-nav-bar-close-line")
|
88
|
+
end
|
89
|
+
)
|
90
|
+
|
91
|
+
concat(
|
92
|
+
content_tag(:div, class: "simple-nav-bar-nav-list-container", data: { simple_navbar_target: "menu" }) do
|
93
|
+
content_tag(:nav) do
|
94
|
+
content_tag(:ul, class: "simple-nav-bar-nav-list") do
|
95
|
+
links.map do |link|
|
96
|
+
if link[:dropdown]
|
97
|
+
concat(
|
98
|
+
content_tag(:li, class: "simple-nav-bar-nav-item simple-nav-bar-nav-item-dropdown") do
|
99
|
+
concat(
|
100
|
+
content_tag(:button, class: "simple-nav-bar-nav-link", data: { simple_navbar_target: "dropdownToggle" }) do
|
101
|
+
concat link[:dropdown][:label]
|
102
|
+
concat content_tag(:span, "▼", class: "simple-nav-bar-dropdown-arrow-down")
|
103
|
+
concat content_tag(:span, "▲", class: "simple-nav-bar-dropdown-arrow-up simple-nav-bar-hidden")
|
104
|
+
end
|
105
|
+
)
|
106
|
+
concat(
|
107
|
+
content_tag(:ul, class: "simple-nav-bar-dropdown-menu simple-nav-bar-hidden", data: { simple_navbar_target: "dropdownMenu" }) do
|
108
|
+
link[:dropdown][:links].map do |sublink|
|
109
|
+
concat content_tag(:li, link_to(sublink[:label], sublink[:url], class: "simple-nav-bar-dropdown-item"))
|
110
|
+
end.join.html_safe
|
111
|
+
end
|
112
|
+
)
|
113
|
+
end
|
114
|
+
)
|
115
|
+
else
|
116
|
+
concat content_tag(:li, link_to(link[:label], link[:url], class: "simple-nav-bar-nav-link"), class: "simple-nav-bar-nav-item")
|
117
|
+
end
|
118
|
+
end.join.html_safe
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: simple_navbar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rômulo Oliveira
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-12-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '6.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '6.0'
|
27
|
+
description: Stop losing time creating a navbar from scratch. Use this gem to create
|
28
|
+
a simple and easy navbar for your Rails applications.
|
29
|
+
email:
|
30
|
+
- romuloffall@gmail.com
|
31
|
+
executables: []
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- MIT-LICENSE
|
36
|
+
- README.md
|
37
|
+
- Rakefile
|
38
|
+
- app/assets/javascript/simple_navbar.js
|
39
|
+
- app/assets/javascript/simple_navbar_controller.js
|
40
|
+
- app/assets/stylesheets/simple_navbar.css
|
41
|
+
- lib/generators/simple_navbar/install_generator.rb
|
42
|
+
- lib/simple_navbar.rb
|
43
|
+
- lib/simple_navbar/railtie.rb
|
44
|
+
- lib/simple_navbar/version.rb
|
45
|
+
- lib/tasks/simple_navbar_tasks.rake
|
46
|
+
homepage: https://github.com/RomuloOliveira94/simple_navbar
|
47
|
+
licenses:
|
48
|
+
- MIT
|
49
|
+
metadata:
|
50
|
+
homepage_uri: https://github.com/RomuloOliveira94/simple_navbar
|
51
|
+
source_code_uri: https://github.com/RomuloOliveira94/simple_navbar
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
requirements: []
|
67
|
+
rubygems_version: 3.5.23
|
68
|
+
signing_key:
|
69
|
+
specification_version: 4
|
70
|
+
summary: Simple and easy navbar for Rails applications.
|
71
|
+
test_files: []
|