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

add after_main position to render_resource_slot and improve docs #849

Merged
merged 1 commit into from
Feb 9, 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
1 change: 1 addition & 0 deletions lib/backpex/html/resource/resource_form.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@

{@live_resource.render_resource_slot(assigns, @live_action, :before_main)}
{@live_resource.render_resource_slot(assigns, @live_action, :main)}
{@live_resource.render_resource_slot(assigns, @live_action, :after_main)}
</div>
1 change: 1 addition & 0 deletions lib/backpex/html/resource/resource_index.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@

{@live_resource.render_resource_slot(assigns, :index, :before_main)}
{@live_resource.render_resource_slot(assigns, :index, :main)}
{@live_resource.render_resource_slot(assigns, :index, :after_main)}
</div>
1 change: 1 addition & 0 deletions lib/backpex/html/resource/resource_show.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@

{@live_resource.render_resource_slot(assigns, :show, :before_main)}
{@live_resource.render_resource_slot(assigns, :show, :main)}
{@live_resource.render_resource_slot(assigns, :show, :after_main)}
</div>
21 changes: 15 additions & 6 deletions lib/backpex/live_resource.ex
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,21 @@ defmodule Backpex.LiveResource do
@doc """
The function that can be used to add content to certain positions on Backpex views. It may also be used to overwrite content.

The following actions are supported: `:index`, `:show`

The following positions are supported for the `:index` action: `:page_title`, `:actions`, `:filters`, `:metrics` and `:main`.
The following positions are supported for the `:show` action: `:page_title` and `:main`.

In addition to this, content can be inserted between the main positions via the following extra spots: `:before_page_title`, `:before_actions`, `:before_filters`, `:before_metrics` and `:before_main`.
See the following list for the available positions and the corresponding actions:

- all actions
- `:before_page_title`
- `:page_title`
- `:before_main`
- `:main`
- `:after_main`
- `:index` action
- `:before_actions`
- `:actions`
- `:before_filters`
- `:filters`
- `:before_metrics`
- `:metrics`
"""
@callback render_resource_slot(assigns :: map(), action :: atom(), position :: atom()) ::
%Phoenix.LiveView.Rendered{}
Expand Down