Skip to content

Commit b323b41

Browse files
authored
fix: compressed switch checkbox (#505)
1 parent 7258a47 commit b323b41

File tree

3 files changed

+47
-20
lines changed

3 files changed

+47
-20
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/templates/unfold/helpers/fieldset_row.html

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,53 @@
66
{% for field in line %}
77
<div class="flex group {% if adminform.model_admin.compressed_fields %} field-row{% endif %}{% if not line.fields|length == 1 and not adminform.model_admin.compressed_fields %} lg:max-w-xs flex-grow{% endif %}{% if field.errors %} errors {% endif %}{% if not forloop.parentloop.last %} {% if adminform.model_admin.compressed_fields %}mb-3{% else %}mb-6{% endif %}{% else %} pb-3{% endif %} {% if adminform.model_admin.compressed_fields %}flex-col lg:flex-row lg:gap-2 {% else %}flex-col{% endif %}">
88
{% if field.is_checkbox %}
9-
<div class="flex flex-row">
10-
{{ field.field }}
11-
12-
<div class="flex flex-col">
13-
{{ field.label_tag }}
14-
15-
{% if field.field.help_text %}
16-
<div class="ml-2 -mt-1">
17-
{% include "unfold/helpers/help_text.html" with help_text=field.field.help_text %}
18-
</div>
19-
{% endif %}
20-
21-
{% if field.errors %}
22-
<span class="mt-1 text-red-600 text-sm dark:text-red-500">
23-
{{ field.errors }}
24-
</span>
25-
{% endif %}
9+
{% if adminform.model_admin.compressed_fields %}
10+
<div class="flex flex-row gap-4">
11+
<div class="font-medium h-5 flex items-start -ml-2 min-w-32 w-32 lg:min-w-48 lg:w-48">
12+
{{ field.label_tag }}
13+
</div>
14+
15+
<div class="flex-grow">
16+
<div class="flex flex-col lg:flex-row">
17+
{{ field.field }}
18+
19+
{% if field.field.help_text %}
20+
<div class="lg:-mt-2 lg:ml-2">
21+
{% include "unfold/helpers/help_text.html" with help_text=field.field.help_text %}
22+
</div>
23+
{% endif %}
24+
</div>
25+
26+
{% if field.errors %}
27+
<span class="mt-1 text-red-600 text-sm dark:text-red-500">
28+
{{ field.errors }}
29+
</span>
30+
{% endif %}
31+
</div>
2632
</div>
27-
</div>
33+
{% else %}
34+
<div class="flex flex-row">
35+
{{ field.field }}
36+
37+
<div class="flex flex-col">
38+
{{ field.label_tag }}
39+
40+
{% if field.field.help_text %}
41+
<div class="ml-2 -mt-1">
42+
{% include "unfold/helpers/help_text.html" with help_text=field.field.help_text %}
43+
</div>
44+
{% endif %}
45+
46+
{% if field.errors %}
47+
<span class="mt-1 text-red-600 text-sm dark:text-red-500">
48+
{{ field.errors }}
49+
</span>
50+
{% endif %}
51+
</div>
52+
</div>
53+
{% endif %}
2854
{% else %}
29-
<div class="{% if adminform.model_admin.compressed_fields %} min-w-48 mt-2 w-48{% endif %}">
55+
<div class="{% if adminform.model_admin.compressed_fields %} min-w-48 lg:mt-2 w-48{% endif %}">
3056
{{ field.label_tag }}
3157
</div>
3258

src/unfold/widgets.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@
227227
"rounded-full",
228228
"transition-all",
229229
"w-8",
230+
"min-w-8",
230231
"after:absolute",
231232
"after:bg-white",
232233
"after:content-['']",

0 commit comments

Comments
 (0)