Commit fab348b8 authored by Emma's avatar Emma 👽

fix missing active class on page >1 user page tabs

parent 1e5b9645
{% from _self import tab %}
{% macro tab(path, label) %}
{% with { active: app.request.baseUrl ~ app.request.pathInfo == path } %}
<li class="tabs__tab {{ active ? 'tabs__tab--active' }}">
<a href="{{ path }}" class="tabs__link {{ active ? 'tabs__link--active' }}">{{ label }}</a>
</li>
{% endwith %}
{% endmacro %}
<nav class="tabs user-nav">
<ul class="tabs__bar">
{{ tab(path('user', {username: user.username}), 'label.overview'|trans) }}
{{ tab(path('user_submissions', {username: user.username}), 'user.submissions'|trans) }}
{{ tab(path('user_comments', {username: user.username}), 'user.comments'|trans) }}
{% for tab in [
{ path: 'user', label: 'label.overview' },
{ path: 'user_submissions', label: 'user.submissions' },
{ path: 'user_comments', label: 'user.comments' },
] %}
<li class="tabs__tab {{ tab.path == current ? 'tabs__tab--active' }}">
<a href="{{ path(tab.path, {username: user.username}) }}"
class="tabs__link {{ tab.path == current ? 'tabs__link--active' }}">
{{- tab.label|trans -}}
</a>
</li>
{% endfor %}
</ul>
</nav>
......@@ -6,16 +6,12 @@
{{ include('_includes/meta_pagination.html.twig', {pager: comments}) }}
{% endblock %}
{% block page_classes %}
user-comments-page
{% endblock %}
{% block page_classes 'user-comments-page' %}
{% block title %}
{{ 'user.comments'|trans }}
{% endblock %}
{% block title 'user.comments'|trans %}
{% block body %}
{{ include('user/_nav.html.twig', {user: user}, with_context=false) }}
{{ include('user/_nav.html.twig', {current: 'user_comments', user: user}, with_context=false) }}
<h1 class="page-heading">{{ block('title') }}</h1>
......@@ -23,5 +19,5 @@
{{ comment(comment, {recurse: false}) }}
{% endfor %}
{{ include('_includes/pagination.html.twig', { pager: comments }) }}
{{ include('_includes/pagination.html.twig', {pager: comments}, with_context=false) }}
{% endblock %}
......@@ -6,16 +6,12 @@
{{ include('_includes/meta_pagination.html.twig', {pager: submissions}) }}
{% endblock %}
{% block page_classes %}
user-submissions-page
{% endblock %}
{% block page_classes 'user-submissions-page' %}
{% block title %}
{{ 'user.submissions'|trans }}
{% endblock %}
{% block title 'user.submissions'|trans %}
{% block body %}
{{ include('user/_nav.html.twig', {user: user}, with_context=false) }}
{{ include('user/_nav.html.twig', {current: 'user_submissions', user: user}, with_context=false) }}
<h1 class="page-heading">{{ block('title') }}</h1>
......@@ -23,6 +19,5 @@
{{ submission(submission) }}
{% endfor %}
{{ include('_includes/pagination.html.twig', {pager: submissions}) }}
{{ include('_includes/pagination.html.twig', {pager: submissions}, with_context=false) }}
{% endblock %}
......@@ -4,14 +4,12 @@
{% from 'comment/_macros.html.twig' import comment %}
{% from _self import timestamp %}
{% block title %}{{ user.username }}{% endblock %}
{% block title user.username %}
{% block page_classes %}
user-page
{% endblock %}
{% block page_classes 'user-page' %}
{% block body %}
{{ include('user/_nav.html.twig', {user: user}, with_context=false) }}
{{ include('user/_nav.html.twig', {current: 'user', user: user}, with_context=false) }}
<h1 class="page-heading">{{ user.username }}</h1>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment