lato 3.14.5 → 3.14.6

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: 0e875480609c4aaa1b932e6f1deaee666a2a3df6e30c86dafcd487bf874c7807
4
- data.tar.gz: 2598d84609cc7be515b88e903e101dde2ef8fa8b95e2943b345818380c7354a2
3
+ metadata.gz: 2c6664ab48177f66d9fb4290210f2d8390fe5b9c6bbbfd7ce90640edac41ed20
4
+ data.tar.gz: 7aae0d3c205a4207dce4499ff73870d0fd08c360a145fff08763c8e5181e0a25
5
5
  SHA512:
6
- metadata.gz: 5fd18d8715d6eda3955dcaad2781d6217becec2cc7aaf722aa52f55ad42a0d40f459322a825aa5b0836a81c004ac4f96119eaf08aa0ccaada0542e29c9f1ca14
7
- data.tar.gz: a1dba640c648db9b3a12b29211b8e25566c9a54366b274d528e181e8772146c56dffee945f05cede88298876948c5fa2fbda859d174ce228783261807186b43b
6
+ metadata.gz: 157174be653d6fb1030c1963ad66f77e54ec9d4bf69896ee7e29dd781dfb31744d1cb5a5782d73c604da161852fcb26f6ecdaf9ad8d3e43caf7898089d63fda9
7
+ data.tar.gz: 397e59f83ea024e125d97ded46a4616835ba8878bc0ab1f8c85d55d5e6d6e2d46ea682137db3171f987221da43ae2347d76699c4f51bafcb092a64da793a4341
@@ -51,6 +51,12 @@ document.addEventListener('turbo:before-cache', (e) => {
51
51
  document.body.style.paddingRight = ''
52
52
  document.body.style.overflow = ''
53
53
 
54
+ // close sidebar submenus
55
+ document.querySelectorAll('aside .nav-item .collapse.show').forEach((el) => {
56
+ if (el.querySelector('.nav-link.active')) return // keep open if contains active link
57
+ el.classList.remove('show')
58
+ })
59
+
54
60
  // close nav menu (for mobile)
55
61
  document.querySelector('.navbar-toggler').classList.add('collapsed')
56
62
  document.querySelector('.navbar-collapse').classList.remove('show')
@@ -61,6 +61,11 @@ aside {
61
61
  max-height: 100vh;
62
62
  position: sticky;
63
63
  top: 0;
64
+
65
+ .dropdown-toggle::after {
66
+ position: absolute;
67
+ right: 0.5rem;
68
+ }
64
69
  }
65
70
 
66
71
  main, aside {
@@ -21,11 +21,21 @@ module Lato
21
21
  # Sidebar
22
22
  ##
23
23
 
24
- def lato_sidebar_nav_item(key, path, external: false, &block)
24
+ def lato_sidebar_nav_item(key, path, external: false, children: nil, &block)
25
25
  active = request.path == path
26
26
  active = @sidebar_key == key if @sidebar_key
27
+
28
+ # se ci sono children, verifico se uno di questi è attivo e assegno a active la key del child attivo
29
+ if children && children.is_a?(Array)
30
+ children.each do |child|
31
+ if request.path == child[:path] || (@sidebar_key && @sidebar_key == (child[:key] || key))
32
+ active = child[:key] || key
33
+ break
34
+ end
35
+ end
36
+ end
27
37
 
28
- render 'lato/components/sidebar_nav_item', active: active, path: path, external: external do
38
+ render 'lato/components/sidebar_nav_item', key: key, active: active, path: path, external: external, children: children do
29
39
  yield if block
30
40
  end
31
41
  end
@@ -1,18 +1,51 @@
1
1
  <%
2
2
 
3
- link_to_options = {
4
- class: ['nav-link position-relative', (active ? 'active' : 'link-dark')].join(' '),
5
- }
6
- link_to_options[:target] = '_blank' if external
3
+ # Controlla se ci sono children da visualizzare
4
+ has_children = children&.any?
5
+
6
+ # Se non ci sono children, comportamento normale
7
+ unless has_children
8
+ link_to_options = {
9
+ class: ['nav-link position-relative', (active ? 'active' : 'link-dark')].join(' '),
10
+ }
11
+ link_to_options[:target] = '_blank' if external
12
+ end
7
13
 
8
14
  %>
9
15
 
10
- <li class="nav-item border-bottom py-2">
11
- <%= link_to path, link_to_options do %>
12
- <%= yield %>
16
+ <% if has_children %>
17
+ <!-- Menu con dropdown per children -->
18
+ <li class="nav-item border-bottom py-2">
19
+ <div class="nav-link position-relative dropdown">
20
+ <a href="#" class="link-dark text-decoration-none dropdown-toggle d-flex align-items-center"
21
+ data-bs-toggle="collapse"
22
+ data-bs-target="#sidebar-nav-item-dropdown-<%= key || 'item' %>"
23
+ aria-expanded="<%= active ? 'true' : 'false' %>">
24
+ <%= yield %>
25
+ </a>
26
+
27
+ <div class="collapse <%= 'show' if active %>" id="sidebar-nav-item-dropdown-<%= key || 'item' %>">
28
+ <ul class="list-unstyled mt-2 border-start border-1 ps-2">
29
+ <% children.each do |child| %>
30
+ <li class="py-1">
31
+ <%= link_to child[:path], class: ['nav-link py-1', (active == child[:key] ? 'active' : 'link-dark')].join(' ') do %>
32
+ <%= child[:label] %>
33
+ <% end %>
34
+ </li>
35
+ <% end %>
36
+ </ul>
37
+ </div>
38
+ </div>
39
+ </li>
40
+ <% else %>
41
+ <!-- Menu normale senza children -->
42
+ <li class="nav-item border-bottom py-2">
43
+ <%= link_to path, link_to_options do %>
44
+ <%= yield %>
13
45
 
14
- <% if external %>
15
- <i class="bi bi-arrow-up-right position-absolute end-0 top-50 translate-middle-y me-2" style="font-size: 0.75rem"></i>
46
+ <% if external %>
47
+ <i class="bi bi-arrow-up-right position-absolute end-0 top-50 translate-middle-y me-2" style="font-size: 0.75rem"></i>
48
+ <% end %>
16
49
  <% end %>
17
- <% end %>
18
- </li>
50
+ </li>
51
+ <% end %>
data/lib/lato/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lato
2
- VERSION = "3.14.5"
2
+ VERSION = "3.14.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lato
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.14.5
4
+ version: 3.14.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregorio Galante