keystone_ui 0.62.0 → 0.63.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 +4 -4
- data/app/components/keystone/ui/nav_item_component.html.erb +1 -1
- data/app/components/keystone/ui/nav_item_component.rb +10 -1
- data/app/components/keystone/ui/navigation_component.html.erb +4 -4
- data/lib/keystone_ui/configuration.rb +2 -2
- data/lib/keystone_ui/navigation_group.rb +7 -3
- data/lib/keystone_ui/version.rb +1 -1
- data/lib/keystone_ui/visible_navigation.rb +2 -2
- data/the_local/agents/keystone_ui-develop.md +2 -1
- data/the_local/agents/keystone_ui-install.md +4 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '0359f881db7160fc60d97b6496ecd4131d5450e7c66bfe1e0e94f9df35587a1d'
|
|
4
|
+
data.tar.gz: 7eab7185a552a901d6f6858ee45d8b01f4ef06241b32f96f749953b8377a5aa1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1e99aa1db1e7b14f3f1037223faec2577ced190386f0262336c279865026cc8d5598d6f58e36e00cf6d18ec80146efce621824d1e52c3bb8cc1be8f8abcc4e32
|
|
7
|
+
data.tar.gz: 4cc34ebcc7c2a81b5433029becd7e6568c4480cede78661843a78f62da45f861d50bb6f5f3379e402f530a2bbe4adfd34ad7f6304c2e8514c346a2a44adbf5cd
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<%= link_to @
|
|
1
|
+
<%= link_to @href, class: link_classes do %><%= @label %><% if counted? %><%= render count_badge %><% end %><% end %>
|
|
@@ -5,10 +5,11 @@ module Keystone
|
|
|
5
5
|
class NavItemComponent < ViewComponent::Base
|
|
6
6
|
attr_reader :label, :href
|
|
7
7
|
|
|
8
|
-
def initialize(label:, href:, active: false)
|
|
8
|
+
def initialize(label:, href:, active: false, count: nil)
|
|
9
9
|
@label = label
|
|
10
10
|
@href = href
|
|
11
11
|
@active = active
|
|
12
|
+
@count = count
|
|
12
13
|
end
|
|
13
14
|
|
|
14
15
|
ACTIVE_CLASS = "active"
|
|
@@ -16,6 +17,14 @@ module Keystone
|
|
|
16
17
|
def link_classes
|
|
17
18
|
[ "ks-nav-item", (ACTIVE_CLASS if @active) ].compact.join(" ")
|
|
18
19
|
end
|
|
20
|
+
|
|
21
|
+
def counted?
|
|
22
|
+
@count.to_i.positive?
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def count_badge
|
|
26
|
+
BadgeComponent.new(label: @count.to_s, variant: :info)
|
|
27
|
+
end
|
|
19
28
|
end
|
|
20
29
|
end
|
|
21
30
|
end
|
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
<% groups.each do |group| %>
|
|
10
10
|
<% if group.standalone %>
|
|
11
11
|
<% tab = group.tabs.first %>
|
|
12
|
-
<a class="<%= sidebar_tab_classes(tab) %>" href="<%= tab.href %>"><%= tab.label %></a>
|
|
12
|
+
<a class="<%= sidebar_tab_classes(tab) %>" href="<%= tab.href %>"><%= tab.label %><% if tab.count.to_i.positive? %> <%= render Keystone::Ui::BadgeComponent.new(label: tab.count.to_s, variant: :info) %><% end %></a>
|
|
13
13
|
<% else %>
|
|
14
14
|
<details class="<%= SIDEBAR_GROUP_CLASSES %>"<%= " open" if group.active %>>
|
|
15
15
|
<summary class="<%= sidebar_group_label_classes(group) %>"><%= group.label %></summary>
|
|
16
16
|
<div class="<%= SIDEBAR_GROUP_TABS_CLASSES %>">
|
|
17
17
|
<% group.tabs.each do |tab| %>
|
|
18
|
-
<a class="<%= sidebar_tab_classes(tab) %>" href="<%= tab.href %>"><%= tab.label %></a>
|
|
18
|
+
<a class="<%= sidebar_tab_classes(tab) %>" href="<%= tab.href %>"><%= tab.label %><% if tab.count.to_i.positive? %> <%= render Keystone::Ui::BadgeComponent.new(label: tab.count.to_s, variant: :info) %><% end %></a>
|
|
19
19
|
<% end %>
|
|
20
20
|
</div>
|
|
21
21
|
</details>
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
<% groups.each do |group| %>
|
|
43
43
|
<% if group.standalone %>
|
|
44
44
|
<% tab = group.tabs.first %>
|
|
45
|
-
<%= render Keystone::Ui::NavItemComponent.new(label: tab.label, href: tab.href, active: tab.active) %>
|
|
45
|
+
<%= render Keystone::Ui::NavItemComponent.new(label: tab.label, href: tab.href, active: tab.active, count: tab.count) %>
|
|
46
46
|
<% else %>
|
|
47
47
|
<%= render Keystone::Ui::NavDropdownComponent.new(title: group.label, area: group.label, active: group.active) do %>
|
|
48
48
|
<% group.tabs.each do |tab| %>
|
|
49
|
-
<%= render Keystone::Ui::NavItemComponent.new(label: tab.label, href: tab.href, active: tab.active) %>
|
|
49
|
+
<%= render Keystone::Ui::NavItemComponent.new(label: tab.label, href: tab.href, active: tab.active, count: tab.count) %>
|
|
50
50
|
<% end %>
|
|
51
51
|
<% end %>
|
|
52
52
|
<% end %>
|
|
@@ -31,9 +31,9 @@ module KeystoneUi
|
|
|
31
31
|
@navigation_groups << group
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
def navigation_tab(key, label:, href:, permitted:)
|
|
34
|
+
def navigation_tab(key, label:, href:, permitted:, count: nil)
|
|
35
35
|
group = NavigationGroup.new(label, standalone: true)
|
|
36
|
-
group.tab(key, label: label, href: href, permitted: permitted)
|
|
36
|
+
group.tab(key, label: label, href: href, permitted: permitted, count: count)
|
|
37
37
|
@navigation_groups << group
|
|
38
38
|
end
|
|
39
39
|
|
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
module KeystoneUi
|
|
4
4
|
class NavigationGroup
|
|
5
|
-
Tab = Struct.new(:key, :label, :href, :permitted, keyword_init: true) do
|
|
5
|
+
Tab = Struct.new(:key, :label, :href, :permitted, :count, keyword_init: true) do
|
|
6
6
|
def href_for(view)
|
|
7
7
|
href.respond_to?(:call) ? href.call(view) : href
|
|
8
8
|
end
|
|
9
|
+
|
|
10
|
+
def count_for(view)
|
|
11
|
+
count&.call(view)
|
|
12
|
+
end
|
|
9
13
|
end
|
|
10
14
|
|
|
11
15
|
attr_reader :label, :tabs
|
|
@@ -24,8 +28,8 @@ module KeystoneUi
|
|
|
24
28
|
tabs.select { |tab| tab.permitted.call(view) }
|
|
25
29
|
end
|
|
26
30
|
|
|
27
|
-
def tab(key, label:, href:, permitted:)
|
|
28
|
-
@tabs << Tab.new(key: key, label: label, href: href, permitted: permitted)
|
|
31
|
+
def tab(key, label:, href:, permitted:, count: nil)
|
|
32
|
+
@tabs << Tab.new(key: key, label: label, href: href, permitted: permitted, count: count)
|
|
29
33
|
end
|
|
30
34
|
end
|
|
31
35
|
end
|
data/lib/keystone_ui/version.rb
CHANGED
|
@@ -5,7 +5,7 @@ require "keystone_ui/navigation_order"
|
|
|
5
5
|
module KeystoneUi
|
|
6
6
|
class VisibleNavigation
|
|
7
7
|
Group = Struct.new(:label, :tabs, :active, :standalone, keyword_init: true)
|
|
8
|
-
Tab = Struct.new(:label, :href, :active, keyword_init: true)
|
|
8
|
+
Tab = Struct.new(:label, :href, :active, :count, keyword_init: true)
|
|
9
9
|
|
|
10
10
|
def initialize(declared_groups, view:, saved_order:, current_tab:)
|
|
11
11
|
@declared_groups = declared_groups
|
|
@@ -32,7 +32,7 @@ module KeystoneUi
|
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
def visible_tab(tab)
|
|
35
|
-
Tab.new(label: tab.label, href: tab.href_for(@view), active: tab.key == @current_tab)
|
|
35
|
+
Tab.new(label: tab.label, href: tab.href_for(@view), active: tab.key == @current_tab, count: tab.count_for(@view))
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
end
|
|
@@ -251,7 +251,8 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
|
|
|
251
251
|
and keeps it from `lg:` up, for a page that shows its own title in
|
|
252
252
|
`ui_mobile_header`. It defaults to `false`, which keeps the logo at every
|
|
253
253
|
width.
|
|
254
|
-
- `ui_nav_item(label:, href:, active: false)` is one desktop
|
|
254
|
+
- `ui_nav_item(label:, href:, active: false, count: nil)` is one desktop
|
|
255
|
+
link, with `count:` shown in a badge after the label when above zero.
|
|
255
256
|
`ui_nav_dropdown(title:, area:, active: false)` takes a block holding the
|
|
256
257
|
menu links.
|
|
257
258
|
- `ui_bottom_nav` takes no keywords and a block of
|
|
@@ -327,6 +327,10 @@ built on ViewComponent; hook it in before building any screen with those helpers
|
|
|
327
327
|
`href:`, when two tabs share a key, or when a group has no tabs. Drawing
|
|
328
328
|
the declared groups in the layout is done with the navigation helper,
|
|
329
329
|
which belongs to `keystone_ui-develop`.
|
|
330
|
+
- Both `group.tab` and `navigation_tab` take an optional `count:`, a
|
|
331
|
+
callable given the view that returns a number. A count above zero shows in
|
|
332
|
+
an info badge after the tab's label in the top bar and the sidebar. It runs
|
|
333
|
+
on every page, so keep it to one cheap query.
|
|
330
334
|
- `navigation_tab key, label:, href:, permitted:` — declares one tab
|
|
331
335
|
outside any group, such as a Console or Clients tab, in its place among
|
|
332
336
|
the groups. The navigation helper draws it as a plain link in the top bar
|