Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layout #349

Merged
merged 7 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions docs/.vitepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,20 @@ const config = {
{text: "Record previews", link: "/3.0/record-previews.html"},
{text: "Scopes", link: "/3.0/scopes.html"},
{text: "Records reordering", link: "/3.0/records-reordering.html"},
{text: "Resource sidebar", link: "/3.0/resource-sidebar.html"},
{text: "Resource panels", link: "/3.0/resource-panels.html"},
{text: "Resource tabs", link: "/3.0/tabs.html"},
{text: "Discreet information", link: "/3.0/discreet-information.html"},
{text: "Customizable controls", link: "/3.0/customizable-controls.html"},
{text: "Cover and Profile Photos", link: "/3.0/cover-and-profile-photos.html"},
],
},
{
text: "Layout",
items: [
{text: "Panels", link: "/3.0/resource-panels.html"},
{text: "Clusters", link: "/3.0/resource-clusters.html"},
{text: "Sidebars", link: "/3.0/resource-sidebar.html"},
{text: "Tabs", link: "/3.0/tabs.html"},
],
},
{
text: "Views",
items: [
Expand Down
1 change: 0 additions & 1 deletion docs/3.0/fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ class Avo::Resources::User < Avo::BaseResource
end
```


## Field Types

<ul>
Expand Down
36 changes: 36 additions & 0 deletions docs/3.0/resource-clusters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Several fields in a cluster

<VersionReq version="3.18.0" class="mt-2" />

:::info
To fully understand this section, you should be familiar with the [`stacked`](./field-wrappers.html#stacked) field option and [`resource panels`](./resource-panels.html). These concepts will help you structure and customize your fields effectively.
:::

The `cluster` DSL allows you to group multiple fields horizontally within a [`panel`](./resource-panels.html#computed-panels-vs-manual-customization). This is useful for organizing related fields in a structured layout.

To enhance readability and maintain a well-organized UI, it is recommended to use the [`stacked`](./field-wrappers.html#stacked) option for fields inside clusters.

<Image src="/assets/img/row.png" width="1028" height="230" alt="Field naming convention" />

```ruby{4-18}
# app/avo/resources/user.rb
class Avo::Resources::Person < Avo::BaseResource
def fields
panel "Address" do
cluster do
field :street_address, stacked: true do
"1234 Elm Street"
end

field :city, stacked: true do
"Los Angeles"
end

field :zip_code, stacked: true do
"15234"
end
end
end
end
end
```
34 changes: 34 additions & 0 deletions docs/3.0/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,40 @@ You can now refine this method to restrict access for specific users or even def

</Option>

<Option name="Deprecation of `row`">

The `row` DSL has been available but undocumented for some time. As of <Version version="3.18.0" />, it has been officially deprecated in favor of `cluster`, which is now properly documented [here](./resource-clusters.html).

### Steps to Update

Replace all `row do` with `cluster do`.

```ruby
# app/avo/resources/user.rb
class Avo::Resources::Person < Avo::BaseResource
def fields
panel "Address" do
row do # [!code --]
cluster do # [!code ++]
field :street_address, stacked: true do
"1234 Elm Street"
end

field :city, stacked: true do
"Los Angeles"
end

field :zip_code, stacked: true do
"15234"
end
end
end
end
end
```

</Option>


## Upgrade from 3.16.2 to 3.16.3

Expand Down
Binary file added docs/public/assets/img/row.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.