keystone_ui 0.22.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 59407e58c161eccb32c1dd76581bb7c0e8ea6f5005fe5f9bde9b061860ffe2ef
4
- data.tar.gz: 4cf237c4e194ecb2c509765191546f633ceb3f0be82563c1eeedcb9f8fb24b06
3
+ metadata.gz: a2d9cae890778efeef3333b64e2e04fa14955d60171b99d1f0fced2d64d0d8aa
4
+ data.tar.gz: 45bb649fa4211a143e3e5c987332de6b2849423f52bcb04765120f49aff9ba87
5
5
  SHA512:
6
- metadata.gz: 97139bc519bef9a218073c10d290ef335df3471fa294b392298bd4c613490baf173ab02fbd2e4395c2c2c7aba563127d19754049d6f808db8f42b8d0aebfd61b
7
- data.tar.gz: 6371eaa8e6bd1a00b028f2820026e0a12c21f3e959a436de04e17ef0b288fb73513948a88c944c2be18a514a7ef54eaa624a87eee4a5dfdc7030b5202c9cd338
6
+ metadata.gz: 193b52fdb0006bb35f2d58e50934755a3917b4f34348051a3d64a7b5b1eda768005c9dd74c7638ba585cd2fcc46f923730816f08a04f078d46e0132405cd310d
7
+ data.tar.gz: d2aa6186b582a92554c1c58139351e2ebb67c8682908bbbb849d72d2fa117cb6e92f0124cb024e0d1a9ea1cc85d138eb1f4f9da08f1cb5bcbf81cd72ae32c6c0
@@ -17,6 +17,8 @@ module Keystone
17
17
  def before_render
18
18
  @trail ||= KeystoneUi.configuration.supplied_trail(helpers)
19
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? }
20
22
  end
21
23
 
22
24
  def subtitle?
@@ -17,6 +17,8 @@ module Keystone
17
17
  def before_render
18
18
  @trail ||= KeystoneUi.configuration.supplied_trail(helpers)
19
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? }
20
22
  end
21
23
 
22
24
  def subtitle?
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KeystoneUi
4
- VERSION = "0.22.0"
4
+ VERSION = "0.23.0"
5
5
  end
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"
@@ -75,8 +75,11 @@ outer element. See Conventions before using it.
75
75
  supplies for the current request, if the app supplies one. With no
76
76
  `back_url:`, the back URL is the `href` of the trail's last link. A `trail:`
77
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.
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.
80
83
  - `ui_show_page(title:, back_url: nil, subtitle: nil, trail: nil)` — the shell
81
84
  marker for a detail screen. It renders nothing where it is called. It
82
85
  publishes the title, subtitle, and back URL for the navbar, and hands
@@ -84,8 +87,9 @@ outer element. See Conventions before using it.
84
87
  `ui_page`, outside `ui_page`'s block. It shows no title, so put
85
88
  `ui_page_header` inside the `ui_page` block for the desktop title. `trail:`
86
89
  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.
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.
89
93
  - `ui_breadcrumbs(trail:, current: nil)` — a line of links shown only from `lg:`
90
94
  up. `trail:` is `[[label, href], ...]`, from the top level down, and each pair
91
95
  renders as a link, separated by `›`. `current:` is the page being shown,
@@ -338,7 +342,9 @@ outer element. See Conventions before using it.
338
342
  does, a screen whose supplied trail is right passes neither `trail:` nor
339
343
  `back_url:`, and passes its own only where the supplied one is wrong. If the
340
344
  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
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
342
348
  back link comes from `ui_mobile_header`, which the navbar renders from the
343
349
  title and back URL these shells publish. Check the app's layout: if it does not
344
350
  already render `ui_mobile_header` from that published context, ask the
@@ -31,9 +31,15 @@ earlier pages instead, the shell shows breadcrumbs in place of that link, ending
31
31
  with the page's own title. A page that passes no trail gets the one the app or
32
32
  another gem supplies for the request, if any, and a page that passes no back
33
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
35
- title, appear at the top of the page container, inside its width and padding, so
36
- a page using either shell also uses the page container.
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.
37
43
 
38
44
  ## Interface
39
45
 
@@ -25,7 +25,7 @@ built on ViewComponent; hook it in before building any screen with those helpers
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
27
  `trail_supplier` (a callable that supplies the breadcrumb trail for form and
28
- show pages that pass none),
28
+ show pages that pass none, and their Back link when they pass none either),
29
29
  and the `tailwind_imports` and `tailwind_sources` lists (extra CSS files and
30
30
  scan paths added to the Tailwind build).
31
31
  - `keystone_theme_attributes` — a layout helper placed inside the `<html>` tag.
@@ -214,8 +214,20 @@ built on ViewComponent; hook it in before building any screen with those helpers
214
214
  screens, ending with the page's title, in place of the desktop "Back" link.
215
215
  A page that passes no Back link goes back to the trail's last link. A page
216
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.
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.
219
231
  - `tailwind_imports` and `tailwind_sources` — lists to append to, never
220
232
  assign. Each import becomes an `@import` line and each source becomes an
221
233
  `@source` line in `keystone_source.css` on the next boot. They are for
@@ -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.22.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