keystone_ui 0.38.0 → 0.40.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 +13 -11
- data/app/components/keystone/ui/navigation_component.rb +16 -18
- 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 +511 -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 +5 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 50be7dcd619f5461a74ec4c8b7d2d6e09deb955af9b17817b1ef690f842f5a07
|
|
4
|
+
data.tar.gz: 1148f6cf6bba00291658cec6c0672eeae3500093ebbffec67bbbc412fabe72eb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 884b4a4d0b72cf66bc76d5e94af4322a65f1b82aa81a5fba5b6b3f3fbad865524d6dd7fb75dce0a33d1fec8e88e41691a4a57b045e5d920751b3c6fe1453e545
|
|
7
|
+
data.tar.gz: ca9f20d6ef81510e165a8c6a938e6a2cc0cb37dfc1c426b97f17e1695686521727d5e0336809084761d8c0e59f90aef425fe912878d79661e44fa89e4d12137b
|
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
<% sidebar = capture do %>
|
|
5
5
|
<nav class="<%= SIDEBAR_CLASSES %>">
|
|
6
6
|
<% if logo? %>
|
|
7
|
-
<div><%= logo %></div>
|
|
7
|
+
<div class="<%= SIDEBAR_LOGO_CLASSES %>"><%= logo %></div>
|
|
8
8
|
<% end %>
|
|
9
|
-
<% groups.each do |group
|
|
10
|
-
<
|
|
11
|
-
<
|
|
12
|
-
<% tabs.each do |tab| %>
|
|
13
|
-
<a class="<%= sidebar_tab_classes(tab) %>" href="<%= tab.
|
|
9
|
+
<% groups.each do |group| %>
|
|
10
|
+
<details class="<%= SIDEBAR_GROUP_CLASSES %>"<%= " open" if group.active %>>
|
|
11
|
+
<summary class="<%= sidebar_group_label_classes(group) %>"><%= group.label %></summary>
|
|
12
|
+
<% group.tabs.each do |tab| %>
|
|
13
|
+
<a class="<%= sidebar_tab_classes(tab) %>" href="<%= tab.href %>"><%= tab.label %></a>
|
|
14
14
|
<% end %>
|
|
15
|
-
</
|
|
15
|
+
</details>
|
|
16
16
|
<% end %>
|
|
17
17
|
<% if menus? %>
|
|
18
18
|
<div class="<%= SIDEBAR_MENUS_CLASSES %>"><%= menus %></div>
|
|
@@ -25,16 +25,17 @@
|
|
|
25
25
|
<%= sidebar unless sidebar_first? %>
|
|
26
26
|
</div>
|
|
27
27
|
<% else %>
|
|
28
|
+
<div>
|
|
28
29
|
<div class="<%= TOP_BAR_CLASSES %>">
|
|
29
30
|
<%= render Keystone::Ui::NavbarComponent.new(sticky: false) do |navbar| %>
|
|
30
31
|
<% if logo? %>
|
|
31
32
|
<% navbar.with_logo do %><%= logo %><% end %>
|
|
32
33
|
<% end %>
|
|
33
34
|
<% 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.
|
|
35
|
+
<% groups.each do |group| %>
|
|
36
|
+
<%= render Keystone::Ui::NavDropdownComponent.new(title: group.label, area: group.label, active: group.active) do %>
|
|
37
|
+
<% group.tabs.each do |tab| %>
|
|
38
|
+
<%= render Keystone::Ui::NavItemComponent.new(label: tab.label, href: tab.href, active: tab.active) %>
|
|
38
39
|
<% end %>
|
|
39
40
|
<% end %>
|
|
40
41
|
<% end %>
|
|
@@ -45,4 +46,5 @@
|
|
|
45
46
|
<% end %>
|
|
46
47
|
</div>
|
|
47
48
|
<%= content %>
|
|
49
|
+
</div>
|
|
48
50
|
<% 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
|
|
@@ -8,11 +8,16 @@ module Keystone
|
|
|
8
8
|
TOP_BAR_CLASSES = "hidden lg:block sticky top-0 z-40"
|
|
9
9
|
SIDEBAR_ROW_CLASSES = "lg:flex"
|
|
10
10
|
SIDEBAR_CLASSES = "ks-sidebar hidden lg:flex lg:sticky lg:top-0 lg:h-screen shrink-0 overflow-y-auto"
|
|
11
|
+
SIDEBAR_LOGO_CLASSES = "ks-sidebar-logo"
|
|
11
12
|
SIDEBAR_GROUP_CLASSES = "flex flex-col"
|
|
12
13
|
SIDEBAR_GROUP_LABEL_CLASSES = "ks-sidebar-group-label"
|
|
13
14
|
SIDEBAR_TAB_CLASSES = "ks-sidebar-tab"
|
|
14
15
|
ACTIVE_CLASS = "active"
|
|
15
|
-
SIDEBAR_MENUS_CLASSES =
|
|
16
|
+
SIDEBAR_MENUS_CLASSES = [
|
|
17
|
+
"mt-auto [&_[data-dropdown-target=menu]]:static [&_[data-controller~=dropdown]]:flex-wrap [&_[data-dropdown-target=menu]]:basis-full",
|
|
18
|
+
"[&_[data-dropdown-target=menu].hidden]:block [&_[data-dropdown-target=menu].hidden]:h-0 [&_[data-dropdown-target=menu].hidden]:overflow-hidden",
|
|
19
|
+
"[&_[data-dropdown-target=menu].hidden]:my-0 [&_[data-dropdown-target=menu].hidden]:py-0 [&_[data-dropdown-target=menu].hidden]:invisible"
|
|
20
|
+
].join(" ")
|
|
16
21
|
SIDEBAR_CONTENT_CLASSES = "min-w-0 flex-1"
|
|
17
22
|
SIDEBAR_PLACEMENTS = %w[left right].freeze
|
|
18
23
|
|
|
@@ -22,27 +27,20 @@ module Keystone
|
|
|
22
27
|
attr_reader :groups
|
|
23
28
|
|
|
24
29
|
def before_render
|
|
25
|
-
|
|
26
|
-
.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
@groups = KeystoneUi::VisibleNavigation.new(
|
|
31
|
+
KeystoneUi.configuration.navigation_groups,
|
|
32
|
+
view: helpers,
|
|
33
|
+
saved_order: saved_navigation["order"] || [],
|
|
34
|
+
current_tab: KeystoneUi.configuration.supplied_current_tab(helpers)
|
|
35
|
+
).groups
|
|
30
36
|
end
|
|
31
37
|
|
|
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(" ")
|
|
38
|
+
def sidebar_group_label_classes(group)
|
|
39
|
+
[ SIDEBAR_GROUP_LABEL_CLASSES, (ACTIVE_CLASS if group.active) ].compact.join(" ")
|
|
42
40
|
end
|
|
43
41
|
|
|
44
42
|
def sidebar_tab_classes(tab)
|
|
45
|
-
[ SIDEBAR_TAB_CLASSES, (ACTIVE_CLASS if
|
|
43
|
+
[ SIDEBAR_TAB_CLASSES, (ACTIVE_CLASS if tab.active) ].compact.join(" ")
|
|
46
44
|
end
|
|
47
45
|
|
|
48
46
|
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
|