Architecture
Simple. One hook, one template, one CSS gradient, one JS event listener.
Hook
db/hooks.php registers callback on after_standard_main_region_html_generation.
hook_callbacks::after_standard_main_region_html_generation():
- Checks
local_lumens/enabledconfig. - Checks
local/lumens:usecapability. - Renders
flashlightoutput class.
Flashlight Class
classes/output/flashlight.php is a named_templatable renderable. Uses template local_lumens/flashlight.
Template
templates/flashlight.mustache has three parts:
Div
<div id="local_lumens_flashlight" aria-hidden="true"></div>CSS
Fixed overlay, full viewport, z-index 9999999999 (basically on top of everything).
pointer-events: none — clicks pass through to page below.
Radial gradient creates the flashlight:
background: radial-gradient(
circle var(--flashlight-size) at var(--flashlight-x) var(--flashlight-y),
rgba(0, 0, 0, 0) 0%, /* center: fully transparent */
rgba(0, 0, 0, 0) 5%, /* still transparent */
rgba(0, 0, 0, 0.95) 100% /* edge: almost black */
);CSS custom properties control position and size:
--flashlight-x,--flashlight-y— cursor position in px--flashlight-size— circle radius (default12.5vmax)
JS
Mouse tracking:
- On page load, check
sessionStoragefor saved position. mousemovelistener updates--flashlight-xand--flashlight-y.navigation.addEventListener("navigate", ...)saves position tosessionStoragebefore page unload.
Position persists per tab session (sessionStorage, not localStorage).