[UI][TWIG] Small UI cleanup and change twig 'active' function to check for starts with, rather than equals

This commit is contained in:
Hugo Sales 2020-08-21 15:32:14 +00:00 committed by Hugo Sales
parent 57297aba56
commit 43665749bb
4 changed files with 5 additions and 7 deletions

View File

@ -49,9 +49,6 @@ class NetworkPublic extends Controller
);
$attachments[] = $a;
}
if ($notes === []) {
$notes = null;
}
return [
'_template' => 'network/public.html.twig',
'notes' => $notes,

View File

@ -30,6 +30,7 @@
namespace App\Twig;
use App\Util\Formatting;
use Functional as F;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Request;
@ -52,7 +53,7 @@ class Runtime implements RuntimeExtensionInterface, EventSubscriberInterface
public function isCurrentRoute(string $class, string ...$routes): string
{
$current_route = $this->request->attributes->get('_route');
return F\some($routes, F\equal($current_route)) ? $class : '';
return F\some($routes, F\partial_left([Formatting::class, 'startsWith'], $current_route)) ? $class : '';
}
// ----------------------------------------------------------

View File

@ -30,7 +30,7 @@
<a href='#'><i> #{{ tag }} </i></a>
{% endfor %}
{% else %}
<i> {{ '(None)' | trans }} </i>
<i> {{ '(No tags)' | trans }} </i>
{% endif %}
</div>
<div class="stats">
@ -46,7 +46,7 @@
<a href='#'>Replies</a>
<a href='#'>Favourites</a>
<a href='#'>Reverse Favs</a>
<a href="{{ path('settings_personal_info') }}" class='hover-effect {% if app.request.attributes.get('_route') starts with 'settings_' %}active{% endif %}'>Settings</a>
<a href="{{ path('settings_personal_info') }}" class='hover-effect {{ active('settings_') }}'>Settings</a>
<a href='#'>Logout</a>
</div>
<div class="footer">

View File

@ -59,7 +59,7 @@
{% endif %}
<div class="timeline-nav">
<div class="notes">
{% if notes is defined %}
{% if notes is defined and notes is not empty %}
{% for note in notes %}
<div>
<img src="{{ note.getAvatarUrl() }}" alt="{{ note.getActorNickname() }}'s avatar" width="64px">