widget-user: ajout de la polymorphie au widget

This commit is contained in:
Darks 2020-07-21 18:45:06 +02:00
parent c0f2552e03
commit 48dd2b982b
Signed by: Darks
GPG Key ID: F61F10FA138E797C
5 changed files with 40 additions and 52 deletions

View File

@ -68,18 +68,9 @@ table.topiclist tr > td:last-child {
table.thread {
width: 100%;
}
table.thread td.member {
table.thread td.author {
width: 20%;
}
table.thread td.guest {
width: 20%; padding-top: 12px;
text-align: center;
}
table.thread td.guest em {
display: block;
font-weight: bold; font-style: normal;
margin-bottom: 8px;
}
table.thread td {
vertical-align: top;
}

View File

@ -32,26 +32,36 @@
}
.profile-xp div {
height: 10px;
background: var(--background-xp);
border: var(--border-xp);
margin: -1px;
background: var(--background-xp);
border: var(--border-xp);
margin: -1px;
}
.profile.guest {
flex-direction: column;
width: 100%; padding-top: 12px;
text-align: center;
}
.profile.guest em {
display: block;
font-weight: bold; font-style: normal;
margin-bottom: 8px;
}
/* Trophies */
.trophies {
display: flex; flex-wrap: wrap; justify-content: space-between;
display: flex; flex-wrap: wrap; justify-content: space-between;
}
.trophy {
display: flex; align-items: center;
width: 260px;
margin: 5px; padding: 5px;
display: flex; align-items: center;
width: 260px;
margin: 5px; padding: 5px;
border: 1px solid #c5c5c5;
border-left: 5px solid var(--links);
border-radius: 2px;
border-radius: 2px;
}
.trophy img {
height: 50px; margin-right: 5px;
height: 50px; margin-right: 5px;
}
.trophy div > * {
display: block;
@ -65,7 +75,7 @@
}
.trophy.disabled {
filter: grayscale(100%);
filter: grayscale(100%);
opacity: .5;
border-left: 1px solid #c5c5c5;
}

View File

@ -1,6 +1,6 @@
{% extends "base/base.html" %}
{% import "widgets/editor.html" as widget_editor %}
{% import "widgets/member.html" as widget_member %}
{% import "widgets/user.html" as widget_user %}
{% import "widgets/pagination.html" as widget_pagination with context %}
{% block title %}
@ -11,11 +11,7 @@
<section>
<h1>{{ t.title }}</h1>
<table class="thread"><tr>
{% if t.author.type == "member" %}
<td class="member">{{ widget_member.profile(t.author ) }}</td>
{% else %}
<td class="guest"><em>Invité</em>{{ t.author.name }}</td>
{% endif %}
<td class="author">{{ widget_user.profile(t.author ) }}</td>
<td>{{ t.thread.top_comment.text }}</td>
</tr></table>
@ -25,11 +21,7 @@
{% for c in comments.items %}
<tr id="{{ c.id }}">
{% if c != t.thread.top_comment %}
{% if c.author.type == "member" %}
<td class="member">{{ widget_member.profile(c.author ) }}</td>
{% else %}
<td class="guest"><em>Invité</em>{{ c.author.name }}</td>
{% endif %}
<td class="author">{{ widget_user.profile(c.author) }}</td>
<td>
<div>{% if c.date_created != c.date_modified %}
Posté le {{ c.date_created|date }} (Modifié le {{ c.date_modified|date }})

View File

@ -1,12 +0,0 @@
{% macro profile(member) %}
<div class=profile>
<img class=profile-avatar src="{{ url_for('avatar', filename=member.avatar) }}" alt="Avatar de {{ member.name }}">
<div>
<div class=profile-name><a href="{{ url_for('user', username=member.name) }}">{{ member.name }}</a></div>
<div class=profile-title>Membre</div>
<div class=profile-points>Niveau {{ member.level[0] }} <span>({{ member.xp }})</span></div>
<div class=profile-points-small>N{{ member.level[0] }} <span>({{ member.xp }})</span></div>
<div class=profile-xp><div style='width: {{ member.level[1] }}%;'></div></div>
</div>
</div>
{% endmacro %}

View File

@ -1,12 +1,19 @@
{% macro profile(member) %}
<div class=profile>
<img class=profile-avatar src="{{ url_for('avatar', filename=member.avatar) }}" alt="Avatar de {{ member.name }}">
{% macro profile(user) %}
{% if user.type == "member" %}
<div class="profile">
<img class="profile-avatar" src="{{ url_for('avatar', filename=user.avatar) }}" alt="Avatar de {{ user.name }}">
<div>
<div class=profile-name>{{ member.name }}</div>
<div class=profile-title>Membre</div>
<div class=profile-points>Niveau {{ member.level[0] }} <span>({{ member.xp }})</span></div>
<div class=profile-points-small>N{{ member.level[0] }} <span>({{ member.xp }})</span></div>
<div class=profile-xp><div style='width: {{ member.level[1] }}%;'></div></div>
<div class="profile-name">{{ user.name }}</div>
<div class="profile-title">Membre</div>
<div class="profile-points">Niveau {{ user.level[0] }} <span>({{ user.xp }})</span></div>
<div class="profile-points-small">N{{ user.level[0] }} <span>({{ user.xp }})</span></div>
<div class="profile-xp"><div style='width: {{ user.level[1] }}%;'></div></div>
</div>
</div>
</div>
{% else %}
<div class="profile guest">
<em>{{ user.name }}</em>
<span>Invité</span>
</div>
{% endif %}
{% endmacro %}