Skip to content

feat: list_fullwidth for custom pages #1430

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions src/unfold/templates/admin/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@

{% block messages %}
<div class="px-4">
<div class="{% if not cl.model_admin.list_fullwidth %}container{% endif %} mx-auto">
<div class="{% if not cl.model_admin.list_fullwidth and not list_fullwidth %}container{% endif %} mx-auto">
{% include "unfold/helpers/messages.html" %}
</div>
</div>
{% endblock messages %}

<div class="@container px-4 pb-4 grow">
<div id="content" class="{% if not cl.model_admin.list_fullwidth %}container{% endif %} mx-auto {% block coltype %}colM{% endblock %}">
<div id="content" class="{% if not cl.model_admin.list_fullwidth and not list_fullwidth%}container{% endif %} mx-auto {% block coltype %}colM{% endblock %}">
{% if cl %}
{% tab_list "changelist" cl.opts %}
{% elif opts %}
Expand Down
2 changes: 1 addition & 1 deletion src/unfold/templates/unfold/helpers/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% if not is_popup %}
{% block header %}
<div class="bg-white border-b border-base-200 mb-6 px-4 z-40 dark:bg-base-900 dark:border-base-800 dark:text-font-default-dark {% element_classes 'header' %}">
<div class="{% if not cl.model_admin.list_fullwidth %}container{% endif %} flex items-center h-16 mx-auto py-4">
<div class="{% if not cl.model_admin.list_fullwidth and not list_fullwidth %}container{% endif %} flex items-center h-16 mx-auto py-4">
<div id="header-inner" class="flex items-center w-full">
<div class="flex items-center w-full">
{% block usertools %}
Expand Down
2 changes: 2 additions & 0 deletions src/unfold/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class UnfoldModelAdminViewMixin(PermissionRequiredMixin):
"""

model_admin = None
list_fullwidth = False

def __init__(self, model_admin, **kwargs):
self.model_admin = model_admin
Expand All @@ -44,4 +45,5 @@ def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
**kwargs,
**self.model_admin.admin_site.each_context(self.request),
**{"title": self.title},
**{"list_fullwidth": self.list_fullwidth},
)