misuzu/templates/profile/_layout/header.twig

130 lines
6.9 KiB
Twig

{% from 'macros.twig' import avatar %}
{% from '_layout/input.twig' import input_checkbox_raw %}
<div class="container profile__header">
<div class="profile__header__background"></div>
<div class="profile__header__details">
<div class="profile__header__avatar">
{% if profile_is_editing and perms.edit_avatar %}
<label class="profile__header__avatar__image profile__header__avatar__image--edit" for="avatar-selection">
{{ avatar(profile_user.user_id, 120, profile_user.username, {'id': 'avatar-preview'}) }}
</label>
<div class="profile__header__avatar__options">
<label class="input__button profile__header__avatar__option" for="avatar-selection">
Select
</label>
{{ input_checkbox_raw('avatar[delete]', false, 'profile__header__avatar__check', '', false, {'id':'avatar-delete'}) }}
<label class="input__button profile__header__avatar__option profile__header__avatar__option--delete"
for="avatar-delete">
Remove
</label>
</div>
{% else %}
<div class="profile__header__avatar__image">
{{ avatar(profile_user.user_id|default(0), 120, profile_user.username|default('')) }}
</div>
{% endif %}
</div>
<div class="profile__header__details__content">
{% if profile_user is defined %}
<div class="profile__header__username" style="{{ profile_user.user_colour|html_colour }}">
{{ profile_user.username }}
</div>
{% if profile_user.user_title is not empty %}
<div class="profile__header__title">
{{ profile_user.user_title }}
</div>
{% endif %}
<div class="profile__header__country">
<div class="flag flag--{{ profile_user.country|lower }}"></div>
<div class="profile__header__country__name">
{{ profile_user.countryName }}{% if profile_user.user_age > 0 %}, {{ profile_user.user_age }} year{{ profile_user.user_age != 's' ? 's' : '' }} old{% endif %}
</div>
</div>
{% else %}
<div class="profile__header__username">
User not found!
</div>
<div class="profile__header__title">
Check the link and try again.
</div>
{% endif %}
</div>
{% if profile_viewer is not null and profile_user.id != profile_viewer.id and profile_user.relationString(profile_viewer) != 'none' %}
<div class="profile__header__details__relation" title="Since {{ profile_user.relationTime(profile_viewer)|date('r') }}">
{% if profile_user.relationString(profile_viewer) == 'mutual' %}
Mutual Friends
{% elseif profile_user.relationString(profile_viewer) == 'followed' %}
You Follow
{% elseif profile_user.relationString(profile_viewer) == 'following' %}
Follows You
{% endif %}
</div>
{% endif %}
</div>
<div class="profile__header__options">
{% if profile_user is defined %}
<div class="profile__header__actions">
{% if profile_mode is empty %}
{% if profile_is_editing %}
<button class="input__button input__button--save profile__header__action">Save</button>
<a href="{{ url('user-profile', {'user': profile_user.user_id}) }}" class="input__button input__button--destroy profile__header__action">Discard</a>
<a href="{{ url('settings-index') }}" class="input__button profile__header__action">Settings</a>
{% elseif profile_can_edit %}
<a href="{{ url('user-profile-edit', {'user': profile_user.user_id}) }}" class="input__button profile__header__action">Edit Profile</a>
{% endif %}
{% if current_user is defined and current_user.user_id != profile_user.user_id and not profile_is_editing %}
{% if profile_user.relationString(profile_viewer) != 'following' %}
<a href="{{ url('user-relation-none', {'user': profile_user.user_id}) }}" class="input__button input__button--destroy profile__header__action js-user-relation-action" data-relation-user="{{ profile_user.user_id }}" data-relation-type="0">Unfollow</a>
{% else %}
<a href="{{ url('user-relation-follow', {'user': profile_user.user_id}) }}" class="input__button profile__header__action js-user-relation-action" data-relation-user="{{ profile_user.user_id }}" data-relation-type="1">Follow</a>
{% endif %}
{% endif %}
{% else %}
<a href="{{ url('user-profile', {'user': profile_user.user_id}) }}" class="input__button profile__header__action">Return</a>
{% endif %}
</div>
{% endif %}
{% if stats is defined %}
<div class="profile__header__stats">
{% for stat in stats %}
{% if stat.value|default(false) %}
{% set is_date = stat.is_date|default(false) %}
{% set is_url = stat.url is defined %}
{% set active_class = stat.active|default(false) ? ' profile__header__stat--active' : '' %}
{% if is_url %}
<a class="profile__header__stat profile__header__stat--link{{ active_class }}" href="{{ stat.url }}">
{% else %}
<div class="profile__header__stat{{ active_class }}{% if is_date %} profile__header__stat--date" title="{{ stat.value|date('r') }}{% endif %}">
{% endif %}
<div class="profile__header__stat__name">
{{ stat.title }}
</div>
{% if is_date %}
<time class="profile__header__stat__value" datetime="{{ stat.value|date('c') }}">
{{ stat.value|time_diff }}
</time>
{% else %}
<div class="profile__header__stat__value">
{{ stat.value|number_format }}
</div>
{% endif %}
{% if is_url %}</a>{% else %}</div>{% endif %}
{% endif %}
{% endfor %}
</div>
{% endif %}
</div>
</div>