keystone_ui 0.21.1 → 0.23.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 +8 -1
- data/app/components/keystone/ui/show_page_component.rb +8 -1
- data/lib/keystone_ui/configuration.rb +5 -1
- data/lib/keystone_ui/incomplete_trail.rb +9 -0
- data/lib/keystone_ui/missing_back_link.rb +9 -0
- data/lib/keystone_ui/version.rb +1 -1
- data/lib/keystone_ui.rb +2 -0
- data/the_local/agents/keystone_ui-develop.md +29 -11
- data/the_local/agents/keystone_ui-info.md +12 -3
- data/the_local/agents/keystone_ui-install.md +24 -1
- data/the_local/interface.yml +2 -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: a2d9cae890778efeef3333b64e2e04fa14955d60171b99d1f0fced2d64d0d8aa
|
|
4
|
+
data.tar.gz: 45bb649fa4211a143e3e5c987332de6b2849423f52bcb04765120f49aff9ba87
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 193b52fdb0006bb35f2d58e50934755a3917b4f34348051a3d64a7b5b1eda768005c9dd74c7638ba585cd2fcc46f923730816f08a04f078d46e0132405cd310d
|
|
7
|
+
data.tar.gz: d2aa6186b582a92554c1c58139351e2ebb67c8682908bbbb849d72d2fa117cb6e92f0124cb024e0d1a9ea1cc85d138eb1f4f9da08f1cb5bcbf81cd72ae32c6c0
|
|
@@ -7,13 +7,20 @@ 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
|
+
raise KeystoneUi::MissingBackLink, @title unless @back_url
|
|
21
|
+
raise KeystoneUi::IncompleteTrail, @title if @trail&.any? { |label, href| label.blank? || href.blank? }
|
|
22
|
+
end
|
|
23
|
+
|
|
17
24
|
def subtitle?
|
|
18
25
|
!@subtitle.nil?
|
|
19
26
|
end
|
|
@@ -7,13 +7,20 @@ 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
|
+
raise KeystoneUi::MissingBackLink, @title unless @back_url
|
|
21
|
+
raise KeystoneUi::IncompleteTrail, @title if @trail&.any? { |label, href| label.blank? || href.blank? }
|
|
22
|
+
end
|
|
23
|
+
|
|
17
24
|
def subtitle?
|
|
18
25
|
!@subtitle.nil?
|
|
19
26
|
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
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module KeystoneUi
|
|
4
|
+
class IncompleteTrail < StandardError
|
|
5
|
+
def initialize(title)
|
|
6
|
+
super(%(The page "#{title}" has a breadcrumb trail with a link that has no label or no address. Give every link in the trail both.))
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module KeystoneUi
|
|
4
|
+
class MissingBackLink < StandardError
|
|
5
|
+
def initialize(title)
|
|
6
|
+
super(%(The page "#{title}" has no Back link. Pass back_url: or trail:, or supply a trail for it through config.trail_supplier.))
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
end
|
data/lib/keystone_ui/version.rb
CHANGED
data/lib/keystone_ui.rb
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
require "view_component"
|
|
4
4
|
require "keystone_ui/styles"
|
|
5
5
|
require "keystone_ui/configuration"
|
|
6
|
+
require "keystone_ui/missing_back_link"
|
|
7
|
+
require "keystone_ui/incomplete_trail"
|
|
6
8
|
require "keystone_ui/theme_choice"
|
|
7
9
|
require "keystone_ui/look_choice"
|
|
8
10
|
require "keystone_ui/engine"
|
|
@@ -64,22 +64,32 @@ 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
|
-
link
|
|
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, or a trail that is empty or whose
|
|
79
|
+
last link has no `href`, rendering raises `KeystoneUi::MissingBackLink`, naming
|
|
80
|
+
the page's title. A trail with any link whose label or `href` is `nil` or
|
|
81
|
+
blank raises `KeystoneUi::IncompleteTrail`, naming the page's title, even when
|
|
82
|
+
`back_url:` is passed.
|
|
83
|
+
- `ui_show_page(title:, back_url: nil, subtitle: nil, trail: nil)` — the shell
|
|
84
|
+
marker for a detail screen. It renders nothing where it is called. It
|
|
85
|
+
publishes the title, subtitle, and back URL for the navbar, and hands
|
|
86
|
+
`ui_page` a "Back" link to `back_url` shown from `lg:` up. Call it before
|
|
87
|
+
`ui_page`, outside `ui_page`'s block. It shows no title, so put
|
|
88
|
+
`ui_page_header` inside the `ui_page` block for the desktop title. `trail:`
|
|
89
|
+
and `back_url:` work as they do on `ui_form_page`, including the supplied
|
|
90
|
+
trail, the fallback to the trail's last link, and the
|
|
91
|
+
`KeystoneUi::MissingBackLink` and `KeystoneUi::IncompleteTrail` errors, and
|
|
92
|
+
the breadcrumbs end with `title` unlinked.
|
|
83
93
|
- `ui_breadcrumbs(trail:, current: nil)` — a line of links shown only from `lg:`
|
|
84
94
|
up. `trail:` is `[[label, href], ...]`, from the top level down, and each pair
|
|
85
95
|
renders as a link, separated by `›`. `current:` is the page being shown,
|
|
@@ -326,7 +336,15 @@ outer element. See Conventions before using it.
|
|
|
326
336
|
Those shells supply the desktop "Back" link themselves, so never add a
|
|
327
337
|
second back link or button to those screens. Whether a screen
|
|
328
338
|
shows that "Back" link or breadcrumbs, and which parent screens the trail
|
|
329
|
-
names, is the developer's choice, so ask before passing `trail:`.
|
|
339
|
+
names, is the developer's choice, so ask before passing `trail:`. Check
|
|
340
|
+
first whether the app's Keystone UI initializer sets a `trail_supplier`,
|
|
341
|
+
which supplies a trail for every request: if it
|
|
342
|
+
does, a screen whose supplied trail is right passes neither `trail:` nor
|
|
343
|
+
`back_url:`, and passes its own only where the supplied one is wrong. If the
|
|
344
|
+
app supplies no trail, every form and detail screen passes `back_url:` or
|
|
345
|
+
`trail:`, since a screen with neither raises `KeystoneUi::MissingBackLink`
|
|
346
|
+
when it renders. Every link in a trail needs both a label and an `href`, or
|
|
347
|
+
the screen raises `KeystoneUi::IncompleteTrail`. Setting up a supplied trail is `keystone_ui-install`'s job. Below `lg:` the
|
|
330
348
|
back link comes from `ui_mobile_header`, which the navbar renders from the
|
|
331
349
|
title and back URL these shells publish. Check the app's layout: if it does not
|
|
332
350
|
already render `ui_mobile_header` from that published context, ask the
|
|
@@ -28,9 +28,18 @@ 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.
|
|
32
|
-
|
|
33
|
-
|
|
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.
|
|
35
|
+
|
|
36
|
+
Every form and show page must end up with a Back link. A page with no back
|
|
37
|
+
link, no trail and no supplied trail raises `KeystoneUi::MissingBackLink` when it
|
|
38
|
+
renders, and the message names the page's title. A trail with a link missing
|
|
39
|
+
its label or its address raises `KeystoneUi::IncompleteTrail`, also naming the
|
|
40
|
+
page. That link or those breadcrumbs, and the form page's title, appear at the
|
|
41
|
+
top of the page container, inside its width and padding, so a page using either
|
|
42
|
+
shell also uses the page container.
|
|
34
43
|
|
|
35
44
|
## Interface
|
|
36
45
|
|
|
@@ -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, and their Back link when they pass none either),
|
|
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,26 @@ 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. Return `nil`, not an empty
|
|
218
|
+
array, for a page with no trail, because an empty array replaces the
|
|
219
|
+
page's Back link with breadcrumbs holding only its title.
|
|
220
|
+
- Every form and show page must end up with a Back link. A page that passes
|
|
221
|
+
no Back link and no trail, and gets no trail from the supplier, raises
|
|
222
|
+
`KeystoneUi::MissingBackLink` naming the page's title when it renders.
|
|
223
|
+
So does a page whose trail's last link has no address.
|
|
224
|
+
- Every link the supplier returns needs both a label and an address. A trail
|
|
225
|
+
with a blank label or address raises `KeystoneUi::IncompleteTrail` naming
|
|
226
|
+
the page's title.
|
|
227
|
+
- Ask the developer which code in the app knows each page's trail before
|
|
228
|
+
writing the callable. If some form or show pages pass no `back_url:`, ask
|
|
229
|
+
where their Back link should come from before enabling the supplier or
|
|
230
|
+
leaving it out.
|
|
208
231
|
- `tailwind_imports` and `tailwind_sources` — lists to append to, never
|
|
209
232
|
assign. Each import becomes an `@import` line and each source becomes an
|
|
210
233
|
`@source` line in `keystone_source.css` on the next boot. They are for
|
data/the_local/interface.yml
CHANGED
|
@@ -65,6 +65,8 @@ develop:
|
|
|
65
65
|
sources:
|
|
66
66
|
- lib/generators/keystone/install_generator.rb
|
|
67
67
|
- lib/keystone_ui/configuration.rb
|
|
68
|
+
- lib/keystone_ui/missing_back_link.rb
|
|
69
|
+
- lib/keystone_ui/incomplete_trail.rb
|
|
68
70
|
- lib/keystone_ui/theme_choice.rb
|
|
69
71
|
- lib/keystone_ui/look_choice.rb
|
|
70
72
|
- app/helpers/keystone_ui_helper.rb
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: keystone_ui
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.23.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tyler Schneider
|
|
@@ -189,9 +189,11 @@ files:
|
|
|
189
189
|
- lib/keystone_ui.rb
|
|
190
190
|
- lib/keystone_ui/configuration.rb
|
|
191
191
|
- lib/keystone_ui/engine.rb
|
|
192
|
+
- lib/keystone_ui/incomplete_trail.rb
|
|
192
193
|
- lib/keystone_ui/leftover_stylesheet.rb
|
|
193
194
|
- lib/keystone_ui/look_check.rb
|
|
194
195
|
- lib/keystone_ui/look_choice.rb
|
|
196
|
+
- lib/keystone_ui/missing_back_link.rb
|
|
195
197
|
- lib/keystone_ui/safelist.rb
|
|
196
198
|
- lib/keystone_ui/source_css.rb
|
|
197
199
|
- lib/keystone_ui/theme_choice.rb
|