Skip to content

Commit f351eb2

Browse files
authored
fix: visual changelist improvements (#368)
1 parent c2413d7 commit f351eb2

File tree

10 files changed

+53
-37
lines changed

10 files changed

+53
-37
lines changed

src/unfold/forms.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@
2222
class ActionForm(forms.Form):
2323
action = forms.ChoiceField(
2424
label="",
25-
widget=forms.Select({"class": " ".join([*SELECT_CLASSES, "w-72"])}),
25+
widget=forms.Select(
26+
{
27+
"class": " ".join([*SELECT_CLASSES, "max-w-full", "lg:!w-64"]),
28+
"x-model": "action",
29+
}
30+
),
2631
)
2732

2833
select_across = forms.BooleanField(

src/unfold/static/unfold/css/styles.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/unfold/styles.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,9 @@ table select:focus {
101101
@apply border-primary-600;
102102
}
103103

104-
table tr.selected {
105-
@apply bg-yellow-50 dark:bg-white/[.06];
104+
table tr.selected td,
105+
table tr.selected th {
106+
@apply bg-yellow-200/[.10] dark:bg-white/[.03];
106107
}
107108

108109
/*******************************************************

src/unfold/templates/admin/actions.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{% load i18n %}
22

3-
<div class="actions flex flex-col md:flex-row md:items-center">
3+
<div class="actions flex flex-col gap-3 order-last lg:order-none lg:flex-row lg:items-center">
44
{% block actions %}
5-
<div class="flex">
5+
<div class="flex flex-col gap-2 lg:flex-row" x-data="{action: ''}">
66
{% block actions-form %}
77
{% for field in action_form %}
88
{% if field.label %}
@@ -19,31 +19,31 @@
1919
{% endblock %}
2020

2121
{% block actions-submit %}
22-
<button type="submit" class="bg-white border flex items-center h-9.5 ml-3 px-2 rounded shadow-sm text-gray-400 w-9.5 hover:text-gray-700 focus:outline-none dark:bg-gray-900 dark:border-gray-700 dark:text-gray-500 dark:hover:text-gray-200" title="{% translate "Run the selected action" %}" name="index" value="{{ action_index|default:0 }}">
23-
<span class="material-symbols-outlined md-18">chevron_right</span>
22+
<button type="submit" x-show="action" class="bg-primary-600 cursor-pointer flex font-medium items-center justify-center px-3 py-2 rounded-md text-sm text-white whitespace-nowrap" title="{% translate "Run the selected action" %}" name="index" value="{{ action_index|default:0 }}">
23+
{% trans "Run" %}
2424
</button>
2525
{% endblock %}
2626
</div>
2727

2828
{% block actions-counter %}
2929
{% if actions_selection_counter %}
30-
<div class="hidden truncate md:block">
31-
<span class="action-counter ml-4 text-sm text-gray-500 dark:text-gray-400" data-actions-icnt="{{ cl.result_list|length }}">
30+
<div class="bg-gray-100 flex flex-row gap-2 h-9.5 items-center px-3 rounded-md shadow-sm truncate dark:bg-white/[.04] lg:bg-transparent dark:lg:!bg-transparent lg:px-0 lg:shadow-none">
31+
<span class="action-counter text-sm text-gray-500 dark:text-gray-400" data-actions-icnt="{{ cl.result_list|length }}">
3232
{{ selection_note }}
3333
</span>
3434

3535
{% if cl.result_count != cl.result_list|length %}
36-
<span class="all hidden ml-4 text-gray-500 text-sm">
36+
<span class="all hidden text-gray-500 text-sm">
3737
{{ selection_note_all }}
3838
</span>
3939

40-
<span class="question hidden ml-4 text-primary-600 text-sm underline">
40+
<span class="question hidden text-primary-600 text-sm underline">
4141
<a href="#" title="{% translate "Click here to select the objects across all pages" %}">
4242
{% blocktranslate with cl.result_count as total_count %}Select all {{ total_count }} {{ module_name }}{% endblocktranslate %}
4343
</a>
4444
</span>
4545

46-
<span class="clear hidden ml-4 text-sm text-red-600 underline">
46+
<span class="clear hidden text-sm text-red-600 underline">
4747
<a href="#">
4848
{% translate "Clear selection" %}
4949
</a>

src/unfold/templates/admin/base.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@
4343
{% if cl %}
4444
{% tab_list cl.opts %}
4545
{% elif opts %}
46-
<div class="mb-8">
47-
{% tab_list opts %}
48-
</div>
46+
{% tab_list opts %}
4947
{% endif %}
5048

5149
{% block content %}

src/unfold/templates/admin/change_list.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
{% block result_list %}
8585
{% if actions_on_top %}
8686
{% if cl.search_fields or action_form or cl.has_filters %}
87-
<div class="bg-gray-50 flex flex-col gap-3 mb-4 p-3 rounded-md md:flex-row dark:bg-gray-800">
87+
<div class="bg-gray-50 flex flex-col gap-3 mb-4 p-3 rounded-md lg:flex-row dark:bg-gray-800">
8888
{% block search %}
8989
{% search_form cl %}
9090
{% endblock %}
@@ -95,7 +95,7 @@
9595

9696
{% block filters %}
9797
{% if cl.has_filters %}
98-
<a class="{% if cl.has_active_filters %}bg-primary-600 border-primary-600 text-white{% else %}bg-white text-gray-500 hover:text-gray-700 dark:bg-gray-900 dark:border-gray-700 dark:hover:text-gray-200 dark:text-gray-400{% endif %} border cursor-pointer flex font-medium group items-center px-3 py-2 rounded-md shadow-sm text-sm md:ml-auto md:mt-0" x-on:click="filterOpen = true" x-on:keydown.escape.window="filterOpen = false">
98+
<a class="{% if cl.has_active_filters %}bg-primary-600 border-primary-600 text-white{% else %}bg-white text-gray-500 hover:text-gray-700 dark:bg-gray-900 dark:border-gray-700 dark:hover:text-gray-200 dark:text-gray-400{% endif %} border cursor-pointer flex font-medium group items-center px-3 py-2 rounded-md shadow-sm text-sm lg:ml-auto md:mt-0" x-on:click="filterOpen = true" x-on:keydown.escape.window="filterOpen = false">
9999
{% trans "Filters" %}
100100

101101
<span class="material-symbols-outlined md-18 ml-auto -mr-1 pl-4 {% if cl.has_active_filters %}text-white{% else %}text-gray-400 group-hover:text-gray-700 dark:group-hover:text-gray-200 dark:text-gray-500{% endif %}">filter_list</span>

src/unfold/templates/admin/change_list_results.html

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,30 @@
88

99
{% if results %}
1010
<table id="result_list" class="block border-gray-200 border-spacing-none border-separate text-gray-700 w-full dark:text-gray-400 lg:border lg:rounded-md lg:shadow-sm lg:table lg:dark:border-gray-800">
11-
<thead class="hidden lg:table-header-group">
11+
<thead>
1212
<tr>
1313
{% for header in result_headers %}
14-
<th class="align-middle font-medium px-3 py-2 text-left text-gray-400 text-sm {{ header.class_attrib }} {% if "action-toggle" in header.text and forloop.counter == 1 %}w-10{% endif %}" scope="col">
14+
<th class="align-middle font-medium py-2 text-left text-gray-400 text-sm {{ header.class_attrib }} {% if "action-toggle" in header.text and forloop.counter == 1 %}lg:px-3 lg:w-10{% else %}hidden px-3 lg:table-cell{% endif %}" scope="col">
1515
<div class="flex items-center">
1616
<div class="text">
1717
{% if header.sortable %}
1818
<a href="{{ header.url_primary }}">
1919
{{ header.text|capfirst }}
2020
</a>
2121
{% else %}
22-
<span>{{ header.text|capfirst }}</span>
22+
{% if "action-toggle" in header.text and forloop.counter == 1 %}
23+
<label class="flex flex-row items-center gap-2">
24+
{{ header.text|capfirst }}
25+
26+
<span class="block font-normal text-gray-500 dark:text-gray-400 lg:hidden">
27+
{% trans "Select all rows"%}
28+
</span>
29+
</label>
30+
{% else %}
31+
<span>
32+
{{ header.text|capfirst }}
33+
</span>
34+
{% endif %}
2335
{% endif %}
2436
</div>
2537

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
{% load i18n static %}
22

33
{% if cl.search_fields %}
4-
<div id="toolbar" class="lg:w-72">
5-
<div>
6-
<div class="bg-white border flex rounded-md overflow-hidden shadow-sm focus-within:ring focus-within:ring-primary-300 focus-within:border-primary-600 dark:bg-gray-900 dark:border-gray-700 dark:focus-within:border-primary-600 dark:focus-within:ring-primary-700 dark:focus-within:ring-opacity-50">
7-
<input class="font-medium h-9 px-3 text-gray-500 text-sm w-40 lg:w-60 focus:outline-none dark:bg-gray-900 dark:text-gray-400" type="text" name="{{ search_var }}" value="{{ cl.query }}" id="searchbar" placeholder="{% trans 'Type to search' %}" />
4+
<div id="toolbar">
5+
<div class="bg-white border flex rounded-md overflow-hidden shadow-sm lg:w-64 focus-within:ring focus-within:ring-primary-300 focus-within:border-primary-600 dark:bg-gray-900 dark:border-gray-700 dark:focus-within:border-primary-600 dark:focus-within:ring-primary-700 dark:focus-within:ring-opacity-50">
6+
<input class="font-medium grow min-w-0 h-9 px-3 text-gray-500 text-sm focus:outline-none dark:bg-gray-900 dark:text-gray-400" type="text" name="{{ search_var }}" value="{{ cl.query }}" id="searchbar" placeholder="{% trans 'Type to search' %}" />
87

9-
<button type="submit" class="flex items-center ml-auto px-2 focus:outline-none" id="searchbar-submit">
10-
<span class="material-symbols-outlined md-18 text-gray-400 dark:text-gray-500">search</span>
11-
</button>
12-
</div>
13-
14-
{% for pair in cl.params.items %}
15-
{% if pair.0 != search_var %}<input type="hidden" name="{{ pair.0 }}" value="{{ pair.1 }}">{% endif %}
16-
{% endfor %}
8+
<button type="submit" class="flex items-center px-2 focus:outline-none" id="searchbar-submit">
9+
<span class="material-symbols-outlined md-18 text-gray-400 dark:text-gray-500">search</span>
10+
</button>
1711
</div>
12+
13+
{% for pair in cl.params.items %}
14+
{% if pair.0 != search_var %}<input type="hidden" name="{{ pair.0 }}" value="{{ pair.1 }}">{% endif %}
15+
{% endfor %}
1816
</div>
1917
{% endif %}

src/unfold/templates/unfold/helpers/tab_list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{% if not is_popup %}
22
{% if tab_list or actions_list or actions_items or nav_global %}
3-
<div class="flex items-start flex-col mb-2 text-gray-500 text-sm w-full md:border-b dark:md:border-gray-800 md:border-l-0 md:flex-row md:items-center md:justify-end dark:text-gray-400">
3+
<div class="flex items-start flex-col mb-4 text-gray-500 text-sm w-full md:border-b dark:md:border-gray-800 md:border-l-0 md:flex-row md:items-center md:justify-end dark:text-gray-400">
44
{% if tab_list %}
55
<ul class="border rounded-md flex flex-col w-full md:flex-row md:border-b-0 md:border-t-0 md:border-l-0 md:border-r-0 dark:border-gray-800">
66
{% for item in tab_list %}

src/unfold/templatetags/unfold_list.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
register = Library()
3838

3939
LINK_CLASSES = [
40-
"text-gray-700",
40+
"text-gray-600",
4141
"truncate",
42-
"dark:text-gray-200",
42+
"dark:text-gray-300",
4343
]
4444

4545
ROW_CLASSES = [
@@ -54,6 +54,7 @@
5454
"px-3",
5555
"py-2",
5656
"text-left",
57+
"text-gray-500",
5758
"text-sm",
5859
"before:flex",
5960
"before:capitalize",
@@ -63,6 +64,7 @@
6364
"before:text-gray-500",
6465
"first:border-t-0",
6566
"dark:before:text-gray-400",
67+
"dark:text-gray-400",
6668
"lg:before:hidden",
6769
"lg:first:border-t",
6870
"lg:py-3",
@@ -186,7 +188,7 @@ def make_qs_param(t, n):
186188
"url_primary": cl.get_query_string({ORDER_VAR: ".".join(o_list_primary)}),
187189
"url_remove": cl.get_query_string({ORDER_VAR: ".".join(o_list_remove)}),
188190
"url_toggle": cl.get_query_string({ORDER_VAR: ".".join(o_list_toggle)}),
189-
"class_attrib": format_html(' class="{}"', " ".join(th_classes))
191+
"class_attrib": format_html("{}", " ".join(th_classes))
190192
if th_classes
191193
else "",
192194
}

0 commit comments

Comments
 (0)