keystone_ui 0.68.0 → 0.70.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/mobile_action_component.rb +13 -1
- data/app/components/keystone/ui/page_header_component.html.erb +25 -8
- data/app/components/keystone/ui/page_header_component.rb +35 -3
- data/lib/keystone_ui/version.rb +1 -1
- data/the_local/agents/keystone_ui-develop.md +19 -6
- 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: d96059f073f00b06481b723fb6e180de135d958e0e3a3fcc3413e2d34597ebe8
|
|
4
|
+
data.tar.gz: d8a8aa05e26e90910ab1764ec0b0b2f5336c4f790984de40230937402ec89dfb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a41678266c550174986fa9c04a01bde5cdfa0d5a4b66f7bd7b862376e1a8c654bd03878be4d10e1bcfc80d3092c7f0df5eb2b307dce0ffa86d131731d374dde7
|
|
7
|
+
data.tar.gz: 7d73b0660e745189ceacd0c1b3c047c246e3325d4de08217a94909c40a833bdfef2d9b5f055037bf35ed745bf728bae244f0aa04ffa5773b2001f01b16a5d27b
|
|
@@ -16,7 +16,19 @@ module Keystone
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def call
|
|
19
|
-
link_to(PLUS_ICON.html_safe,
|
|
19
|
+
return link_to(PLUS_ICON.html_safe, url, **options) unless content_for?(:mobile_action_method)
|
|
20
|
+
|
|
21
|
+
button_to(url, method: content_for(:mobile_action_method), **options) { PLUS_ICON.html_safe }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def url
|
|
27
|
+
content_for(:mobile_action_url)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def options
|
|
31
|
+
{ class: LINK_CLASSES, aria: { label: content_for(:mobile_action_label) } }
|
|
20
32
|
end
|
|
21
33
|
end
|
|
22
34
|
end
|
|
@@ -2,21 +2,38 @@
|
|
|
2
2
|
<% if action_url %>
|
|
3
3
|
<% content_for :mobile_action_url, action_url %>
|
|
4
4
|
<% content_for :mobile_action_label, action_label %>
|
|
5
|
+
<% content_for :mobile_action_method, action_method.to_s if action_method %>
|
|
5
6
|
<% end %>
|
|
6
7
|
<div class="<%= wrapper_classes %>">
|
|
7
8
|
<div>
|
|
8
|
-
|
|
9
|
+
<% if badges? %>
|
|
10
|
+
<div class="<%= TITLE_ROW_CLASSES %>">
|
|
11
|
+
<h1 class="<%= title_classes %>"><%= @title %></h1>
|
|
12
|
+
<% @badges.each do |badge| %>
|
|
13
|
+
<%= render Keystone::Ui::BadgeComponent.new(**badge) %>
|
|
14
|
+
<% end %>
|
|
15
|
+
</div>
|
|
16
|
+
<% else %>
|
|
17
|
+
<h1 class="<%= title_classes %>"><%= @title %></h1>
|
|
18
|
+
<% end %>
|
|
9
19
|
<% if subtitle? %>
|
|
10
20
|
<p class="<%= SUBTITLE_CLASSES %>"><%= subtitle_text %></p>
|
|
11
21
|
<% end %>
|
|
12
22
|
</div>
|
|
13
|
-
<% if
|
|
14
|
-
<div class="<%=
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
23
|
+
<% if actions? %>
|
|
24
|
+
<div class="<%= actions_classes %>">
|
|
25
|
+
<% if action? %>
|
|
26
|
+
<%= @action_block.call %>
|
|
27
|
+
<% elsif action_url %>
|
|
28
|
+
<%= render Keystone::Ui::ButtonComponent.new(label: action_label, href: action_url, method: action_method || :get) %>
|
|
29
|
+
<% end %>
|
|
30
|
+
<% if menu? %>
|
|
31
|
+
<%= render Keystone::Ui::ActionMenuComponent.new do %>
|
|
32
|
+
<% @menu.each do |item| %>
|
|
33
|
+
<%= render Keystone::Ui::ActionMenuItemComponent.new(**item) %>
|
|
34
|
+
<% end %>
|
|
35
|
+
<% end %>
|
|
36
|
+
<% end %>
|
|
20
37
|
</div>
|
|
21
38
|
<% end %>
|
|
22
39
|
</div>
|
|
@@ -7,20 +7,28 @@ module Keystone
|
|
|
7
7
|
TITLE_CLASSES = "ks-page-header-title"
|
|
8
8
|
SUBTITLE_CLASSES = "ks-page-header-subtitle"
|
|
9
9
|
ACTIONS_CLASSES = "page-header-actions ks-page-header-actions"
|
|
10
|
+
PHONE_TITLE_CLASSES = "ks-page-header-title max-sm:[body:has(.ks-mobile-header-title)_&]:hidden"
|
|
11
|
+
PHONE_WRAPPER_CLASSES = "max-sm:flex max-sm:flex-wrap max-sm:items-center max-sm:justify-between"
|
|
12
|
+
PHONE_ACTIONS_CLASSES = "max-sm:block"
|
|
13
|
+
MENU_ROW_CLASSES = "flex items-center ks-grid-gap-sm"
|
|
14
|
+
TITLE_ROW_CLASSES = "flex flex-wrap items-center ks-grid-gap-sm"
|
|
10
15
|
|
|
11
|
-
attr_reader :title, :action_url, :action_label
|
|
16
|
+
attr_reader :title, :action_url, :action_label, :action_method
|
|
12
17
|
|
|
13
|
-
def initialize(title:, subtitle: nil, action_url: nil, action_label: "Add new", class: nil)
|
|
18
|
+
def initialize(title:, subtitle: nil, action_url: nil, action_label: "Add new", action_method: nil, badges: [], menu: [], class: nil)
|
|
14
19
|
@title = title
|
|
15
20
|
@subtitle = subtitle
|
|
16
21
|
@action_url = action_url
|
|
17
22
|
@action_label = action_label
|
|
23
|
+
@action_method = action_method
|
|
24
|
+
@badges = badges
|
|
25
|
+
@menu = menu
|
|
18
26
|
@action_block = nil
|
|
19
27
|
@extra_classes = binding.local_variable_get(:class)
|
|
20
28
|
end
|
|
21
29
|
|
|
22
30
|
def wrapper_classes
|
|
23
|
-
[ WRAPPER_CLASSES, @extra_classes ].compact.join(" ")
|
|
31
|
+
[ WRAPPER_CLASSES, (PHONE_WRAPPER_CLASSES if phone?), @extra_classes ].compact.join(" ")
|
|
24
32
|
end
|
|
25
33
|
|
|
26
34
|
def before_render
|
|
@@ -35,6 +43,30 @@ module Keystone
|
|
|
35
43
|
!!@action_block
|
|
36
44
|
end
|
|
37
45
|
|
|
46
|
+
def actions_classes
|
|
47
|
+
[ ACTIONS_CLASSES, (menu? ? MENU_ROW_CLASSES : PHONE_ACTIONS_CLASSES if phone?) ].compact.join(" ")
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def title_classes
|
|
51
|
+
phone? ? PHONE_TITLE_CLASSES : TITLE_CLASSES
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def phone?
|
|
55
|
+
badges? || menu?
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def actions?
|
|
59
|
+
action? || !action_url.nil? || menu?
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def menu?
|
|
63
|
+
@menu.any?
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def badges?
|
|
67
|
+
@badges.any?
|
|
68
|
+
end
|
|
69
|
+
|
|
38
70
|
def subtitle?
|
|
39
71
|
!@subtitle.nil?
|
|
40
72
|
end
|
data/lib/keystone_ui/version.rb
CHANGED
|
@@ -27,7 +27,7 @@ not available in the app yet, that is `keystone_ui-install`'s job.
|
|
|
27
27
|
- `ui_page` — the outer wrapper of a screen, holding the page's content.
|
|
28
28
|
- `ui_form_page` — marks a screen as a form screen and gives it its title, Back link and breadcrumbs.
|
|
29
29
|
- `ui_show_page` — marks a screen as a detail screen and gives it its Back link and breadcrumbs.
|
|
30
|
-
- `ui_page_header` — the
|
|
30
|
+
- `ui_page_header` — the title of a page, with optional badges beside it and a control and action menu on its right.
|
|
31
31
|
- `ui_breadcrumbs` — a line of links to the pages above the current one, shown from `lg:` up.
|
|
32
32
|
- `ui_section` — a titled block of content with an optional link and action menu in its header.
|
|
33
33
|
- `ui_grid` — a responsive grid with a column count per breakpoint.
|
|
@@ -168,13 +168,26 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
|
|
|
168
168
|
- Ask the developer whether a screen shows breadcrumbs and which parent
|
|
169
169
|
screens its trail names. Ask which screens a navigation tab opens
|
|
170
170
|
directly, since those pass `trail: []`.
|
|
171
|
-
- `ui_page_header(title:, subtitle: nil, action_url: nil, action_label: "Add new", class: nil)`
|
|
172
|
-
takes a block yielding the header
|
|
171
|
+
- `ui_page_header(title:, subtitle: nil, action_url: nil, action_label: "Add new", action_method: nil, badges: [], menu: [], class: nil)`
|
|
172
|
+
takes a block yielding the header. Call
|
|
173
173
|
`header.action { ... }` in the block to place a control on its right.
|
|
174
174
|
`action_url:` declares the screen's main action. It publishes that URL and
|
|
175
175
|
label for `ui_mobile_action` to pick up, and with no `action` block the
|
|
176
176
|
header draws them as a button. An `action` block is drawn alone when both
|
|
177
|
-
are given.
|
|
177
|
+
are given. `action_method:`, such as `:post`, makes the main action send
|
|
178
|
+
that method: the header's button and `ui_mobile_action`'s icon become
|
|
179
|
+
forms posting to `action_url:`.
|
|
180
|
+
- `badges:` is `[{ label:, variant: }, ...]`, each drawn as a `ui_badge`
|
|
181
|
+
beside the title, with `variant:` taking the badge's values. `menu:` is
|
|
182
|
+
`[{ label:, href:, method: }, ...]`, each hash taking the keywords of
|
|
183
|
+
`ui_action_menu_item`, drawn in an action menu beside the actions. Put a
|
|
184
|
+
record's Edit and Delete in `menu:` on its detail screen.
|
|
185
|
+
- Below `sm:` a header given no badges and no menu is hidden, even with an
|
|
186
|
+
action. A header given badges or a menu is shown there with its badges,
|
|
187
|
+
actions and menu, and hides its title when the page holds
|
|
188
|
+
`ui_mobile_header`'s title. Its action then shows below `sm:` beside
|
|
189
|
+
`ui_mobile_action`'s plus icon, so ask the developer whether a screen
|
|
190
|
+
with both keeps both.
|
|
178
191
|
- `ui_breadcrumbs(trail:, current: nil)` renders `trail:` as links separated
|
|
179
192
|
by `›`, then `current:` unlinked and marked as the current page, shown
|
|
180
193
|
only from `lg:` up. On a form or detail screen pass `trail:` to the shell
|
|
@@ -403,7 +416,7 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
|
|
|
403
416
|
become `data-*` attributes on the input and the label.
|
|
404
417
|
|
|
405
418
|
7. Put the actions on a record, such as Edit and Delete, in an action menu
|
|
406
|
-
rather than a row of buttons: `menu:` on the `ui_section` showing the record,
|
|
419
|
+
rather than a row of buttons: `menu:` on the `ui_page_header` or `ui_section` showing the record,
|
|
407
420
|
`table.actions` for a table row, or `ui_action_menu` anywhere else.
|
|
408
421
|
|
|
409
422
|
- `ui_action_menu` takes no keywords and a block of `ui_action_menu_item`
|
|
@@ -707,7 +720,7 @@ two exceptions: `ui_page`'s `padding:` treats any value other than `:none` as
|
|
|
707
720
|
- **Containers take blocks, leaves take keywords.** The data table, page header
|
|
708
721
|
and swipe deck render only what is registered through the object they yield,
|
|
709
722
|
so anything else emitted in their block is dropped.
|
|
710
|
-
- **Check both screen sizes.** Page headers, mobile headers, mobile actions,
|
|
723
|
+
- **Check both screen sizes.** Page headers with no badges or menu, mobile headers, mobile actions,
|
|
711
724
|
bottom navigation, breadcrumbs and `ui_navigation`'s bars render on one side
|
|
712
725
|
of `lg:` or `sm:` only, so a screen needs both treatments.
|
|
713
726
|
- Out of scope: installing or upgrading the gem, its configuration, the theme
|