-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create an avatar tag to be usable anywhere we need an avatar.
- fixes #1285 - Use a django tag to render an avatar component.
- Loading branch information
Showing
7 changed files
with
67 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,20 @@ | ||
{% if profile.avatar %} | ||
<img class="avatar" src="{{ profile.avatar.url }}" alt="{{ profile.user }}" /> | ||
{% elif show_placeholder %} | ||
<span class="avatar empty"> | ||
<i class="far fa-user fa-4x" ></i> | ||
</span> | ||
{% endif %} | ||
{# Intended to be used with a django tag: avatar_tags.avatar #} | ||
{% with av_size=av_size|default:"w-9 h-9" av_show_name=av_show_name|default:False av_title=av_title|default:av_name av_alt=av_alt|default:av_name %} | ||
<a {% if av_href %}href="{{ av_href }}"{% endif %}> | ||
<div class="w-min text-center flex flex-col justify-center items-center"> | ||
<div class="bg-gray-300 dark:bg-slate rounded-lg {{ av_size }} flex items-center"> | ||
{% if av_image_url %} | ||
<img src="{{ av_image_url }}" | ||
title="{{ av_title }}" | ||
alt="{{ av_alt }}" | ||
class="rounded-lg {{ av_size }} object-cover mx-auto" /> | ||
{% else %} | ||
<i class="{{ av_size }} m-auto text-3xl align-middle fas fa-user text-white dark:text-white/60" title="{{ av_title }}"></i> | ||
{% endif %} | ||
</div> | ||
{% if av_show_name %} | ||
<span class="text-xs">{{ av_name }}</span> | ||
{% endif %} | ||
</div> | ||
</a> | ||
{% endwith %} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from django import template | ||
from django.template.loader import render_to_string | ||
|
||
register = template.Library() | ||
|
||
|
||
@register.simple_tag() | ||
def avatar( | ||
name, | ||
image_url, | ||
href, | ||
is_show_name=False, | ||
alt=None, | ||
title=None, | ||
image_size=None, | ||
): | ||
context = { | ||
"av_name": name, | ||
"av_href": href, | ||
"av_image_url": image_url, | ||
"av_show_name": is_show_name, | ||
"av_size": image_size, | ||
"av_title": title, | ||
"av_alt": alt, | ||
} | ||
return render_to_string("partials/avatar.html", context) |