feat(funbox): add tunnel vision effect (@d1rshan)#7959
Draft
d1rshan wants to merge 10 commits into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a new “tunnel_vision” funbox mode and wires it through schema validation, funbox metadata, frontend behavior, and styling.
Changes:
- Added
tunnel_visionto the sharedFunboxNameSchemaenum and updated schema tests. - Registered
tunnel_visionin the funbox metadata list with CSS + frontend hooks. - Implemented caret-position-driven CSS masking plus a small caret behavior tweak to support the effect.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/schemas/src/configs.ts | Adds tunnel_vision to the funbox name enum. |
| packages/schemas/tests/config.spec.ts | Extends schema tests to cover the new funbox enum value. |
| packages/funbox/src/list.ts | Registers tunnel_vision metadata (properties, hooks, css modifications). |
| frontend/static/funbox/tunnel_vision.css | Introduces the CSS mask effect driven by caret-position CSS variables. |
| frontend/src/ts/test/funbox/funbox-functions.ts | Implements observer + rAF update loop to keep caret-position CSS vars current. |
| frontend/src/ts/elements/caret.ts | Allows main caret updates even when caret style is “off”. |
| frontend/tests/test/funbox/funbox-validation.spec.ts | Extends validation coverage list for the new funbox. |
| attributes: true, | ||
| attributeFilter: ["class", "style"], | ||
| }); | ||
| window.addEventListener("resize", requestCaretPositionUpdate); |
Comment on lines
+1
to
+13
| #words { | ||
| /* em keeps the visible area proportional to the current typing font size. */ | ||
| --tunnel-vision-radius: 3em; | ||
| --tunnel-vision-softness: 0.8em; | ||
|
|
||
| mask-image: radial-gradient( | ||
| circle at var(--caret-center-x, 50%) var(--caret-center-y, 50%), | ||
| #000 0, | ||
| #000 var(--tunnel-vision-radius), | ||
| transparent | ||
| calc(var(--tunnel-vision-radius) + var(--tunnel-vision-softness)) | ||
| ); | ||
| } |
| if (tunnelVisionFrame !== undefined) { | ||
| cancelAnimationFrame(tunnelVisionFrame); | ||
| tunnelVisionFrame = undefined; | ||
| } |
| }; | ||
| }): void { | ||
| if (this.style === "off") return; | ||
| if (this.style === "off" && !this.isMainCaret) return; |
Comment on lines
+78
to
+98
| function requestCaretPositionUpdate(): void { | ||
| if (tunnelVisionFrame !== undefined) return; | ||
| tunnelVisionFrame = requestAnimationFrame(() => { | ||
| tunnelVisionFrame = undefined; | ||
|
|
||
| const caret = document.getElementById("caret"); | ||
| const words = document.getElementById("words"); | ||
| if (caret === null || words === null) return; | ||
|
|
||
| const caretRect = caret.getBoundingClientRect(); | ||
| const wordsRect = words.getBoundingClientRect(); | ||
| words.style.setProperty( | ||
| "--caret-center-x", | ||
| `${caretRect.left + caretRect.width / 2 - wordsRect.left}px`, | ||
| ); | ||
| words.style.setProperty( | ||
| "--caret-center-y", | ||
| `${caretRect.top + caretRect.height / 2 - wordsRect.top}px`, | ||
| ); | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds a funbox effect 'tunnel vision' - only the area around caret will be visible.