frontend
Technical notes on web development, DevOps, and AI integration.
47 articles
- 07:42frontend
Per-Diagram Default Zoom, Stored in a Data Attribute
Each diagram carries its initial zoom in a data-zoom attribute; a generic toolbar reads it once at init, no per-diagram branches.
TL;DR: A module map SVG kept loading at 100% zoom, forcing manual resizing, but a shared 50% default would break other drawings. The fix: the generator emits a data-zoom attribute per diagram, and the toolbar reads it to apply the right scale and width. This keeps content-specific defaults in the generator, not shared code, and extends to other initial states.
#mermaid#javascript#css - 02:27frontend
fetch Rejected on file://, Search Becomes a Script
A fetch for a neighboring JSON file fails under file:// because local origins are opaque. The search index ships as a script file and IndexedDB stores it.
TL;DR: Browsers treat local files as opaque origins, so fetch can't load a JSON file opened via file://. The fix ships the search index as a JavaScript file assigning a global, loads it with a script tag, and caches it in IndexedDB, re-seeding when a captured_at version changes. A build audit also fails if any screenshot lacks a caption.
#frontend#javascript#documentation - 00:40frontend
Deep-Link Video in Mega Menu: URL, State, Preload Done Right
Three URL layers for mega menu video deep-links: path for identity, query for panel state, hash for timestamp. Manual sync of video.currentTime to hash. Preload metadata + poster, not auto. Prefetch route on hover, not auto.
TL;DR: Use path segments for video identity, query strings for panel state, and hash fragments for timestamps to create bookmarkable URLs. React Activity preserves component state but not video playback, so manually sync currentTime with the hash on mount and timeupdate. For mega panels, set preload="metadata" with posters and manually prefetch on hover since hidden elements skip automatic prefetching.
#frontend#performance#nextjs - 00:44frontend
Why Popular Video Cards Have No Thumbnails
Popular marquee cards checked explicit thumbnails, leaving video items on gradients. Fix: explicit thumbnail → i.ytimg hqdefault → gradient. hqdefault always exists for public videos.
TL;DR: Video items showed a gradient placeholder. A fallback chain was added to display thumbnails. It uses YouTube's image CDN for video thumbnails.
#frontend#performance#nextjs - 00:36frontend
Why the "Popular" Marquee Across Three Pillars Looks Empty — and How to Fill It
Marquee populer 3 pilar (olahraga/kebudayaan/kepemudaan) kosong di pilar muda. Fix: parallel fetch popular + random, mergePopularWithRandom dedupe by id, popular priority, slice 9.
TL;DR: KotaPortal's marquee looked half-empty. Server-side parallel fetch and merge dedupe fixed this. Young pillars now display 9 items.
#frontend#performance#nextjs - 10:43frontend
The Validation Gate Before Third-Party Photos Enter a Grid
Name matching first, image checked after load, revert when in doubt: the validation gate that keeps third-party photos from poisoning a public grid.
TL;DR: Images were missing from a culture grid. Entity data was healthy, but image supply was the issue. A solution was found, but with limitations and a need for further verification.
#data-quality#api#frontend - 23:05testing
Writing E2E Tests for a Page That Postpones Its Fetch
A 52-line E2E spec for a listing page that debounces 350 ms: zero waitForTimeout, assertions that retry on their own, and five data-testid hooks.
TL;DR: The listing page debounces client fetch by 350 milliseconds. Playwright's automatic retry replaces waitForTimeout. The test uses a 10-second assertion timeout.
#playwright#testing#typescript - 22:48frontend
Three 7-Line Routes, One 471-Line Component
The Kelembagaan admin module: three 7-14 line server routes, one 471-line client editor, a 350 ms debounced list, and an id guard that throws 404.
TL;DR: Commit c50f35b adds the Kelembagaan module. It includes organization list and edit forms with validation. Validation occurs on the server side for security.
#nextjs#react#typescript - 23:29backend
Two Sets: What You May Read, What You May Manage
Opening read access across departments without loosening writes: readable and manageable module sets as two separate fail-closed sets.
TL;DR: KotaPortal treated the module query parameter as a write gate, hiding all content from other departments. The fix splits access into two sets: ModulesFor for writable modules and ReadableModules for readable ones, with fail-closed checks moved earlier in the chain. The frontend keeps full navigation while write affordances hide per permission, marked by a read-only banner.
#rbac#golang#http