keystone_ui 0.21.1 → 0.22.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/form_page_component.rb +6 -1
- data/app/components/keystone/ui/show_page_component.rb +6 -1
- data/lib/keystone_ui/configuration.rb +5 -1
- data/lib/keystone_ui/version.rb +1 -1
- data/the_local/agents/keystone_ui-develop.md +23 -11
- data/the_local/agents/keystone_ui-info.md +4 -1
- data/the_local/agents/keystone_ui-install.md +12 -1
- 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: 59407e58c161eccb32c1dd76581bb7c0e8ea6f5005fe5f9bde9b061860ffe2ef
|
|
4
|
+
data.tar.gz: 4cf237c4e194ecb2c509765191546f633ceb3f0be82563c1eeedcb9f8fb24b06
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 97139bc519bef9a218073c10d290ef335df3471fa294b392298bd4c613490baf173ab02fbd2e4395c2c2c7aba563127d19754049d6f808db8f42b8d0aebfd61b
|
|
7
|
+
data.tar.gz: 6371eaa8e6bd1a00b028f2820026e0a12c21f3e959a436de04e17ef0b288fb73513948a88c944c2be18a514a7ef54eaa624a87eee4a5dfdc7030b5202c9cd338
|
|
@@ -7,13 +7,18 @@ module Keystone
|
|
|
7
7
|
TITLE_CLASSES = "ks-page-title text-2xl"
|
|
8
8
|
SUBTITLE_CLASSES = "ks-page-header-subtitle text-sm"
|
|
9
9
|
|
|
10
|
-
def initialize(title:, back_url
|
|
10
|
+
def initialize(title:, back_url: nil, subtitle: nil, trail: nil)
|
|
11
11
|
@title = title
|
|
12
12
|
@back_url = back_url
|
|
13
13
|
@subtitle = subtitle
|
|
14
14
|
@trail = trail
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
+
def before_render
|
|
18
|
+
@trail ||= KeystoneUi.configuration.supplied_trail(helpers)
|
|
19
|
+
@back_url ||= @trail&.last&.last
|
|
20
|
+
end
|
|
21
|
+
|
|
17
22
|
def subtitle?
|
|
18
23
|
!@subtitle.nil?
|
|
19
24
|
end
|
|
@@ -7,13 +7,18 @@ module Keystone
|
|
|
7
7
|
TITLE_CLASSES = "ks-page-title text-2xl"
|
|
8
8
|
SUBTITLE_CLASSES = "ks-page-header-subtitle text-sm"
|
|
9
9
|
|
|
10
|
-
def initialize(title:, back_url
|
|
10
|
+
def initialize(title:, back_url: nil, subtitle: nil, trail: nil)
|
|
11
11
|
@title = title
|
|
12
12
|
@back_url = back_url
|
|
13
13
|
@subtitle = subtitle
|
|
14
14
|
@trail = trail
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
+
def before_render
|
|
18
|
+
@trail ||= KeystoneUi.configuration.supplied_trail(helpers)
|
|
19
|
+
@back_url ||= @trail&.last&.last
|
|
20
|
+
end
|
|
21
|
+
|
|
17
22
|
def subtitle?
|
|
18
23
|
!@subtitle.nil?
|
|
19
24
|
end
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module KeystoneUi
|
|
4
4
|
class Configuration
|
|
5
|
-
attr_accessor :accent, :surface, :theme_mode_supplier, :look_supplier
|
|
5
|
+
attr_accessor :accent, :surface, :theme_mode_supplier, :look_supplier, :trail_supplier
|
|
6
6
|
attr_reader :tailwind_imports, :tailwind_sources, :looks, :default_look
|
|
7
7
|
|
|
8
8
|
def initialize
|
|
@@ -29,6 +29,10 @@ module KeystoneUi
|
|
|
29
29
|
def supplied_theme_mode(view)
|
|
30
30
|
theme_mode_supplier&.call(view)
|
|
31
31
|
end
|
|
32
|
+
|
|
33
|
+
def supplied_trail(view)
|
|
34
|
+
trail_supplier&.call(view)
|
|
35
|
+
end
|
|
32
36
|
end
|
|
33
37
|
|
|
34
38
|
def self.configuration
|
data/lib/keystone_ui/version.rb
CHANGED
|
@@ -64,22 +64,28 @@ outer element. See Conventions before using it.
|
|
|
64
64
|
`sm:`). Call `header.action { ... }` in the block to place a custom control on
|
|
65
65
|
the right; only what `action` receives is rendered. Passing `action_url:`
|
|
66
66
|
publishes that URL and label for a mobile navbar to pick up.
|
|
67
|
-
- `ui_form_page(title:, back_url
|
|
67
|
+
- `ui_form_page(title:, back_url: nil, subtitle: nil, trail: nil)` — the shell
|
|
68
68
|
marker for a form screen. It renders nothing where it is called. It publishes
|
|
69
69
|
the title and back URL so the navbar can render mobile header context, and
|
|
70
70
|
hands `ui_page` a "Back" link to `back_url` shown from `lg:` up, then the
|
|
71
71
|
title and subtitle shown from `md:` up. Call it before `ui_page`, outside
|
|
72
72
|
`ui_page`'s block, or none of that appears. Passing `trail:` replaces the
|
|
73
73
|
"Back" link with breadcrumbs: the trail's links followed by `title` unlinked,
|
|
74
|
-
as `ui_breadcrumbs` renders them. `
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
74
|
+
as `ui_breadcrumbs` renders them. With no `trail:`, it uses the trail the app
|
|
75
|
+
supplies for the current request, if the app supplies one. With no
|
|
76
|
+
`back_url:`, the back URL is the `href` of the trail's last link. A `trail:`
|
|
77
|
+
or `back_url:` passed here always wins over the supplied ones. With no
|
|
78
|
+
`back_url:` and no trail from either place, the "Back" link and the mobile
|
|
79
|
+
header point at the current page, so pass one.
|
|
80
|
+
- `ui_show_page(title:, back_url: nil, subtitle: nil, trail: nil)` — the shell
|
|
81
|
+
marker for a detail screen. It renders nothing where it is called. It
|
|
82
|
+
publishes the title, subtitle, and back URL for the navbar, and hands
|
|
83
|
+
`ui_page` a "Back" link to `back_url` shown from `lg:` up. Call it before
|
|
84
|
+
`ui_page`, outside `ui_page`'s block. It shows no title, so put
|
|
85
|
+
`ui_page_header` inside the `ui_page` block for the desktop title. `trail:`
|
|
86
|
+
and `back_url:` work as they do on `ui_form_page`, including the supplied
|
|
87
|
+
trail and the fallback to the trail's last link, and the breadcrumbs end with
|
|
88
|
+
`title` unlinked.
|
|
83
89
|
- `ui_breadcrumbs(trail:, current: nil)` — a line of links shown only from `lg:`
|
|
84
90
|
up. `trail:` is `[[label, href], ...]`, from the top level down, and each pair
|
|
85
91
|
renders as a link, separated by `›`. `current:` is the page being shown,
|
|
@@ -326,7 +332,13 @@ outer element. See Conventions before using it.
|
|
|
326
332
|
Those shells supply the desktop "Back" link themselves, so never add a
|
|
327
333
|
second back link or button to those screens. Whether a screen
|
|
328
334
|
shows that "Back" link or breadcrumbs, and which parent screens the trail
|
|
329
|
-
names, is the developer's choice, so ask before passing `trail:`.
|
|
335
|
+
names, is the developer's choice, so ask before passing `trail:`. Check
|
|
336
|
+
first whether the app's Keystone UI initializer sets a `trail_supplier`,
|
|
337
|
+
which supplies a trail for every request: if it
|
|
338
|
+
does, a screen whose supplied trail is right passes neither `trail:` nor
|
|
339
|
+
`back_url:`, and passes its own only where the supplied one is wrong. If the
|
|
340
|
+
app supplies no trail, every form and detail screen passes `back_url:` or
|
|
341
|
+
`trail:`. Setting up a supplied trail is `keystone_ui-install`'s job. Below `lg:` the
|
|
330
342
|
back link comes from `ui_mobile_header`, which the navbar renders from the
|
|
331
343
|
title and back URL these shells publish. Check the app's layout: if it does not
|
|
332
344
|
already render `ui_mobile_header` from that published context, ask the
|
|
@@ -28,7 +28,10 @@ these apps are often viewed in a native webview. The form and show page shells
|
|
|
28
28
|
follow the same split for going back: the mobile header carries the back link on
|
|
29
29
|
small screens, and from `lg:` up the shell shows a "Back" link. Given a trail of
|
|
30
30
|
earlier pages instead, the shell shows breadcrumbs in place of that link, ending
|
|
31
|
-
with the page's own title.
|
|
31
|
+
with the page's own title. A page that passes no trail gets the one the app or
|
|
32
|
+
another gem supplies for the request, if any, and a page that passes no back
|
|
33
|
+
link goes back to that trail's last link. A trail or back link the page passes
|
|
34
|
+
itself always wins. Supplying a trail is set up through the install local. That link or those breadcrumbs, and the form page's
|
|
32
35
|
title, appear at the top of the page container, inside its width and padding, so
|
|
33
36
|
a page using either shell also uses the page container.
|
|
34
37
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: keystone_ui-install
|
|
3
|
-
description: Use to hook Keystone UI into a project — adding the gem, running the install generator to wire Tailwind, the Stimulus controllers and the layout's theme attributes, and configuring the palette, the theme mode supplier, registered looks and extra Tailwind imports and sources.
|
|
3
|
+
description: Use to hook Keystone UI into a project — adding the gem, running the install generator to wire Tailwind, the Stimulus controllers and the layout's theme attributes, and configuring the palette, the theme mode supplier, registered looks, the breadcrumb trail supplier and extra Tailwind imports and sources.
|
|
4
4
|
tools: Bash, Read, Edit
|
|
5
5
|
scope: UI — pages, forms, tables, navigation, dashboards
|
|
6
6
|
---
|
|
@@ -24,6 +24,8 @@ built on ViewComponent; hook it in before building any screen with those helpers
|
|
|
24
24
|
custom mode),
|
|
25
25
|
`register_look` (a look's CSS file by name), `default_look` and
|
|
26
26
|
`look_supplier` (which registered look a page gets),
|
|
27
|
+
`trail_supplier` (a callable that supplies the breadcrumb trail for form and
|
|
28
|
+
show pages that pass none),
|
|
27
29
|
and the `tailwind_imports` and `tailwind_sources` lists (extra CSS files and
|
|
28
30
|
scan paths added to the Tailwind build).
|
|
29
31
|
- `keystone_theme_attributes` — a layout helper placed inside the `<html>` tag.
|
|
@@ -176,6 +178,7 @@ built on ViewComponent; hook it in before building any screen with those helpers
|
|
|
176
178
|
config.register_look :compact, "/absolute/path/to/compact.css"
|
|
177
179
|
config.default_look = :compact
|
|
178
180
|
config.look_supplier = ->(view) { view.current_user&.look }
|
|
181
|
+
config.trail_supplier = ->(view) { view.breadcrumb_trail }
|
|
179
182
|
config.tailwind_imports << "/absolute/path/to/extra.css"
|
|
180
183
|
config.tailwind_sources << "/absolute/path/to/components/**/*.{erb,rb}"
|
|
181
184
|
end
|
|
@@ -205,6 +208,14 @@ built on ViewComponent; hook it in before building any screen with those helpers
|
|
|
205
208
|
- `look_supplier` — a callable that receives the view and returns a look
|
|
206
209
|
name for the request. A name that is not registered, or `nil`, leaves the
|
|
207
210
|
page on the default look.
|
|
211
|
+
- `trail_supplier` — a callable that receives the view and returns the
|
|
212
|
+
breadcrumb trail as an array of `[label, href]` pairs, or `nil`. A form or
|
|
213
|
+
show page that passes no trail of its own shows the supplied one on `lg:`
|
|
214
|
+
screens, ending with the page's title, in place of the desktop "Back" link.
|
|
215
|
+
A page that passes no Back link goes back to the trail's last link. A page
|
|
216
|
+
that passes its own trail or Back link keeps it. With no supplier, or a
|
|
217
|
+
`nil` return, the page shows its Back link. Ask the developer
|
|
218
|
+
which code in the app knows each page's trail before writing the callable.
|
|
208
219
|
- `tailwind_imports` and `tailwind_sources` — lists to append to, never
|
|
209
220
|
assign. Each import becomes an `@import` line and each source becomes an
|
|
210
221
|
`@source` line in `keystone_source.css` on the next boot. They are for
|