avo 4.0.20 → 4.0.21

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.
@@ -61,7 +61,7 @@
61
61
  app/views/avo/partials/_sidebar_width_override.html.erb (server-validated
62
62
  from the avo.sidebar.width cookie). With no cookie it is undefined and the
63
63
  fallback chain takes over: --sidebar-width-default, written by the same
64
- carrier when the host sets Avo.configuration.sidebar_default_width, then
64
+ carrier when the host sets Avo.configuration.sidebar[:default_width], then
65
65
  --spacing(64) for the untouched 256px. That chain is deliberately INSIDE
66
66
  this media block — below lg the sidebar is a full-height overlay, so a wide
67
67
  configured default would cover a phone screen and the base declaration's
@@ -292,7 +292,7 @@ module Avo
292
292
  def sidebar_width_max = SIDEBAR_WIDTH_MAX
293
293
 
294
294
  # Already clamped into the bounds by Avo::Configuration.
295
- def sidebar_width_default = Avo.configuration.sidebar_default_width
295
+ def sidebar_width_default = Avo.configuration.sidebar[:default_width]
296
296
 
297
297
  # nil when the host has not changed the starting width, so the pre-paint
298
298
  # carrier emits nothing at all and the stylesheet's own --spacing(64)
@@ -226,7 +226,7 @@ export default class extends Controller {
226
226
  }
227
227
 
228
228
  // The width the sidebar starts at with no stored preference — Avo's 256px
229
- // unless the host set Avo.configuration.sidebar_default_width. This is what
229
+ // unless the host set Avo.configuration.sidebar[:default_width]. This is what
230
230
  // remove-when-default compares against, so reading it from config rather than
231
231
  // hardcoding 256 is what keeps a configured host from accumulating a cookie
232
232
  // that merely restates their own default.
@@ -6,8 +6,8 @@
6
6
  <%= content_tag :nav, class: class_names("top-navbar", {"print:hidden": Avo.configuration.hide_layout_when_printing}) do %>
7
7
  <div class="top-navbar__start">
8
8
  <%# Mobile always needs a toggle to reach the overlay sidebar. Desktop toggle
9
- is optional and controlled by sidebar_toggle_visible. %>
10
- <%= a_button class: class_names("shrink-0 -ms-1.5 lg:ms-0", "lg:hidden": !Avo.configuration.sidebar_toggle_visible),
9
+ is optional and controlled by sidebar[:toggle_visible]. %>
10
+ <%= a_button class: class_names("shrink-0 -ms-1.5 lg:ms-0", "lg:hidden": !Avo.configuration.sidebar[:toggle_visible]),
11
11
  size: :sm,
12
12
  style: :text,
13
13
  padding: :sm,
@@ -1,6 +1,6 @@
1
1
  <%# Resize handle for the desktop sidebar (R1–R3, R8, R18, R20–R22).
2
2
 
3
- Rendered only when Avo.configuration.sidebar_resizable is on (the S5
3
+ Rendered only when Avo.configuration.sidebar[:resizable] is on (the S5
4
4
  accessibility off-switch), and always with `hidden` present (R20). The
5
5
  sidebar_resize controller is the SINGLE owner of that attribute: it removes
6
6
  `hidden` on connect when the sidebar is open at >= lg, and re-adds it
@@ -18,7 +18,7 @@
18
18
  (Unit 8 makes valuenow track the drag). They are required, not optional:
19
19
  axe-core 4.12 lists aria-valuenow as a mandatory attribute of role="separator".
20
20
  With no stored width the value is the starting width — Avo's 256px unless the
21
- host set Avo.configuration.sidebar_default_width. %>
21
+ host set Avo.configuration.sidebar[:default_width]. %>
22
22
  <% current_width = @sidebar_width || sidebar_width_default %>
23
23
  <%= tag.div "",
24
24
  class: class_names("sidebar-resize-handle", "print:hidden": Avo.configuration.hide_layout_when_printing),
@@ -3,7 +3,7 @@
3
3
  <script nonce="<%= content_security_policy_nonce %>">
4
4
  // Apply the sidebar width before first paint to avoid a 256px flash (R15).
5
5
  // Both values below are produced server-side as Integers within bounds
6
- // (Avo::ApplicationHelper#sidebar_width, Avo::Configuration#sidebar_default_width),
6
+ // (Avo::ApplicationHelper#sidebar_width, Avo::Configuration#sidebar),
7
7
  // so they are interpolated as bare JS number literals — never a string taken
8
8
  // from the cookie or from the host's initializer.
9
9
  //
@@ -67,7 +67,7 @@
67
67
  <%# Immediately after the sidebar wrapper: after every nav link and both %>
68
68
  <%# skip links in the tab order, before the content. Must stay inside %>
69
69
  <%# .main to inherit --sidebar-offset-size, which positions it. %>
70
- <%= render partial: "avo/partials/sidebar_resize_handle" if Avo.configuration.sidebar_resizable %>
70
+ <%= render partial: "avo/partials/sidebar_resize_handle" if Avo.configuration.sidebar[:resizable] %>
71
71
 
72
72
  <div class="flex lg:hidden">
73
73
  <%= render Avo::SidebarComponent.new sidebar_open: @sidebar_open, for_mobile: true %>
@@ -65,17 +65,7 @@ module Avo
65
65
  attr_accessor :use_stacked_fields
66
66
  attr_accessor :default_editor_url
67
67
  attr_writer :body_classes
68
- attr_accessor :sidebar_toggle_visible
69
- # Off-switch for the drag-to-resize sidebar handle. Drag-only resizing is a
70
- # known WCAG SC 2.5.7 (Dragging Movements) gap, so a host with an AA/VPAT
71
- # obligation can disable it entirely; when false the handle is neither
72
- # rendered nor wired up.
73
- attr_accessor :sidebar_resizable
74
- # Width the desktop sidebar starts at, in pixels, before the user drags it.
75
- # Only applies at >= lg: below that the sidebar is a full-height overlay, and
76
- # a wide configured value would cover a phone screen, so the mobile default
77
- # stays 256px regardless.
78
- attr_writer :sidebar_default_width
68
+ attr_writer :sidebar
79
69
  attr_accessor :tailwindcss_integration_enabled
80
70
  attr_accessor :mount_lookbook
81
71
 
@@ -215,9 +205,7 @@ module Avo
215
205
  @send_metadata = true
216
206
  @use_stacked_fields = false
217
207
  @default_editor_url = "cursor://file/%{path}"
218
- @sidebar_toggle_visible = true
219
- @sidebar_resizable = true
220
- @sidebar_default_width = SIDEBAR_WIDTH_DEFAULT
208
+ @sidebar = {}
221
209
  @body_classes = []
222
210
  @tailwindcss_integration_enabled = true
223
211
  @mount_lookbook = false
@@ -247,6 +235,29 @@ module Avo
247
235
  }.freeze
248
236
  end
249
237
 
238
+ # Sidebar.
239
+ #
240
+ # `toggle_visible` shows the navbar button that collapses the desktop
241
+ # sidebar. On mobile the toggle is always visible regardless.
242
+ #
243
+ # `resizable` is the off-switch for the drag-to-resize handle. Drag-only
244
+ # resizing is a known WCAG SC 2.5.7 (Dragging Movements) gap, so a host with
245
+ # an AA/VPAT obligation can disable it entirely; when false the handle is
246
+ # neither rendered nor wired up.
247
+ #
248
+ # `default_width` is where the desktop sidebar starts, in pixels, before the
249
+ # user drags it. Only applies at >= lg: below that the sidebar is a
250
+ # full-height overlay, and a wide configured value would cover a phone
251
+ # screen, so the mobile default stays 256px regardless. It is absent here and
252
+ # filled in by the #sidebar reader: SIDEBAR_WIDTH_DEFAULT (lib/avo.rb) isn't
253
+ # defined yet when this constant is evaluated at require time.
254
+ unless defined?(SIDEBAR_DEFAULTS)
255
+ SIDEBAR_DEFAULTS = {
256
+ toggle_visible: true,
257
+ resizable: true
258
+ }.freeze
259
+ end
260
+
250
261
  # Global defaults for associations.
251
262
  #
252
263
  # `lookup_list_limit` caps how many records are listed in a belongs_to/attach
@@ -447,16 +458,28 @@ module Avo
447
458
  Avo::ExecutionContext.new(target: @body_classes).handle
448
459
  end
449
460
 
450
- # Clamped into the same [SIDEBAR_WIDTH_MIN, SIDEBAR_WIDTH_MAX] range the drag
451
- # and the persisted cookie use — outside it the sidebar would start at a
452
- # width the handle cannot drag back to, and aria-valuenow would sit outside
453
- # its own declared min/max. Anything unparseable falls back to the built-in
454
- # default rather than clamping to the minimum, so a typo does not silently
455
- # ship a 200px sidebar. The bounds constants stay private (lib/avo.rb):
456
- # this accessor is the only host-facing width knob.
457
- def sidebar_default_width
458
- Integer(@sidebar_default_width, exception: false)
459
- &.clamp(SIDEBAR_WIDTH_MIN, SIDEBAR_WIDTH_MAX) || SIDEBAR_WIDTH_DEFAULT
461
+ # `default_width` is clamped into the same [SIDEBAR_WIDTH_MIN,
462
+ # SIDEBAR_WIDTH_MAX] range the drag and the persisted cookie use — outside it
463
+ # the sidebar would start at a width the handle cannot drag back to, and
464
+ # aria-valuenow would sit outside its own declared min/max. Anything
465
+ # unparseable falls back to the built-in default rather than clamping to the
466
+ # minimum, so a typo does not silently ship a 200px sidebar. The bounds
467
+ # constants stay private (lib/avo.rb): this hash is the only host-facing knob.
468
+ def sidebar
469
+ config = SIDEBAR_DEFAULTS.merge(@sidebar)
470
+ width = Integer(config[:default_width], exception: false)&.clamp(SIDEBAR_WIDTH_MIN, SIDEBAR_WIDTH_MAX)
471
+
472
+ config.merge(default_width: width || SIDEBAR_WIDTH_DEFAULT)
473
+ end
474
+
475
+ # Backward-compatible flat accessor — the canonical home is now
476
+ # `config.sidebar[:toggle_visible]`.
477
+ def sidebar_toggle_visible
478
+ sidebar[:toggle_visible]
479
+ end
480
+
481
+ def sidebar_toggle_visible=(value)
482
+ @sidebar[:toggle_visible] = value
460
483
  end
461
484
 
462
485
  def persistence
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "4.0.20" unless const_defined?(:VERSION)
2
+ VERSION = "4.0.21" unless const_defined?(:VERSION)
3
3
  end
data/lib/avo.rb CHANGED
@@ -37,7 +37,7 @@ module Avo
37
37
  # css/layout.css keeps a commented duplicate of the bounds.
38
38
  #
39
39
  # All three are private_constant. The BOUNDS have no host-facing knob by
40
- # design. The DEFAULT does — `Avo.configuration.sidebar_default_width` — and
40
+ # design. The DEFAULT does — `Avo.configuration.sidebar[:default_width]` — and
41
41
  # this constant is only its fallback, so it must not become public API by
42
42
  # accident either. Reachable inside Avo via unqualified lexical lookup (e.g.
43
43
  # from Avo::Configuration and Avo::ApplicationHelper, both nested in Avo);
@@ -104,14 +104,21 @@ Avo.configure do |config|
104
104
  # }
105
105
 
106
106
  ## == Sidebar ==
107
- # Width the sidebar starts at on desktop, in pixels, before a user drags it.
108
- # Clamped to 200..480. Only applies at >= lg below that the sidebar is a
109
- # full-height overlay and stays 256px so it cannot cover a phone screen.
110
- # config.sidebar_default_width = 256
107
+ # config.sidebar = {
108
+ # # Show the navbar button that collapses the sidebar on desktop. On mobile
109
+ # # the toggle is always visible regardless of this setting.
110
+ # toggle_visible: true,
111
111
  #
112
- # Set to false to remove the drag-to-resize handle entirely. Drag-only resizing
113
- # is a known WCAG SC 2.5.7 gap, so hosts with an AA/VPAT obligation can opt out.
114
- # config.sidebar_resizable = true
112
+ # # Set to false to remove the drag-to-resize handle entirely. Drag-only
113
+ # # resizing is a known WCAG SC 2.5.7 gap, so hosts with an AA/VPAT
114
+ # # obligation can opt out.
115
+ # resizable: true,
116
+ #
117
+ # # Width the sidebar starts at on desktop, in pixels, before a user drags it.
118
+ # # Clamped to 200..480. Only applies at >= lg — below that the sidebar is a
119
+ # # full-height overlay and stays 256px so it cannot cover a phone screen.
120
+ # default_width: 256
121
+ # }
115
122
 
116
123
  ## == Back to top button ==
117
124
  # config.back_to_top = {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avo
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.20
4
+ version: 4.0.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin