AlbumButtonBox: add way for users to select an album filter

This commit is contained in:
2024-01-14 21:28:45 +01:00
parent 6a25ecec23
commit 99b867b241
3 changed files with 59 additions and 27 deletions

View File

@@ -8,11 +8,15 @@
class AlbumButtonBox extends Template
{
private $active_filter;
private $buttons;
private $filters;
public function __construct($buttons)
public function __construct(array $buttons, array $filters, $active_filter)
{
$this->active_filter = $active_filter;
$this->buttons = $buttons;
$this->filters = $filters;
}
public function html_main()
@@ -25,6 +29,25 @@ class AlbumButtonBox extends Template
<a class="btn btn-light" href="', $button['url'], '">', $button['caption'], '</a>';
echo '
<div class="dropdown">
<button class="btn btn-light dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
<i class="bi bi-filter"></i>
</button>
<ul class="dropdown-menu">';
foreach ($this->filters as $key => $filter)
{
$is_active = $key === $this->active_filter;
echo '
<li><a class="dropdown-item', $is_active ? ' active' : '',
'" href="', $filter['link'], '">',
$filter['caption'],
'</a></li>';
}
echo '
</ul>
</div>
</div>';
}
}