Skip to content

Commit 491d5d3

Browse files
authored
feat: crispy fieldset subheader (#1311)
1 parent 7c7fe47 commit 491d5d3

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

src/unfold/layout.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,22 @@ class Button(ButtonClassesMixin, BaseInput):
2525
input_type = "button"
2626

2727

28+
class FieldsetSubheader(LayoutObject):
29+
template = "unfold_crispy/layout/fieldset_subheader.html"
30+
31+
def __init__(self, title=None, *args, **kwargs):
32+
self.title = title
33+
super().__init__(*args, **kwargs)
34+
35+
def render(self, form, context, template_pack=TEMPLATE_PACK, **kwargs):
36+
return render_to_string(
37+
self.template,
38+
{
39+
"title": self.title,
40+
},
41+
)
42+
43+
2844
class Hr(LayoutObject):
2945
template = "unfold_crispy/layout/hr.html"
3046

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_crispy/layout/fieldset.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@
55
</legend>
66
{% endif %}
77

8-
{{ fields|safe }}
8+
<div class="flex flex-col gap-5">
9+
{{ fields|safe }}
10+
</div>
911
</fieldset>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div class="border-b border-t border-base-200 font-semibold -mx-3 py-2.5 px-3 text-font-important-light first:border-t-0 first:-mt-5 dark:border-base-800 dark:text-font-important-dark">
2+
{{ title }}
3+
</div>

0 commit comments

Comments
 (0)