avo 4.1.14 → 4.1.15
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/Gemfile.lock +1 -1
- data/app/assets/builds/avo/application.css +30 -22
- data/app/assets/stylesheets/css/components/avatar.css +12 -12
- data/app/assets/stylesheets/css/components/field-wrapper.css +2 -1
- data/app/assets/stylesheets/css/components/sidebar_resize.css +1 -1
- data/app/assets/stylesheets/css/components/ui/panel_header.css +2 -2
- data/app/assets/stylesheets/css/layout.css +13 -4
- data/app/components/avo/breadcrumb_element_component.html.erb +2 -2
- data/app/components/avo/fields/avatar_field/index_component.html.erb +3 -3
- data/app/components/avo/u_i/avatar_component.rb +2 -2
- data/app/components/avo/u_i/panel_header_component.html.erb +2 -2
- data/app/components/avo/u_i/panel_header_component.rb +5 -5
- data/app/controllers/avo/base_application_controller.rb +2 -1
- data/app/controllers/avo/charts_controller.rb +1 -1
- data/app/controllers/avo/media_library_controller.rb +1 -1
- data/app/helpers/avo/application_helper.rb +2 -7
- data/lib/avo/configuration.rb +27 -7
- data/lib/avo/skills/avo-admin-config/SKILL.md +2 -2
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/templates/initializer/avo.tt +1 -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: 979ea4a3d9398395f5ddcf3122789f338eb1866c5712f338345d70fb4616fe68
|
|
4
|
+
data.tar.gz: 595a5f9ab9aeeda7c3be1cdd9e9cd944bf04fdd056de079bcb2ca5ca16f97e6a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '0893fb0c3556b1da737b856b2892252402101526b9d762fcc7fd2a1642d8dccb1ca6d2dc28081f399bccfff8484a06f33ecefa308ba13fe60236423480b3fc37'
|
|
7
|
+
data.tar.gz: 90974ed038a73a92fe8d9f9bcb7e16d425a7e90b89f2b152afaf71ddb224d57b9d82486d64e00000b9fd7fc637e67be4472d4875e8c4c767d22665b4f89f9080
|
data/Gemfile.lock
CHANGED
|
@@ -5115,52 +5115,60 @@ tag.tagify__tag {
|
|
|
5115
5115
|
}
|
|
5116
5116
|
}
|
|
5117
5117
|
@media (width >= 96rem) {
|
|
5118
|
-
.container-
|
|
5118
|
+
.container-lg {
|
|
5119
5119
|
width: 100%;
|
|
5120
5120
|
}
|
|
5121
5121
|
@media (width >= 30rem) {
|
|
5122
|
-
.container-
|
|
5122
|
+
.container-lg {
|
|
5123
5123
|
max-width: 30rem;
|
|
5124
5124
|
}
|
|
5125
5125
|
}
|
|
5126
5126
|
@media (width >= 40rem) {
|
|
5127
|
-
.container-
|
|
5127
|
+
.container-lg {
|
|
5128
5128
|
max-width: 40rem;
|
|
5129
5129
|
}
|
|
5130
5130
|
}
|
|
5131
5131
|
@media (width >= 48rem) {
|
|
5132
|
-
.container-
|
|
5132
|
+
.container-lg {
|
|
5133
5133
|
max-width: 48rem;
|
|
5134
5134
|
}
|
|
5135
5135
|
}
|
|
5136
5136
|
@media (width >= 64rem) {
|
|
5137
|
-
.container-
|
|
5137
|
+
.container-lg {
|
|
5138
5138
|
max-width: 64rem;
|
|
5139
5139
|
}
|
|
5140
5140
|
}
|
|
5141
5141
|
@media (width >= 80rem) {
|
|
5142
|
-
.container-
|
|
5142
|
+
.container-lg {
|
|
5143
5143
|
max-width: 80rem;
|
|
5144
5144
|
}
|
|
5145
5145
|
}
|
|
5146
5146
|
@media (width >= 96rem) {
|
|
5147
|
-
.container-
|
|
5147
|
+
.container-lg {
|
|
5148
5148
|
max-width: 96rem;
|
|
5149
5149
|
}
|
|
5150
5150
|
}
|
|
5151
|
-
.container-
|
|
5151
|
+
.container-lg {
|
|
5152
5152
|
margin-inline: auto;
|
|
5153
5153
|
}
|
|
5154
5154
|
}
|
|
5155
5155
|
@media (width >= 80rem) {
|
|
5156
|
-
.container-
|
|
5156
|
+
.container-md {
|
|
5157
5157
|
margin-inline: auto;
|
|
5158
5158
|
width: 100%;
|
|
5159
5159
|
max-width: calc(var(--spacing) * 240);
|
|
5160
5160
|
padding-inline: 0px;
|
|
5161
5161
|
}
|
|
5162
5162
|
}
|
|
5163
|
-
|
|
5163
|
+
@media (width >= 48rem) {
|
|
5164
|
+
.container-sm {
|
|
5165
|
+
margin-inline: auto;
|
|
5166
|
+
width: 100%;
|
|
5167
|
+
max-width: calc(var(--spacing) * 180);
|
|
5168
|
+
padding-inline: 0px;
|
|
5169
|
+
}
|
|
5170
|
+
}
|
|
5171
|
+
.container-full {
|
|
5164
5172
|
width: 100%;
|
|
5165
5173
|
}
|
|
5166
5174
|
.top-navbar {
|
|
@@ -8012,7 +8020,7 @@ tag.tagify__tag {
|
|
|
8012
8020
|
width: 100%;
|
|
8013
8021
|
}
|
|
8014
8022
|
}
|
|
8015
|
-
.container-
|
|
8023
|
+
:is(.container-md, .container-sm) .field-wrapper__content-wrapper {
|
|
8016
8024
|
width: 100%;
|
|
8017
8025
|
}
|
|
8018
8026
|
.field-wrapper.field-wrapper--density-compact {
|
|
@@ -8037,32 +8045,32 @@ tag.tagify__tag {
|
|
|
8037
8045
|
height: 100%;
|
|
8038
8046
|
overflow: hidden;
|
|
8039
8047
|
}
|
|
8040
|
-
.cado-avatar--
|
|
8048
|
+
.cado-avatar--lg {
|
|
8041
8049
|
width: calc(var(--spacing) * 20);
|
|
8042
8050
|
height: calc(var(--spacing) * 20);
|
|
8043
8051
|
}
|
|
8044
|
-
.cado-avatar--
|
|
8052
|
+
.cado-avatar--md {
|
|
8045
8053
|
width: calc(var(--spacing) * 12);
|
|
8046
8054
|
height: calc(var(--spacing) * 12);
|
|
8047
8055
|
}
|
|
8048
|
-
.cado-avatar--
|
|
8056
|
+
.cado-avatar--sm {
|
|
8049
8057
|
width: calc(var(--spacing) * 8);
|
|
8050
8058
|
height: calc(var(--spacing) * 8);
|
|
8051
8059
|
}
|
|
8052
|
-
.cado-avatar--
|
|
8060
|
+
.cado-avatar--xs {
|
|
8053
8061
|
width: calc(var(--spacing) * 5);
|
|
8054
8062
|
height: calc(var(--spacing) * 5);
|
|
8055
8063
|
}
|
|
8056
8064
|
.cado-avatar--rounded {
|
|
8057
8065
|
border-radius: calc(infinity * 1px);
|
|
8058
8066
|
}
|
|
8059
|
-
.cado-avatar--square.cado-avatar--
|
|
8067
|
+
.cado-avatar--square.cado-avatar--lg {
|
|
8060
8068
|
border-radius: var(--radius-2xl);
|
|
8061
8069
|
}
|
|
8062
|
-
.cado-avatar--square.cado-avatar--
|
|
8070
|
+
.cado-avatar--square.cado-avatar--md {
|
|
8063
8071
|
border-radius: var(--radius-xl);
|
|
8064
8072
|
}
|
|
8065
|
-
.cado-avatar--square.cado-avatar--
|
|
8073
|
+
.cado-avatar--square.cado-avatar--sm, .cado-avatar--square.cado-avatar--xs {
|
|
8066
8074
|
border-radius: var(--radius-md);
|
|
8067
8075
|
}
|
|
8068
8076
|
.cado-avatar--placeholder, .cado-avatar--initials {
|
|
@@ -8144,27 +8152,27 @@ tag.tagify__tag {
|
|
|
8144
8152
|
text-overflow: ellipsis;
|
|
8145
8153
|
white-space: nowrap;
|
|
8146
8154
|
}
|
|
8147
|
-
.cado-avatar--
|
|
8155
|
+
.cado-avatar--lg .cado-avatar__initials {
|
|
8148
8156
|
width: calc(var(--spacing) * 8);
|
|
8149
8157
|
font-size: var(--text-2xl);
|
|
8150
8158
|
line-height: var(--tw-leading, var(--text-2xl--line-height));
|
|
8151
8159
|
--tw-leading: calc(var(--spacing) * 8);
|
|
8152
8160
|
line-height: calc(var(--spacing) * 8);
|
|
8153
8161
|
}
|
|
8154
|
-
.cado-avatar--
|
|
8162
|
+
.cado-avatar--md .cado-avatar__initials {
|
|
8155
8163
|
width: calc(var(--spacing) * 6);
|
|
8156
8164
|
font-size: var(--text-lg);
|
|
8157
8165
|
line-height: var(--tw-leading, var(--text-lg--line-height));
|
|
8158
8166
|
--tw-leading: calc(var(--spacing) * 6);
|
|
8159
8167
|
line-height: calc(var(--spacing) * 6);
|
|
8160
8168
|
}
|
|
8161
|
-
.cado-avatar--
|
|
8169
|
+
.cado-avatar--sm .cado-avatar__initials {
|
|
8162
8170
|
font-size: var(--text-sm);
|
|
8163
8171
|
line-height: var(--tw-leading, var(--text-sm--line-height));
|
|
8164
8172
|
--tw-leading: calc(var(--spacing) * 6);
|
|
8165
8173
|
line-height: calc(var(--spacing) * 6);
|
|
8166
8174
|
}
|
|
8167
|
-
.cado-avatar--
|
|
8175
|
+
.cado-avatar--xs .cado-avatar__initials {
|
|
8168
8176
|
font-size: var(--text-tiny);
|
|
8169
8177
|
--tw-leading: calc(var(--spacing) * 4);
|
|
8170
8178
|
line-height: calc(var(--spacing) * 4);
|
|
@@ -4,19 +4,19 @@
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
/* Size variants */
|
|
7
|
-
.cado-avatar--
|
|
7
|
+
.cado-avatar--lg {
|
|
8
8
|
@apply size-20;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
.cado-avatar--
|
|
11
|
+
.cado-avatar--md {
|
|
12
12
|
@apply size-12;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
.cado-avatar--
|
|
15
|
+
.cado-avatar--sm {
|
|
16
16
|
@apply size-8;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
.cado-avatar--
|
|
19
|
+
.cado-avatar--xs {
|
|
20
20
|
@apply size-5;
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -25,16 +25,16 @@
|
|
|
25
25
|
@apply rounded-full;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
.cado-avatar--square.cado-avatar--
|
|
28
|
+
.cado-avatar--square.cado-avatar--lg {
|
|
29
29
|
@apply rounded-2xl;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
.cado-avatar--square.cado-avatar--
|
|
32
|
+
.cado-avatar--square.cado-avatar--md {
|
|
33
33
|
@apply rounded-xl;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
.cado-avatar--square.cado-avatar--
|
|
37
|
-
.cado-avatar--square.cado-avatar--
|
|
36
|
+
.cado-avatar--square.cado-avatar--sm,
|
|
37
|
+
.cado-avatar--square.cado-avatar--xs {
|
|
38
38
|
@apply rounded-md;
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -111,18 +111,18 @@
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
/* Font sizes for different avatar sizes */
|
|
114
|
-
.cado-avatar--
|
|
114
|
+
.cado-avatar--lg .cado-avatar__initials {
|
|
115
115
|
@apply text-2xl leading-8 w-8;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
.cado-avatar--
|
|
118
|
+
.cado-avatar--md .cado-avatar__initials {
|
|
119
119
|
@apply text-lg leading-6 w-6;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
.cado-avatar--
|
|
122
|
+
.cado-avatar--sm .cado-avatar__initials {
|
|
123
123
|
@apply text-sm leading-6;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
.cado-avatar--
|
|
126
|
+
.cado-avatar--xs .cado-avatar__initials {
|
|
127
127
|
@apply text-tiny leading-4;
|
|
128
128
|
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
the sidebar, leaving >= 6px of the 8px `body.os-pc` scroll gutter grabbable.
|
|
9
9
|
The other 13px stop exactly at the earliest interactive box edge in the
|
|
10
10
|
layout: .main-content's start budget is 17px (1px border + 16px padding, since
|
|
11
|
-
.container-
|
|
11
|
+
.container-md zeroes the inner 8px at >= xl), but the first breadcrumb
|
|
12
12
|
pulls its own 4px of padding back out for optical alignment, so anything
|
|
13
13
|
past +13px starts covering it. sidebar_resize_spec.rb holds that line.
|
|
14
14
|
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/* Size variants */
|
|
40
|
-
.header--size-
|
|
40
|
+
.header--size-md {
|
|
41
41
|
/* Default styles already applied */
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
.header--size-
|
|
44
|
+
.header--size-sm {
|
|
45
45
|
/* Small variant uses same structure but can have different spacing if needed */
|
|
46
46
|
}
|
|
@@ -150,21 +150,30 @@
|
|
|
150
150
|
@apply flex flex-1 flex-col px-0 md:px-2;
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
.container-
|
|
153
|
+
.container-lg {
|
|
154
154
|
@apply 2xl:container 2xl:mx-auto;
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
/* max-width (not a fixed width) so the container fills the space left of a
|
|
158
158
|
widened sidebar instead of overflowing it, while still capping at 960px on
|
|
159
|
-
wide viewports. w-full is required: .container-
|
|
159
|
+
wide viewports. w-full is required: .container-md is a flex item of
|
|
160
160
|
.main-content (flex flex-col), and per Flexbox §4.2 the auto inline margins
|
|
161
161
|
from mx-auto suppress the default align-self: stretch — without an explicit
|
|
162
162
|
width the item would collapse to its content width. */
|
|
163
|
-
.container-
|
|
163
|
+
.container-md {
|
|
164
164
|
@apply xl:px-0 xl:w-full xl:max-w-240 xl:mx-auto;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
.container-
|
|
167
|
+
/* Clamps from md, well before .container-md's xl: waiting would make :sm and :md
|
|
168
|
+
pixel-identical on every laptop, which is where a narrow container is most
|
|
169
|
+
worth asking for. The trade is that at exactly 768px the 720px column leaves
|
|
170
|
+
only 24px a side; it opens up quickly above that, and the alternative was a
|
|
171
|
+
value that does nothing until 1280px. */
|
|
172
|
+
.container-sm {
|
|
173
|
+
@apply md:px-0 md:w-full md:max-w-180 md:mx-auto;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.container-full {
|
|
168
177
|
@apply w-full;
|
|
169
178
|
}
|
|
170
179
|
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
) do %>
|
|
6
6
|
<% if @avatar.present? %>
|
|
7
7
|
<div class="breadcrumb-element__avatar">
|
|
8
|
-
<%= render Avo::UI::AvatarComponent.new src: helpers.main_app.url_for(@avatar.value), shape: :square, type: :avatar, size: :
|
|
8
|
+
<%= render Avo::UI::AvatarComponent.new src: helpers.main_app.url_for(@avatar.value), shape: :square, type: :avatar, size: :xs %>
|
|
9
9
|
</div>
|
|
10
10
|
<% elsif @initials.present? %>
|
|
11
|
-
<span class="breadcrumb-element__initials"><%= render Avo::UI::AvatarComponent.new shape: :square, type: :initials, size: :
|
|
11
|
+
<span class="breadcrumb-element__initials"><%= render Avo::UI::AvatarComponent.new shape: :square, type: :initials, size: :xs, initials: @initials %></span>
|
|
12
12
|
<% end %>
|
|
13
13
|
<% if @icon.present? %>
|
|
14
14
|
<%= helpers.svg @icon, class: "breadcrumb-element__icon" %>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<%= index_field_wrapper(**field_wrapper_args, flush: true, dash_if_blank: false, center_content: true) do %>
|
|
2
2
|
<% if @resource.avatar.present? && @resource.avatar.value.present? %>
|
|
3
|
-
<%= render Avo::UI::AvatarComponent.new src: helpers.safe_image_url(@resource.avatar.value), shape: :square, type: :avatar, size: :
|
|
3
|
+
<%= render Avo::UI::AvatarComponent.new src: helpers.safe_image_url(@resource.avatar.value), shape: :square, type: :avatar, size: :sm %>
|
|
4
4
|
<% elsif @resource.initials.present? %>
|
|
5
|
-
<%= render Avo::UI::AvatarComponent.new shape: :square, type: :initials, size: :
|
|
5
|
+
<%= render Avo::UI::AvatarComponent.new shape: :square, type: :initials, size: :sm, initials: @resource.initials %>
|
|
6
6
|
<% else %>
|
|
7
|
-
<%= render Avo::UI::AvatarComponent.new shape: :square, type: :placeholder, size: :
|
|
7
|
+
<%= render Avo::UI::AvatarComponent.new shape: :square, type: :placeholder, size: :sm %>
|
|
8
8
|
<% end %>
|
|
9
9
|
<% end %>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
class Avo::UI::AvatarComponent < Avo::BaseComponent
|
|
2
|
-
SIZES = %w[
|
|
2
|
+
SIZES = %w[lg md sm xs].freeze
|
|
3
3
|
SHAPES = %w[rounded square].freeze
|
|
4
4
|
THEMES = %w[default orange yellow green teal blue purple].freeze
|
|
5
5
|
TYPES = %w[avatar placeholder initials].freeze
|
|
6
6
|
|
|
7
7
|
def initialize(
|
|
8
8
|
type: "placeholder",
|
|
9
|
-
size: "
|
|
9
|
+
size: "lg",
|
|
10
10
|
shape: "rounded",
|
|
11
11
|
theme: "default",
|
|
12
12
|
initials: nil,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<%= tag.div class: class_names(
|
|
2
2
|
@class,
|
|
3
3
|
"header",
|
|
4
|
-
"header--size-
|
|
5
|
-
"header--size-
|
|
4
|
+
"header--size-md": size_md?,
|
|
5
|
+
"header--size-sm": size_sm?
|
|
6
6
|
), data: { "item-index": @index, component: component_name }.compact_blank do %>
|
|
7
7
|
<div class="header__main">
|
|
8
8
|
<div class="header__content">
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
class Avo::UI::PanelHeaderComponent < Avo::BaseComponent
|
|
4
4
|
prop :title
|
|
5
5
|
prop :description
|
|
6
|
-
prop :size, default: :
|
|
6
|
+
prop :size, default: :md
|
|
7
7
|
prop :url
|
|
8
8
|
prop :target
|
|
9
9
|
prop :index
|
|
@@ -14,11 +14,11 @@ class Avo::UI::PanelHeaderComponent < Avo::BaseComponent
|
|
|
14
14
|
renders_one :controls
|
|
15
15
|
renders_one :discreet_information
|
|
16
16
|
|
|
17
|
-
def
|
|
18
|
-
@size == :
|
|
17
|
+
def size_md?
|
|
18
|
+
@size == :md
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
def
|
|
22
|
-
@size == :
|
|
21
|
+
def size_sm?
|
|
22
|
+
@size == :sm
|
|
23
23
|
end
|
|
24
24
|
end
|
|
@@ -250,7 +250,8 @@ module Avo
|
|
|
250
250
|
end
|
|
251
251
|
|
|
252
252
|
def mark_container_width(width)
|
|
253
|
-
|
|
253
|
+
width = Avo::Configuration.normalize_container_width(width.to_sym)
|
|
254
|
+
raise ArgumentError, "Invalid container width: #{width}. Must be one of #{Avo::Configuration::VALID_CONTAINER_WIDTHS}" unless Avo::Configuration::VALID_CONTAINER_WIDTHS.include?(width)
|
|
254
255
|
@container_size = width.to_s
|
|
255
256
|
end
|
|
256
257
|
|
|
@@ -241,10 +241,9 @@ module Avo
|
|
|
241
241
|
end
|
|
242
242
|
|
|
243
243
|
def container_classes
|
|
244
|
-
return "container-#{
|
|
244
|
+
return "container-#{@container_size}" if @container_size.present?
|
|
245
245
|
|
|
246
|
-
|
|
247
|
-
"container-#{container_width_css_suffix(width)}"
|
|
246
|
+
"container-#{Avo.configuration.container_width.fetch(@view&.to_sym, :lg)}"
|
|
248
247
|
end
|
|
249
248
|
|
|
250
249
|
# encode & encrypt params
|
|
@@ -336,10 +335,6 @@ module Avo
|
|
|
336
335
|
"attachment#{extension}"
|
|
337
336
|
end
|
|
338
337
|
|
|
339
|
-
def container_width_css_suffix(width)
|
|
340
|
-
(width == :full) ? "full-width" : width.to_s
|
|
341
|
-
end
|
|
342
|
-
|
|
343
338
|
def avo_field(type = nil, id = nil, as: nil, view: :show, form: nil, component_options: {}, **args, &block)
|
|
344
339
|
if as.present?
|
|
345
340
|
id = type
|
data/lib/avo/configuration.rb
CHANGED
|
@@ -73,15 +73,21 @@ module Avo
|
|
|
73
73
|
|
|
74
74
|
unless defined?(CONTAINER_WIDTH_DEFAULTS)
|
|
75
75
|
CONTAINER_WIDTH_DEFAULTS = {
|
|
76
|
-
index: :
|
|
77
|
-
show: :
|
|
78
|
-
new: :
|
|
79
|
-
edit: :
|
|
80
|
-
create: :
|
|
81
|
-
update: :
|
|
76
|
+
index: :lg,
|
|
77
|
+
show: :md,
|
|
78
|
+
new: :md,
|
|
79
|
+
edit: :md,
|
|
80
|
+
create: :md,
|
|
81
|
+
update: :md
|
|
82
82
|
}.freeze
|
|
83
83
|
|
|
84
|
-
VALID_CONTAINER_WIDTHS = %i[full
|
|
84
|
+
VALID_CONTAINER_WIDTHS = %i[full lg md sm].freeze
|
|
85
|
+
|
|
86
|
+
# Avo 4.1 renamed the widths onto Tailwind's scale so the vocabulary matches
|
|
87
|
+
# every other size option (`size: :sm`, `width: :xl`, ...). Note `:small`
|
|
88
|
+
# maps to `:md`, not `:sm` — the rename kept the old width and freed the
|
|
89
|
+
# narrower names. The old names still work and warn; drop them in Avo 5.
|
|
90
|
+
DEPRECATED_CONTAINER_WIDTHS = {large: :lg, small: :md}.freeze
|
|
85
91
|
|
|
86
92
|
CONTAINER_WIDTH_GROUPS = {
|
|
87
93
|
forms: %i[new edit create update],
|
|
@@ -90,11 +96,23 @@ module Avo
|
|
|
90
96
|
}.freeze
|
|
91
97
|
end
|
|
92
98
|
|
|
99
|
+
# Single funnel for every container width that enters Avo — `config.container_width=`
|
|
100
|
+
# and the controllers' `mark_container_width`. Unknown values pass through untouched
|
|
101
|
+
# so each caller keeps raising its own ArgumentError.
|
|
102
|
+
def self.normalize_container_width(value)
|
|
103
|
+
replacement = DEPRECATED_CONTAINER_WIDTHS[value.respond_to?(:to_sym) ? value.to_sym : value]
|
|
104
|
+
return value if replacement.nil?
|
|
105
|
+
|
|
106
|
+
Avo.logger.warn "[Avo] Container width `:#{value}` is deprecated and will be removed in Avo 5. Use `:#{replacement}` instead."
|
|
107
|
+
replacement
|
|
108
|
+
end
|
|
109
|
+
|
|
93
110
|
def container_width=(value)
|
|
94
111
|
case value
|
|
95
112
|
when NilClass
|
|
96
113
|
@container_width = nil
|
|
97
114
|
when Symbol
|
|
115
|
+
value = self.class.normalize_container_width(value)
|
|
98
116
|
raise ArgumentError, "Invalid container width: #{value}. Must be one of #{VALID_CONTAINER_WIDTHS}" unless VALID_CONTAINER_WIDTHS.include?(value)
|
|
99
117
|
@container_width = CONTAINER_WIDTH_DEFAULTS.transform_values { value }
|
|
100
118
|
when Hash
|
|
@@ -102,6 +120,8 @@ module Avo
|
|
|
102
120
|
invalid_keys = value.keys.reject { |k| valid_keys.include?(k) }
|
|
103
121
|
raise ArgumentError, "Invalid container width keys: #{invalid_keys}. Valid keys: #{valid_keys}" if invalid_keys.any?
|
|
104
122
|
|
|
123
|
+
value = value.transform_values { |v| self.class.normalize_container_width(v) }
|
|
124
|
+
|
|
105
125
|
invalid_values = value.values.reject { |v| VALID_CONTAINER_WIDTHS.include?(v) }
|
|
106
126
|
raise ArgumentError, "Invalid container widths: #{invalid_values}" if invalid_values.any?
|
|
107
127
|
|
|
@@ -86,7 +86,7 @@ config.pagination = { type: :countless } # global pagination defaults; s
|
|
|
86
86
|
|
|
87
87
|
```ruby
|
|
88
88
|
config.container_width = :full # one width for all views
|
|
89
|
-
config.container_width = { index: :full, show: :
|
|
89
|
+
config.container_width = { index: :full, show: :md } # or per view / group alias
|
|
90
90
|
config.sidebar = { # the sidebar's three knobs, merged over the defaults
|
|
91
91
|
toggle_visible: false, # hide the collapse button → sidebar stays open on desktop (default true)
|
|
92
92
|
resizable: false, # remove the drag-to-resize handle (default true)
|
|
@@ -101,7 +101,7 @@ config.back_to_top = { enabled: false } # the floating "Back t
|
|
|
101
101
|
|
|
102
102
|
`config.sidebar` is a hash merged over `{toggle_visible: true, resizable: true, default_width: 256}`, so set only the keys you change. On desktop the sidebar edge is a drag handle: users resize it and the width persists **per browser** (a cookie, not a user preference). `default_width` sets the starting width and is clamped to `200`–`480` — an unparseable value falls back to `256` rather than clamping to the minimum. Both settings apply at `lg` (1024px) and wider only; below that the sidebar is a full-height overlay at the 256px default. A width the user has dragged to wins over `default_width`. The flat `config.sidebar_toggle_visible = false` still works and writes into `config.sidebar[:toggle_visible]`, but the hash is the canonical home.
|
|
103
103
|
|
|
104
|
-
`container_width` values are `:
|
|
104
|
+
`container_width` values are `:lg` (default index), `:md` (default show/forms), `:sm` (a 720px narrow container, opt-in) and `:full` — Tailwind's scale, matching every other size option in Avo. The Avo-4.0 names `:large` and `:small` still work, log a deprecation warning, and map to `:lg`/`:md`; note `:small` maps to `:md`, **not** to `:sm`, which is a genuinely narrower container that did not exist before. They go away in Avo 5. The hash form accepts individual views (`:index`, `:show`, `:new`, `:edit`, `:create`, `:update`) and group aliases (`:forms`, `:display`, `:single`); a specific key wins over an alias. The `body_classes` block runs in Avo's `ExecutionContext`, so it has `current_user`, `request`, and `params`.
|
|
105
105
|
|
|
106
106
|
### Navigation home and record flow
|
|
107
107
|
|
data/lib/avo/version.rb
CHANGED
|
@@ -153,7 +153,7 @@ Avo.configure do |config|
|
|
|
153
153
|
# config.use_browser_timezone = true # set false to render dates/times in the app's configured zone for everyone; off automatically in the test environment
|
|
154
154
|
# config.currency = 'USD'
|
|
155
155
|
# config.hide_layout_when_printing = false
|
|
156
|
-
# config.container_width = :
|
|
156
|
+
# config.container_width = :lg # :full, :lg, :md, or :sm. Hash for per-view: { index: :full, single: :md }
|
|
157
157
|
# config.use_stacked_fields = false
|
|
158
158
|
# Set to false to disable Avo's Tailwind integration even when `tailwindcss-ruby` is installed.
|
|
159
159
|
# config.tailwindcss_integration_enabled = true
|