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:
eric.busandClaude Opus 5.5 committed 2026-11-24 11:48:50 +01:00
1 parent f7b1dbac8f
commit df8c8a9c4f
10 files changed
+325 -32

No files matched your search

+64 -3
View File
@@ -199,6 +199,65 @@ div.pp_default .pp_close:hover {
color: var(--brand-dark); color: var(--brand-dark);
} }
.tags_more {
position: relative;
}
.tags_more .tags_more_toggle {
cursor: pointer;
}
.tags_more .tags_more_list {
display: flex;
position: absolute;
right: 0;
top: 100%;
z-index: 30;
flex-wrap: wrap;
justify-content: flex-end;
gap: 4px;
width: max-content;
max-width: 240px;
margin: 0;
padding: 6px;
list-style: none;
border-radius: 12px;
background-color: var(--brand-surface);
box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
visibility: hidden;
opacity: 0;
transition: opacity 0.15s ease 0.35s, visibility 0s linear 0.5s;
}
.tags_more .tags_more_list li {
float: none;
margin: 0;
}
@media (hover: hover) {
.tags_more:hover .tags_more_list, .tags_more:focus-within .tags_more_list {
visibility: visible;
opacity: 1;
transition-delay: 0s;
}
}
.tags_more.open .tags_more_list {
visibility: visible;
opacity: 1;
transition-delay: 0s;
}
.tags_more--left .tags_more_list {
right: auto;
left: 0;
justify-content: flex-start;
}
.slider_content_box .tags_more .tags_more_list {
top: auto;
bottom: 100%;
}
.blog .post .post_tags {
margin: 12px 0 6px;
}
.list { .list {
margin: 0; margin: 0;
padding: 0; padding: 0;
@@ -1839,7 +1898,10 @@ h2.box_header span {
margin: 0; margin: 0;
padding: 0; padding: 0;
list-style: none; list-style: none;
height: 31px; position: relative;
display: flex;
flex-wrap: wrap;
gap: 6px 10px;
margin: 20px 0; margin: 20px 0;
} }
.post_tags a { .post_tags a {
@@ -1847,8 +1909,7 @@ h2.box_header span {
color: var(--brand-dark); color: var(--brand-dark);
} }
.post_tags li { .post_tags li {
float: left; margin: 0;
margin-right: 10px;
} }
.share_buttons .btn { .share_buttons .btn {
width: 100%; width: 100%;
+65
View File
@@ -325,3 +325,68 @@ $(function () {
$(this).tabs($(this).data('tabs') ?? {}); $(this).tabs($(this).data('tabs') ?? {});
}); });
}); });
/*
* "+N" tag with the remaining categories of a news item
* (partial/tag_list.blade.php). On desktop the list opens on hover / keyboard
* focus (CSS); on touch screens a tap on "+N" toggles it. A tap or click
* elsewhere, or Escape, closes it.
*/
(function () {
// The list normally extends to the left from "+N". When there isn't enough
// room for that (e.g. "+N" on the left of a second line on mobile), let it
// extend to the right instead.
function place(more) {
var list = more.querySelector('.tags_more_list');
if (!list) {
return;
}
more.classList.remove('tags_more--left');
var boundary = more.closest('.post, .box');
var minLeft = Math.max(boundary ? boundary.getBoundingClientRect().left : 0, 0);
if (list.getBoundingClientRect().left < minLeft) {
more.classList.add('tags_more--left');
}
}
function placeFromEvent(event) {
var more = event.target.closest ? event.target.closest('.tags_more') : null;
if (more && !more.contains(event.relatedTarget)) {
place(more);
}
}
document.addEventListener('mouseover', placeFromEvent);
document.addEventListener('focusin', placeFromEvent);
function closeAll(except) {
var open = document.querySelectorAll('.tags_more.open');
for (var i = 0; i < open.length; i++) {
if (open[i] !== except) {
open[i].classList.remove('open');
open[i].querySelector('.tags_more_toggle').setAttribute('aria-expanded', 'false');
}
}
}
document.addEventListener('click', function (event) {
var toggle = event.target.closest ? event.target.closest('.tags_more_toggle') : null;
if (toggle) {
event.preventDefault();
var more = toggle.closest('.tags_more');
place(more);
var isOpen = more.classList.toggle('open');
toggle.setAttribute('aria-expanded', isOpen ? 'true' : 'false');
closeAll(more);
return;
}
if (!(event.target.closest && event.target.closest('.tags_more_list'))) {
closeAll(null);
}
});
document.addEventListener('keydown', function (event) {
if (event.key === 'Escape') {
closeAll(null);
}
});
})();
+64
View File
@@ -0,0 +1,64 @@
/*
* "+N" tag with the remaining categories of a news item
* (partial/tag_list.blade.php). On desktop the list opens on hover / keyboard
* focus (CSS); on touch screens a tap on "+N" toggles it. A tap or click
* elsewhere, or Escape, closes it.
*/
(function () {
// The list normally extends to the left from "+N". When there isn't enough
// room for that (e.g. "+N" on the left of a second line on mobile), let it
// extend to the right instead.
function place(more) {
var list = more.querySelector('.tags_more_list');
if (!list) {
return;
}
more.classList.remove('tags_more--left');
var boundary = more.closest('.post, .box');
var minLeft = Math.max(boundary ? boundary.getBoundingClientRect().left : 0, 0);
if (list.getBoundingClientRect().left < minLeft) {
more.classList.add('tags_more--left');
}
}
function placeFromEvent(event) {
var more = event.target.closest ? event.target.closest('.tags_more') : null;
if (more && !more.contains(event.relatedTarget)) {
place(more);
}
}
document.addEventListener('mouseover', placeFromEvent);
document.addEventListener('focusin', placeFromEvent);
function closeAll(except) {
var open = document.querySelectorAll('.tags_more.open');
for (var i = 0; i < open.length; i++) {
if (open[i] !== except) {
open[i].classList.remove('open');
open[i].querySelector('.tags_more_toggle').setAttribute('aria-expanded', 'false');
}
}
}
document.addEventListener('click', function (event) {
var toggle = event.target.closest ? event.target.closest('.tags_more_toggle') : null;
if (toggle) {
event.preventDefault();
var more = toggle.closest('.tags_more');
place(more);
var isOpen = more.classList.toggle('open');
toggle.setAttribute('aria-expanded', isOpen ? 'true' : 'false');
closeAll(more);
return;
}
if (!(event.target.closest && event.target.closest('.tags_more_list'))) {
closeAll(null);
}
});
document.addEventListener('keydown', function (event) {
if (event.key === 'Escape') {
closeAll(null);
}
});
})();
+1
View File
@@ -6,6 +6,7 @@
@use "../components/button"; @use "../components/button";
@use "../components/pretty_photo"; @use "../components/pretty_photo";
@use "../components/cookie"; @use "../components/cookie";
@use "../components/tags";
@use "../components/list"; @use "../components/list";
@use "../components/banners"; @use "../components/banners";
@use "../components/contact_form"; @use "../components/contact_form";
+7 -3
View File
@@ -140,7 +140,12 @@
.post_tags { .post_tags {
@include reset-list; @include reset-list;
height: 31px; // Grows with the tags when they wrap onto a second line (was a fixed 31px
// height with floats); the '+N' list (components/_tags.scss) opens below it
position: relative;
display: flex;
flex-wrap: wrap;
gap: 6px 10px;
margin: 20px 0; margin: 20px 0;
a { a {
@@ -150,8 +155,7 @@
} }
li { li {
float: left; margin: 0;
margin-right: 10px;
a { a {
@extend %post-tags-link @extend %post-tags-link
+81
View File
@@ -0,0 +1,81 @@
// "+N" tag that opens the remaining categories of a news item
// (partial/tag_list.blade.php, resources/assets/js/functions/tags.js).
// The list is attached to the "+N" tag itself (right-aligned, extending to the
// left), so the mouse can move straight from "+N" into the list.
.tags_more {
position: relative;
.tags_more_toggle {
cursor: pointer;
}
.tags_more_list {
display: flex;
position: absolute;
right: 0;
top: 100%;
z-index: 30;
flex-wrap: wrap;
justify-content: flex-end;
gap: 4px;
width: max-content;
max-width: 240px;
margin: 0;
padding: 6px;
list-style: none;
border-radius: 12px;
background-color: var(--brand-surface);
box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
// Hidden by default. Closing is delayed a little, so a diagonal mouse move
// from "+N" to a category further away doesn't close the list on the way.
visibility: hidden;
opacity: 0;
transition: opacity 0.15s ease 0.35s, visibility 0s linear 0.5s;
li {
float: none;
margin: 0;
}
}
// Devices with a mouse: open on hover and on keyboard focus (focus-within
// keeps it open while tabbing through the hidden tags). Not on touch screens:
// a tap would trigger a fake hover/focus there, so only a tap (.open, set by
// tags.js) opens and closes it.
@media (hover: hover) {
&:hover .tags_more_list,
&:focus-within .tags_more_list {
visibility: visible;
opacity: 1;
transition-delay: 0s;
}
}
&.open .tags_more_list {
visibility: visible;
opacity: 1;
transition-delay: 0s;
}
}
// Not enough room to the left of "+N" (set by tags.js): extend to the right
.tags_more--left .tags_more_list {
right: auto;
left: 0;
justify-content: flex-start;
}
// Homepage cards: the tags sit on the bottom edge of the image and the card
// clips anything outside it, so the list opens upwards over the image
.slider_content_box .tags_more .tags_more_list {
top: auto;
// Directly against "+N": a gap would close the list while moving the mouse to it
bottom: 100%;
}
// News overview cards (e.g. /nieuws/tag/...): a bit less space than on the article page
.blog .post .post_tags {
margin: 12px 0 6px;
}
+3 -18
View File
@@ -24,12 +24,7 @@ Home
</a> </a>
<div class="slider_content_box"> <div class="slider_content_box">
<ul class="post_details simple"> <ul class="post_details simple">
@foreach($item->tags as $tag) @include('partial/tag_list', ['tags' => $item->tags, 'itemClass' => 'category', 'linkClass' => 'over_image'])
<li class="category">
<a title="{{$tag->titel}}" href="{{route('nieuws.tag', ['tag' => $tag->slug])}}"
class="over_image">{{$tag->titel}}</a>
</li>
@endforeach
</ul> </ul>
<h2><a href="{{url($item->url)}}" title="{{$item->title}}">{!!$item->title!!}</a></h2> <h2><a href="{{url($item->url)}}" title="{{$item->title}}">{!!$item->title!!}</a></h2>
<?php <?php
@@ -59,12 +54,7 @@ Home
</a> </a>
<div class="slider_content_box"> <div class="slider_content_box">
<ul class="post_details simple"> <ul class="post_details simple">
@foreach($item->tags as $tag) @include('partial/tag_list', ['tags' => $item->tags, 'itemClass' => 'category', 'linkClass' => 'over_image'])
<li class="category">
<a title="{{$tag->titel}}" href="{{route('nieuws.tag', ['tag' => $tag->slug])}}"
class="over_image">{{$tag->titel}}</a>
</li>
@endforeach
</ul> </ul>
<h2><a href="{{url($item->url)}}" title="{{$item->title}}">{!!$item->title!!}</a></h2> <h2><a href="{{url($item->url)}}" title="{{$item->title}}">{!!$item->title!!}</a></h2>
<?php <?php
@@ -98,12 +88,7 @@ Home
</a> </a>
<div class="slider_content_box"> <div class="slider_content_box">
<ul class="post_details simple"> <ul class="post_details simple">
@foreach($item->tags as $tag) @include('partial/tag_list', ['tags' => $item->tags, 'itemClass' => 'category', 'linkClass' => 'over_image'])
<li class="category">
<a title="{{$tag->titel}}" href="{{route('nieuws.tag', ['tag' => $tag->slug])}}"
class="over_image">{{$tag->titel}}</a>
</li>
@endforeach
</ul> </ul>
<h5 class="post_title"><a href="{{url($item->url)}}" <h5 class="post_title"><a href="{{url($item->url)}}"
title="{{$item->title}}">{!!$item->title!!}</a></h5> title="{{$item->title}}">{!!$item->title!!}</a></h5>
+1 -3
View File
@@ -27,9 +27,7 @@
@section('tags') @section('tags')
<ul class="post_tags"> <ul class="post_tags">
@foreach($news->tags as $tag) @include('partial/tag_list', ['tags' => $news->tags])
<li><a href="{{route('nieuws.tag', $tag->slug)}}" title="{{$tag->titel}}">{{$tag->titel}}</a></li>
@endforeach
</ul> </ul>
@endsection @endsection
+5 -5
View File
@@ -47,15 +47,15 @@
<img src='{{$item->images && count($item->images) ? $imgBase . $item->images[0]->url : '/images/noimage.svg'}}' <img src='{{$item->images && count($item->images) ? $imgBase . $item->images[0]->url : '/images/noimage.svg'}}'
alt='img'> alt='img'>
</a> </a>
@if($item->tags)
<ul class="post_tags">
@include('partial/tag_list', ['tags' => $item->tags])
</ul>
@endif
<h2 class="post_title"><a href="{{url($item->url)}}" <h2 class="post_title"><a href="{{url($item->url)}}"
title="{{strip_tags($item->title)}}">{!!$item->title!!}</a> title="{{strip_tags($item->title)}}">{!!$item->title!!}</a>
</h2> </h2>
<ul class="post_details clearfix"> <ul class="post_details clearfix">
@foreach($item->tags as $tag)
<li class="detail category"><i class="fa-solid fa-location-dot"></i> <a
href="{{route('nieuws.tag', $tag->slug)}}"
title="{{$tag->titel}}">{{$tag->titel}}</a></li>
@endforeach
@if($item->edited && ($item->edited != $item->published)) @if($item->edited && ($item->edited != $item->published))
<li class="date edited"> <li class="date edited">
<i class="fa-regular fa-clock"></i> <i class="fa-regular fa-clock"></i>
@@ -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