Show at most 4 categories, the rest behind a '+N' tag
- New partial/tag_list: first 4 categories, then a '+N' tag that opens the remaining ones (hover/keyboard on desktop, tap on touch screens; short close delay so the mouse can reach the list) - Used on the homepage, the article page and the news overview / tag pages (the latter now use the same pills instead of text links) - Article page: tag row grows when the tags wrap (was a fixed height) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f7b1dbac8f
commit
df8c8a9c4f
10 files changed
+325
-32
No files matched your search
@@ -0,0 +1,34 @@
|
||||
{{--
|
||||
Category tags of a news item as <li> elements (place inside a <ul>).
|
||||
Shows at most $max tags; the rest is behind a "+N" tag that opens a list
|
||||
on hover, keyboard focus or tap (see resources/assets/js/functions/tags.js).
|
||||
|
||||
Parameters:
|
||||
$tags the tags (objects with ->titel and ->slug)
|
||||
$max number of visible tags (default 4)
|
||||
$itemClass class for each <li> (e.g. 'category' on the homepage)
|
||||
$linkClass class for each <a>
|
||||
--}}
|
||||
@php
|
||||
$tags = is_array($tags ?? null) ? $tags : [];
|
||||
$max = $max ?? 4;
|
||||
$itemClass = $itemClass ?? '';
|
||||
$linkClass = $linkClass ?? '';
|
||||
$visible = array_slice($tags, 0, $max);
|
||||
$hidden = array_slice($tags, $max);
|
||||
@endphp
|
||||
@foreach($visible as $tag)
|
||||
<li class="{{ $itemClass }}"><a class="{{ $linkClass }}" href="{{ route('nieuws.tag', ['tag' => $tag->slug]) }}" title="{{ $tag->titel }}">{{ $tag->titel }}</a></li>
|
||||
@endforeach
|
||||
@if($hidden)
|
||||
<li class="{{ $itemClass }} tags_more">
|
||||
<a class="{{ $linkClass }} tags_more_toggle" href="#" role="button" aria-expanded="false"
|
||||
title="Nog {{ count($hidden) }} categorieën"
|
||||
aria-label="Nog {{ count($hidden) }} categorieën: {{ implode(', ', array_map(function ($tag) { return $tag->titel; }, $hidden)) }}">+{{ count($hidden) }}</a>
|
||||
<ul class="tags_more_list">
|
||||
@foreach($hidden as $tag)
|
||||
<li class="{{ $itemClass }}"><a class="{{ $linkClass }}" href="{{ route('nieuws.tag', ['tag' => $tag->slug]) }}" title="{{ $tag->titel }}">{{ $tag->titel }}</a></li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</li>
|
||||
@endif
|
||||
Reference in new issue
Block a user