Skip to content

Commit cf1ae88

Browse files
authored
feat: image support in header decorator (#393)
1 parent bfd11b5 commit cf1ae88

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,16 @@ class UserAdmin(ModelAdmin):
651651
"""
652652
Third argument is short text which will appear as prefix in circle
653653
"""
654-
return "First main heading", "Smaller additional description", "AB"
654+
return [
655+
"First main heading",
656+
"Smaller additional description", # Use None in case you don't need it
657+
"AB", # Short text which will appear in front of
658+
# Image instead of initials. Initials are ignored if image is available
659+
{
660+
"path": "some/path/picture.jpg,
661+
"squared": True, # Picture is displayed in square format, if empty circle
662+
}
663+
]
655664
```
656665

657666
## Change form tabs
Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
<div class="flex gap-4 items-center">
2-
{% if value.2 %}
3-
<div class="border flex font-medium h-8 justify-center items-center rounded-full text-xs uppercase w-8 dark:border-gray-700">
4-
{{ value.2 }}
5-
</div>
6-
{% endif %}
2+
{% if value.3 and value.3.path %}
3+
<div class="bg-center bg-cover bg-white border flex font-medium h-8 w-8 dark:bg-gray-900 dark:border-gray-700 {% if value.3.squared %}rounded-sm{% else %}rounded-full{% endif %}" style="background-image: url('{{ value.3.path }}')">
4+
</div>
5+
{% elif value.2 %}
6+
<div class="bg-white border flex font-medium h-8 justify-center items-center rounded-full text-xs uppercase w-8 dark:bg-gray-900 dark:border-gray-700">
7+
{{ value.2 }}
8+
</div>
9+
{% endif %}
710

8-
<div class="flex flex-col text-right lg:text-left">
9-
<h3>{{ value.0 }}</h3>
11+
<div class="flex flex-col text-right lg:text-left">
12+
<h3>{{ value.0 }}</h3>
1013

11-
{% if value.1 %}
12-
<p class="text-gray-500">
13-
{{ value.1 }}
14-
</p>
15-
{% endif %}
16-
</div>
14+
{% if value.1 %}
15+
<p class="text-gray-500">
16+
{{ value.1 }}
17+
</p>
18+
{% endif %}
19+
</div>
1720
</div>

0 commit comments

Comments
 (0)