-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create an avatar tag to be usable anywhere we need an avatar. #1298
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{% extends "admin/base_site.html" %} | ||
{% load static %} | ||
{% load static avatar_tags %} | ||
{% block extrahead %} | ||
<link href="{% static 'css/styles.css' %}" rel="stylesheet" /> | ||
{% endblock extrahead %} | ||
|
@@ -33,12 +33,7 @@ <h3 class="mb-2"> | |
<div class="flex flex-col gap-y-1"> | ||
{% for author in commits_per_author %} | ||
<div class="flex gap-x-1"> | ||
{% if author.avatar_url %} | ||
<img src="{{ author.avatar_url }}" alt="github avatar" class="w-8 rounded"> | ||
{% else %} | ||
<div class="w-8 h-8 rounded bg-silver"> | ||
</div> | ||
{% endif %} | ||
{% avatar name=author.name image_url=author.avatar_url href=author.github_profile_url %} | ||
<div> | ||
{{ author.name }}: {{ author.count }} | ||
</div> | ||
|
@@ -60,14 +55,7 @@ <h3 class="my-2"> | |
<hr> | ||
{% endifchanged %} | ||
<div class="flex gap-x-1"> | ||
{% if item.commit__author__avatar_url %} | ||
<img src="{{ item.commit__author__avatar_url }}" | ||
alt="github avatar" | ||
class="w-8 rounded"> | ||
{% else %} | ||
<div class="w-8 h-8 rounded bg-silver"> | ||
</div> | ||
{% endif %} | ||
{% avatar name=item.commit__author__name image_url=item.commit__author__avatar_url href=None %} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does "href" have different values here versus the previous one? Why is image_url different here from the previous one? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because the object is different. Each item in this queryset is actually a |
||
<div> | ||
{{ item.commit__author__name }}: {{ item.count }} | ||
</div> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,21 @@ | ||
{% 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 %} | ||
{% with av_alt=av_alt|default:av_name av_icon_size=av_icon_size|default:"text-3xl" %} | ||
<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 justify-center relative" title="{{ av_title }}"> | ||
{% if av_image_url %} | ||
<img src="{{ av_image_url }}" | ||
alt="{{ av_alt }}" | ||
class="rounded-lg {{ av_size }} object-cover mx-auto" /> | ||
{% else %} | ||
<i class="{{ av_icon_size }} align-middle fas fa-user text-white dark:text-white/60"></i> | ||
{% endif %} | ||
</div> | ||
{% if av_show_name %} | ||
<span class="text-xs">{{ av_name }}</span> | ||
{% endif %} | ||
</div> | ||
</a> | ||
{% endwith %} | ||
{% endwith %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,36 @@ | ||
{% if mobile %} | ||
{% if not user.is_authenticated %} | ||
<a href="{% url 'account_signup' %}" class="menu-link-right">Join</a> | ||
{% else %} | ||
{% if user.image %} | ||
<span class="block py-2 px-3"> | ||
<img src="{{ user.image.url }}" alt="user" class="inline -mt-1 rounded cursor-pointer w-[30px]" @click="userOpen = !userOpen" /> | ||
</span> | ||
{% endif %} | ||
<a href="{% url 'profile-account' %}" class="block py-2 px-3 text-gray-500 dark:text-gray-400">My Profile</a> | ||
<a href="{% url 'account_logout' %}" class="block py-2 px-3 text-gray-500 dark:text-gray-400">Log Out</a> | ||
{% endif %} | ||
{% load avatar_tags %} | ||
{% if not request.user.is_authenticated %} | ||
<a href="{% url 'account_signup' %}" | ||
class="menu-link-right"> | ||
Join | ||
</a> | ||
{% else %} | ||
{% if not user.is_authenticated %} | ||
<a href="{% url 'account_signup' %}" | ||
class="menu-link-right"> | ||
Join | ||
</a> | ||
{% else %} | ||
{% if user.image %} | ||
<div class="h-[30px] w-[30px] text-slate rounded dark:text-white dark:bg-slate justify-center flex overflow-hidden"> | ||
<img src="{{ user.image_thumbnail.url }}" | ||
alt="user" | ||
class="h-full w-full cursor-pointer object-cover" | ||
@click="userOpen = !userOpen" /> | ||
</div> | ||
{% else %} | ||
<div class="h-[30px] w-[30px] bg-white text-slate rounded dark:text-white dark:bg-slate justify-center flex"> | ||
<i class="fas fa-user text-2xl" @click="userOpen = !userOpen"></i> | ||
</div> | ||
{% endif %} | ||
<div x-show="userOpen" | ||
@click.away="userOpen = false" | ||
id="userMenu" | ||
x-transition:enter="transition ease-out duration-100" | ||
x-transition:enter-start="transform opacity-0 scale-95" | ||
x-transition:enter-end="transform opacity-100 scale-100" | ||
x-transition:leave="transition ease-in duration-75" | ||
x-transition:leave-start="transform opacity-100 scale-100" | ||
x-transition:leave-end="transform opacity-0 scale-95" | ||
x-ref="menu-items" | ||
x-description="Profile Menu" | ||
role="menu" | ||
aria-orientation="vertical" | ||
aria-labelledby="user-menu-button" | ||
tabindex="-1" | ||
class="absolute right-0 z-10 py-1 px-2 mt-2 w-32 text-left bg-white rounded-md divide-y divide-gray-300 border border-gray-300 shadow-lg dark:ring-gray-500 dark:divide-gray-500 dark:bg-charcoal" | ||
> | ||
<a href="{% url 'profile-account' %}" class="block py-2 text-xs font-medium dark:text-white text-charcoal dark:hover:text-orange hover:text-orange">My Profile</a> | ||
<a href="{% url 'account_logout' %}" class="block py-2 text-xs font-medium dark:text-white text-charcoal dark:hover:text-orange hover:text-orange">Log Out</a> | ||
</div> | ||
{% endif %} | ||
<div | ||
class="h-[30px] w-[30px] cursor-pointer object-cover flex text-slate rounded dark:text-white dark:bg-slate" | ||
@click="userOpen = !userOpen" | ||
> | ||
{% avatar image_url=request.user.get_thumbnail_url href=None alt="user" name=request.user.get_full_name image_size="h-[30px] w-[30px]" icon_size="text-2xl" %} | ||
</div> | ||
<div x-show="userOpen" | ||
@click.away="userOpen = false" | ||
id="userMenu" | ||
x-transition:enter="transition ease-out duration-100" | ||
x-transition:enter-start="transform opacity-0 scale-95" | ||
x-transition:enter-end="transform opacity-100 scale-100" | ||
x-transition:leave="transition ease-in duration-75" | ||
x-transition:leave-start="transform opacity-100 scale-100" | ||
x-transition:leave-end="transform opacity-0 scale-95" | ||
x-ref="menu-items" | ||
x-description="Profile Menu" | ||
role="menu" | ||
aria-orientation="vertical" | ||
aria-labelledby="user-menu-button" | ||
tabindex="-1" | ||
{# have to set display: none so that x-show starts off as hidden, otherwise there is a flicker #} | ||
style="display: none;" | ||
class="absolute right-0 z-10 py-1 px-2 mt-2 w-32 text-left bg-white rounded-md divide-y divide-gray-300 border border-gray-300 shadow-lg dark:ring-gray-500 dark:divide-gray-500 dark:bg-charcoal" | ||
> | ||
<a href="{% url 'profile-account' %}" class="block py-2 text-xs font-medium dark:text-white text-charcoal dark:hover:text-orange hover:text-orange">My Profile</a> | ||
<a href="{% url 'account_logout' %}" class="block py-2 text-xs font-medium dark:text-white text-charcoal dark:hover:text-orange hover:text-orange">Log Out</a> | ||
</div> | ||
{% endif %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a django tag? It looks just like a partial.. what am I missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's similar to a partial.
include
method instead, and don't include a name for example, it will still render but without a name.I opted for the django tag as it's slightly easier to use but I'm fine with either way.