chg: [notifications] Slightly improved UI

pull/93/head
Sami Mokaddem 2022-02-09 09:30:59 +01:00
parent a77e29fa38
commit e67c711935
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
1 changed files with 10 additions and 8 deletions

View File

@ -10,6 +10,7 @@ $severity = [
'danger' => 2, 'danger' => 2,
]; ];
$maxSeverity = -1; $maxSeverity = -1;
$hasNotification = !empty($notifications);
$notificationVariants = Hash::extract($notifications, '{n}.variant'); $notificationVariants = Hash::extract($notifications, '{n}.variant');
foreach ($notificationVariants as $notifVariant) { foreach ($notificationVariants as $notifVariant) {
$maxSeverity = max($maxSeverity, $severity[$notifVariant] ?? 0); $maxSeverity = max($maxSeverity, $severity[$notifVariant] ?? 0);
@ -20,21 +21,22 @@ $variant = array_flip($severity)[$maxSeverity];
<a class="nav-link px-2 text-decoration-none profile-button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" href="#" data-bs-offset="10,20"> <a class="nav-link px-2 text-decoration-none profile-button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" href="#" data-bs-offset="10,20">
<span class="position-relative"> <span class="position-relative">
<i class="<?= $this->FontAwesome->getClass('bell') ?> fa-lg"></i> <i class="<?= $this->FontAwesome->getClass('bell') ?> fa-lg"></i>
<?= <?php
$this->Bootstrap->notificationBubble([ if ($hasNotification) {
'class' => empty($notifications) ? 'd-none' : '', echo $this->Bootstrap->notificationBubble([
'variant' => $variant, 'variant' => $variant,
]) ]);
}
?> ?>
</span> </span>
</a> </a>
<div class="dropdown-menu dropdown-menu-end" style="min-width: 320px; max-width: 25vw"> <div class="dropdown-menu dropdown-menu-end" style="min-width: 320px; max-width: 25vw; max-height: 50vh; overflow-y: auto;">
<h6 class="dropdown-header d-flex justify-content-between"> <h6 class="dropdown-header d-flex justify-content-between">
<span><?= __n('{0} Notification', '{0} Notifications', count($notifications), count($notifications)) ?></span> <span><?= __n('{0} Notification', '{0} Notifications', count($notifications), count($notifications)) ?></span>
</h6> </h6>
<?php if (empty($notifications)) : ?> <?php if (empty($notifications)) : ?>
<span class="dropdown-item-text text-nowrap user-select-none text-center"> <span class="dropdown-item-text text-nowrap user-select-none text-center fs-7">
<?= __('- No notification -') ?> <?= __('You don\'t have notifications at the moment') ?>
<span> <span>
<?php else : ?> <?php else : ?>
<?php foreach ($notifications as $notification) : ?> <?php foreach ($notifications as $notification) : ?>