keystone_ui 0.38.0 → 0.39.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/navigation_component.html.erb +8 -8
- data/app/components/keystone/ui/navigation_component.rb +10 -17
- data/lib/keystone_ui/engine.rb +6 -0
- data/lib/keystone_ui/navigation_check.rb +37 -0
- data/lib/keystone_ui/version.rb +1 -1
- data/lib/keystone_ui/visible_navigation.rb +38 -0
- data/the_local/agents/keystone_ui-develop.md +504 -628
- data/the_local/agents/keystone_ui-info.md +83 -227
- data/the_local/agents/keystone_ui-install.md +20 -16
- data/the_local/interface.yml +1 -0
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b11fa4104f5668547e8efeff23c90f69f4c3d1b7374103c33d7dc2c208363acb
|
|
4
|
+
data.tar.gz: 719716203afcd39869e402674d72a6bf8f1e5f4e7fce163a76c3429ae2bc77e2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b4849b26d1df9c8a45c7721fa966569e6d0f556780b5139a479a73e08c0602ce1db0eab5d4f8bfedcf5a30301cc4d1bba3cffdb0bf82e91a65a3d87c9fdb575c
|
|
7
|
+
data.tar.gz: 8fdb709bfbf187d4792a76c5057ebec69651fb5d4ba2e5b7a6b527b5e0ae68f437689896a492ec390f46ddc7d330fd3e00e2946588f41932d85bf82e790104e3
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
<% if logo? %>
|
|
7
7
|
<div><%= logo %></div>
|
|
8
8
|
<% end %>
|
|
9
|
-
<% groups.each do |group
|
|
9
|
+
<% groups.each do |group| %>
|
|
10
10
|
<div class="<%= SIDEBAR_GROUP_CLASSES %>">
|
|
11
|
-
<p class="<%= sidebar_group_label_classes(
|
|
12
|
-
<% tabs.each do |tab| %>
|
|
13
|
-
<a class="<%= sidebar_tab_classes(tab) %>" href="<%= tab.
|
|
11
|
+
<p class="<%= sidebar_group_label_classes(group) %>"><%= group.label %></p>
|
|
12
|
+
<% group.tabs.each do |tab| %>
|
|
13
|
+
<a class="<%= sidebar_tab_classes(tab) %>" href="<%= tab.href %>"><%= tab.label %></a>
|
|
14
14
|
<% end %>
|
|
15
15
|
</div>
|
|
16
16
|
<% end %>
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
<% navbar.with_logo do %><%= logo %><% end %>
|
|
32
32
|
<% end %>
|
|
33
33
|
<% navbar.with_desktop_links do %>
|
|
34
|
-
<% groups.each do |group
|
|
35
|
-
<%= render Keystone::Ui::NavDropdownComponent.new(title: group.label, area: group.label, active:
|
|
36
|
-
<% tabs.each do |tab| %>
|
|
37
|
-
<%= render Keystone::Ui::NavItemComponent.new(label: tab.label, href: tab.
|
|
34
|
+
<% groups.each do |group| %>
|
|
35
|
+
<%= render Keystone::Ui::NavDropdownComponent.new(title: group.label, area: group.label, active: group.active) do %>
|
|
36
|
+
<% group.tabs.each do |tab| %>
|
|
37
|
+
<%= render Keystone::Ui::NavItemComponent.new(label: tab.label, href: tab.href, active: tab.active) %>
|
|
38
38
|
<% end %>
|
|
39
39
|
<% end %>
|
|
40
40
|
<% end %>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "keystone_ui/
|
|
3
|
+
require "keystone_ui/visible_navigation"
|
|
4
4
|
|
|
5
5
|
module Keystone
|
|
6
6
|
module Ui
|
|
@@ -22,27 +22,20 @@ module Keystone
|
|
|
22
22
|
attr_reader :groups
|
|
23
23
|
|
|
24
24
|
def before_render
|
|
25
|
-
|
|
26
|
-
.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
@groups = KeystoneUi::VisibleNavigation.new(
|
|
26
|
+
KeystoneUi.configuration.navigation_groups,
|
|
27
|
+
view: helpers,
|
|
28
|
+
saved_order: saved_navigation["order"] || [],
|
|
29
|
+
current_tab: KeystoneUi.configuration.supplied_current_tab(helpers)
|
|
30
|
+
).groups
|
|
30
31
|
end
|
|
31
32
|
|
|
32
|
-
def
|
|
33
|
-
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def holds_current?(tabs)
|
|
37
|
-
tabs.any? { |tab| current?(tab) }
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def sidebar_group_label_classes(tabs)
|
|
41
|
-
[ SIDEBAR_GROUP_LABEL_CLASSES, (ACTIVE_CLASS if holds_current?(tabs)) ].compact.join(" ")
|
|
33
|
+
def sidebar_group_label_classes(group)
|
|
34
|
+
[ SIDEBAR_GROUP_LABEL_CLASSES, (ACTIVE_CLASS if group.active) ].compact.join(" ")
|
|
42
35
|
end
|
|
43
36
|
|
|
44
37
|
def sidebar_tab_classes(tab)
|
|
45
|
-
[ SIDEBAR_TAB_CLASSES, (ACTIVE_CLASS if
|
|
38
|
+
[ SIDEBAR_TAB_CLASSES, (ACTIVE_CLASS if tab.active) ].compact.join(" ")
|
|
46
39
|
end
|
|
47
40
|
|
|
48
41
|
def anything_to_show?
|
data/lib/keystone_ui/engine.rb
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require "keystone_ui/source_css"
|
|
4
4
|
require "keystone_ui/leftover_stylesheet"
|
|
5
5
|
require "keystone_ui/look_check"
|
|
6
|
+
require "keystone_ui/navigation_check"
|
|
6
7
|
|
|
7
8
|
module KeystoneUi
|
|
8
9
|
class Engine < ::Rails::Engine
|
|
@@ -32,8 +33,13 @@ module KeystoneUi
|
|
|
32
33
|
KeystoneUi::LookCheck.new(looks: config.looks, default: config.default_look).call
|
|
33
34
|
end
|
|
34
35
|
|
|
36
|
+
def self.check_navigation
|
|
37
|
+
KeystoneUi::NavigationCheck.new(groups: KeystoneUi.configuration.navigation_groups).call
|
|
38
|
+
end
|
|
39
|
+
|
|
35
40
|
config.after_initialize do
|
|
36
41
|
KeystoneUi::Engine.check_looks
|
|
42
|
+
KeystoneUi::Engine.check_navigation
|
|
37
43
|
|
|
38
44
|
tailwind_dir = Rails.root.join("app/assets/tailwind")
|
|
39
45
|
css_path = tailwind_dir.join("application.css")
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module KeystoneUi
|
|
4
|
+
class NavigationCheck
|
|
5
|
+
class Error < StandardError; end
|
|
6
|
+
|
|
7
|
+
def initialize(groups:)
|
|
8
|
+
@groups = groups
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def call
|
|
12
|
+
@groups.each do |group|
|
|
13
|
+
raise Error, "The #{group.label} navigation group has no tabs." if group.tabs.empty?
|
|
14
|
+
end
|
|
15
|
+
tabs.each do |tab|
|
|
16
|
+
raise Error, "The #{tab.key} tab has no label." if blank?(tab.label)
|
|
17
|
+
raise Error, "The #{tab.key} tab has no link." if blank?(tab.href)
|
|
18
|
+
end
|
|
19
|
+
raise Error, "More than one navigation tab has the key #{shared_key}." if shared_key
|
|
20
|
+
nil
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def tabs
|
|
26
|
+
@groups.flat_map(&:tabs)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def shared_key
|
|
30
|
+
tabs.map(&:key).tally.find { |_key, count| count > 1 }&.first
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def blank?(value)
|
|
34
|
+
value.nil? || value.to_s.strip.empty?
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
data/lib/keystone_ui/version.rb
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "keystone_ui/navigation_order"
|
|
4
|
+
|
|
5
|
+
module KeystoneUi
|
|
6
|
+
class VisibleNavigation
|
|
7
|
+
Group = Struct.new(:label, :tabs, :active, keyword_init: true)
|
|
8
|
+
Tab = Struct.new(:label, :href, :active, keyword_init: true)
|
|
9
|
+
|
|
10
|
+
def initialize(declared_groups, view:, saved_order:, current_tab:)
|
|
11
|
+
@declared_groups = declared_groups
|
|
12
|
+
@view = view
|
|
13
|
+
@saved_order = saved_order
|
|
14
|
+
@current_tab = current_tab
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def groups
|
|
18
|
+
NavigationOrder.new(@saved_order).arrange(permitted).map { |group, tabs| visible_group(group, tabs) }
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
def permitted
|
|
24
|
+
@declared_groups
|
|
25
|
+
.map { |group| [ group, group.tabs_permitted_for(@view) ] }
|
|
26
|
+
.reject { |_group, tabs| tabs.empty? }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def visible_group(group, tabs)
|
|
30
|
+
visible_tabs = tabs.map { |tab| visible_tab(tab) }
|
|
31
|
+
Group.new(label: group.label, tabs: visible_tabs, active: visible_tabs.any?(&:active))
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def visible_tab(tab)
|
|
35
|
+
Tab.new(label: tab.label, href: tab.href_for(@view), active: tab.key == @current_tab)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|