Skip to content

Commit 8461406

Browse files
authored
fix: inline timezone warning (#506)
1 parent b323b41 commit 8461406

File tree

6 files changed

+33
-16
lines changed

6 files changed

+33
-16
lines changed

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: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,21 @@ table tr.selected th {
157157
}
158158

159159
.timezonewarning {
160-
@apply mt-2 text-gray-500 text-xs w-full;
160+
@apply absolute block items-center right-20 top-2.5 text-gray-500 truncate;
161+
font-size: 0;
162+
}
163+
164+
.timezonewarning:hover {
165+
@apply bg-white bottom-px leading-9 left-px right-px px-3 rounded-md text-xs top-px dark:bg-gray-900;
166+
}
167+
168+
.timezonewarning:hover:before {
169+
@apply hidden mr-2;
170+
}
171+
172+
.timezonewarning:before {
173+
@apply block cursor-pointer items-center justify-center material-symbols-outlined text-base text-center text-red-600 dark:border-gray-700;
174+
content: "warning";
161175
}
162176

163177
/*******************************************************

src/unfold/templates/admin/edit_inline/tabular.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ <h2 class="bg-gray-100 border border-transparent font-semibold mb-6 px-4 py-3 ro
110110
{% with is_last_col=forloop.last %}
111111
{% for field in line %}
112112
{% if field.is_readonly or not field.field.is_hidden %}
113-
<td{% if field.field.name %} class="field-{{ field.field.name }}{% if field.field.errors|length > 0 %} errors{% endif %}{% if inline_admin_form.original %} p-3 lg:py-3{% else %} py-3{% endif %}{% if field.is_checkbox %} align-middle{% else %} align-top{% endif %} {% if is_last_row and not inline_admin_formset.has_add_permission %}{% if is_last_col %}border-0 {% else %}border-b lg:border-0{% endif %}{% else %}border-b{% endif %} border-gray-200 flex items-center before:capitalize before:content-[attr(data-label)] before:mr-auto before:text-gray-500 before:w-72 lg:before:hidden font-normal px-3 text-left text-sm lg:table-cell dark:border-gray-800 {% if field.field.is_hidden %} !hidden{% endif %}"{% endif %} data-label="{{ field.field.label }}">
113+
<td{% if field.field.name %} class="field-{{ field.field.name }} group field-tabular {% if field.field.errors|length > 0 %} errors{% endif %}{% if inline_admin_form.original %} p-3 lg:py-3{% else %} py-3{% endif %}{% if field.is_checkbox %} align-middle{% else %} align-top{% endif %} {% if is_last_row and not inline_admin_formset.has_add_permission %}{% if is_last_col %}border-0 {% else %}border-b lg:border-0{% endif %}{% else %}border-b{% endif %} border-gray-200 flex items-center before:capitalize before:content-[attr(data-label)] before:mr-auto before:text-gray-500 before:pr-4 lg:before:hidden font-normal px-3 text-left text-sm lg:table-cell dark:border-gray-800 {% if field.field.is_hidden %} !hidden{% endif %}"{% endif %} data-label="{{ field.field.label }}">
114114
{% if field.is_readonly %}
115115
{% include "unfold/helpers/field_readonly_value.html" with tabular=1 %}
116116
{% else %}
@@ -132,7 +132,7 @@ <h2 class="bg-gray-100 border border-transparent font-semibold mb-6 px-4 py-3 ro
132132
{% endfor %}
133133

134134
{% if inline_admin_formset.formset.can_delete and inline_admin_formset.has_delete_permission %}
135-
<td class="delete {% if inline_admin_form.original %}p-3 lg:py-3{% else %}py-3{% endif %} text-left font-normal px-3 text-sm text-red-600 border-b border-gray-200 flex items-center before:capitalize before:content-[attr(data-label)] before:mr-auto before:text-gray-500 before:w-72 lg:before:hidden font-normal px-3 text-sm lg:align-top lg:table-cell lg:underline lg:w-px dark:border-gray-800" data-label="{% trans "Remove" %}">
135+
<td class="delete {% if inline_admin_form.original %}p-3 lg:py-3{% else %}py-3{% endif %} text-left text-red-600 border-b border-gray-200 flex items-center before:capitalize before:content-[attr(data-label)] before:mr-auto before:text-gray-500 before:pr-4 lg:before:hidden font-normal px-3 text-sm lg:align-top lg:table-cell lg:underline lg:w-px dark:border-gray-800" data-label="{% trans "Remove" %}">
136136
{% if inline_admin_form.original %}
137137
<div class="flex flex-row lg:mt-3">
138138
<div class="ml-auto">

src/unfold/templates/unfold/widgets/foreign_key_raw_id.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="flex flex-row">
1+
<div class="flex flex-row flex-grow">
22
{% include 'django/forms/widgets/input.html' %}
33

44
{% if related_url %}

src/unfold/templates/unfold/widgets/split_datetime.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
<div class="datetime flex flex-col gap-2 max-w-2xl lg:flex-row group-[.field-row]:flex-row group-[.field-row]:items-center">
2-
<div class="basis-1/2 flex flex-col flex-wrap mb-4 lg:mb-0 group-[.field-row]:flex-row group-[.field-row]:gap-2">
3-
<div class="font-medium mb-2 text-gray-500 text-sm dark:text-gray-400 group-[.field-row]:mb-0 group-[.field-row]:flex group-[.field-row]:items-center">
1+
<div class="datetime flex flex-col gap-2 max-w-2xl lg:flex-row lg:group-[.field-row]:flex-row lg:group-[.field-row]:items-center lg:group-[.field-tabular]:flex-row lg:group-[.field-tabular]:items-center">
2+
<div class="basis-1/2 flex flex-col lg:group-[.field-row]:flex-row group-[.field-row]:gap-2 lg:group-[.field-tabular]:flex-row group-[.field-tabular]:gap-2">
3+
<div class="font-medium mb-2 text-gray-500 text-sm dark:text-gray-400 group-[.field-row]:mb-0 group-[.field-row]:flex group-[.field-row]:items-center group-[.field-tabular]:mb-0 group-[.field-tabular]:flex group-[.field-tabular]:items-center">
44
{{ date_label }}
55
</div>
66

77
{% with widget=widget.subwidgets.0 %}
8-
<div class="flex flex-col relative group-[.field-row]:flex-grow">
8+
<div class="flex flex-col min-w-52 relative group-[.field-row]:flex-grow group-[.field-tabular]:flex-grow">
99
{% include widget.template_name %}
1010
</div>
1111
{% endwith %}
1212
</div>
1313

14-
<div class="basis-1/2 flex flex-col flex-wrap lg:ml-auto mt-3 md:mt-0 group-[.field-row]:flex-row group-[.field-row]:gap-2">
15-
<div class="font-medium mb-2 text-gray-500 text-sm dark:text-gray-400 group-[.field-row]:mb-0 group-[.field-row]:flex group-[.field-row]:items-center">
14+
<div class="basis-1/2 flex flex-col lg:ml-auto md:mt-0 lg:group-[.field-row]:flex-row group-[.field-row]:gap-2 lg:group-[.field-tabular]:flex-row group-[.field-tabular]:gap-2">
15+
<div class="font-medium mb-2 text-gray-500 text-sm dark:text-gray-400 group-[.field-row]:mb-0 group-[.field-row]:flex group-[.field-row]:items-center group-[.field-tabular]:mb-0 group-[.field-tabular]:flex group-[.field-tabular]:items-center">
1616
{{ time_label }}
1717
</div>
1818

1919
{% with widget=widget.subwidgets.1 %}
20-
<div class="flex flex-col relative group-[.field-row]:flex-grow">
20+
<div class="flex flex-col min-w-52 relative group-[.field-row]:flex-grow group-[.field-tabular]:flex-grow">
2121
{% include widget.template_name %}
2222
</div>
2323
{% endwith %}

src/unfold/widgets.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"border",
5050
"bg-white",
5151
"font-medium",
52+
"min-w-20",
5253
"rounded-md",
5354
"shadow-sm",
5455
"text-gray-500",
@@ -78,6 +79,8 @@
7879

7980
INPUT_CLASSES = [*BASE_INPUT_CLASSES, "max-w-2xl"]
8081

82+
DATETIME_CLASSES = [*BASE_INPUT_CLASSES, "min-w-52"]
83+
8184
COLOR_CLASSES = [*BASE_CLASSES, "h-9.5", "px-2", "py-2", "w-32"]
8285

8386
INPUT_CLASSES_READONLY = [*BASE_INPUT_CLASSES, "bg-gray-50"]
@@ -322,7 +325,7 @@ def __init__(
322325
self, attrs: Optional[Dict[str, Any]] = None, format: Optional[str] = None
323326
) -> None:
324327
attrs = {
325-
"class": "vDateField " + " ".join(INPUT_CLASSES),
328+
"class": "vDateField " + " ".join(DATETIME_CLASSES),
326329
"size": "10",
327330
**(attrs or {}),
328331
}
@@ -336,7 +339,7 @@ def __init__(
336339
self, attrs: Optional[Dict[str, Any]] = None, format: Optional[str] = None
337340
) -> None:
338341
attrs = {
339-
"class": "vDateField " + " ".join(INPUT_CLASSES),
342+
"class": "vDateField " + " ".join(DATETIME_CLASSES),
340343
"size": "10",
341344
**(attrs or {}),
342345
}
@@ -348,7 +351,7 @@ def __init__(
348351
self, attrs: Optional[Dict[str, Any]] = None, format: Optional[str] = None
349352
) -> None:
350353
attrs = {
351-
"class": "vTimeField " + " ".join(INPUT_CLASSES),
354+
"class": "vTimeField " + " ".join(DATETIME_CLASSES),
352355
"size": "8",
353356
**(attrs or {}),
354357
}
@@ -362,7 +365,7 @@ def __init__(
362365
self, attrs: Optional[Dict[str, Any]] = None, format: Optional[str] = None
363366
) -> None:
364367
attrs = {
365-
"class": "vTimeField " + " ".join(INPUT_CLASSES),
368+
"class": "vTimeField " + " ".join(DATETIME_CLASSES),
366369
"size": "8",
367370
**(attrs or {}),
368371
}

0 commit comments

Comments
 (0)