Scrollable, SPA-navigated filter bar with all languages
Removes the 12-chip cap on the language filter so every language that appears in public content is listed (video 175 alone contributes 12). The bar wrapper is now sticky and horizontally scrollable with chevron buttons that appear only when the bar overflows in that direction, a gradient fade behind each button, vertical-wheel → horizontal scroll that hands off to the page at the edges, and sessionStorage-persisted scroll position so navigation doesn't snap it back to the start. Chip clicks are intercepted (only for /videos URLs; Trending/Shorts still render different templates via a normal navigation) and swap only the #filter-content region via fetch + DOMParser, updating history.pushState, document.title, and active-chip state without a full page reload. Modifier-clicks and middle-clicks fall through to native "open in new tab" behaviour. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This commit is contained in:
1 parent
847020fd02
commit
da714958c6
3 files changed
+181
-9
No files matched your search
@@ -139,9 +139,11 @@ class VideoController extends Controller
|
||||
/**
|
||||
* Distinct languages currently present in public content, sorted by how
|
||||
* many videos each covers (primary + secondary tracks combined). Returned
|
||||
* as [ ['code'=>'ja','flag'=>'jp','name'=>'Japanese','count'=>N], ... ]
|
||||
* as [ ['code'=>'ja','flag'=>'jp','name'=>'Japanese','count'=>N], ... ].
|
||||
* Pass a $limit only if the caller wants a preview; the bar itself is
|
||||
* horizontally scrollable so the default is uncapped.
|
||||
*/
|
||||
protected function buildLanguageChips(int $limit = 12): array
|
||||
protected function buildLanguageChips(?int $limit = null): array
|
||||
{
|
||||
$publicIds = \App\Models\Video::public()->pluck('id');
|
||||
if ($publicIds->isEmpty()) return [];
|
||||
@@ -178,7 +180,7 @@ class VideoController extends Controller
|
||||
if (! $flag) continue; // skip unknown codes
|
||||
$name = \App\Data\Languages::all()[$code]['name'] ?? strtoupper($code);
|
||||
$chips[] = ['code' => $code, 'flag' => $flag, 'name' => $name, 'count' => $count];
|
||||
if (count($chips) >= $limit) break;
|
||||
if ($limit !== null && count($chips) >= $limit) break;
|
||||
}
|
||||
return $chips;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user