misuzu/templates/profile/_layout/header.twig

130 lines
7 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_id, 120, profile.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_id|default(0), 120, profile.username|default('')) }}
</div>
{% endif %}
</div>
<div class="profile__header__details__content">
{% if profile is defined %}
<div class="profile__header__username" style="{{ profile.user_colour|html_colour }}">
{{ profile.username }}
</div>
{% if profile.user_title is not empty %}
<div class="profile__header__title">
{{ profile.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_country|country_name }}{% if profile.user_age > 0 %}, {{ profile.user_age }} year{{ profile.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 is defined and profile_relation_info|length > 0 and (profile_relation_info.subject_relation is not null or profile_relation_info.user_relation is not null) %}
<div class="profile__header__details__relation" title="Since {{ profile_relation_info.relation_created|date('r') }}">
{% if profile_relation_info.subject_relation and profile_relation_info.user_relation %}
Mutual Friends
{% elseif profile_relation_info.user_relation %}
You Follow
{% elseif profile_relation_info.subject_relation %}
Follows You
{% endif %}
</div>
{% endif %}
</div>
<div class="profile__header__options">
{% if profile 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_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_id}) }}" class="input__button profile__header__action">Edit Profile</a>
{% endif %}
{% if current_user is defined and current_user.user_id != profile.user_id and not profile_is_editing %}
{% if profile_relation_info.user_relation == constant('MSZ_USER_RELATION_FOLLOW') %}
<a href="{{ url('user-relation-none', {'user': profile.user_id}) }}" class="input__button input__button--destroy profile__header__action js-user-relation-action" data-relation-user="{{ profile.user_id }}" data-relation-type="{{ constant('MSZ_USER_RELATION_NONE') }}">Unfollow</a>
{% else %}
<a href="{{ url('user-relation-follow', {'user': profile.user_id}) }}" class="input__button profile__header__action js-user-relation-action" data-relation-user="{{ profile.user_id }}" data-relation-type="{{ constant('MSZ_USER_RELATION_FOLLOW') }}">Follow</a>
{% endif %}
{% endif %}
{% else %}
<a href="{{ url('user-profile', {'user': profile.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>