Skip to content

feat(funbox): add tunnel vision effect (@d1rshan)#7959

Draft
d1rshan wants to merge 10 commits into
monkeytypegame:masterfrom
d1rshan:funbox-tunnel-vision
Draft

feat(funbox): add tunnel vision effect (@d1rshan)#7959
d1rshan wants to merge 10 commits into
monkeytypegame:masterfrom
d1rshan:funbox-tunnel-vision

Conversation

@d1rshan
Copy link
Copy Markdown
Contributor

@d1rshan d1rshan commented May 15, 2026

Description

This PR adds a funbox effect 'tunnel vision' - only the area around caret will be visible.

Copilot AI review requested due to automatic review settings May 15, 2026 17:19
@monkeytypegeorge monkeytypegeorge added frontend User interface or web stuff assets Languages, themes, layouts, etc. packages Changes in local packages labels May 15, 2026
@github-actions github-actions Bot added the waiting for review Pull requests that require a review before continuing label May 15, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_vision to the shared FunboxNameSchema enum and updated schema tests.
  • Registered tunnel_vision in 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`,
);
});
}
@d1rshan d1rshan marked this pull request as draft May 15, 2026 17:25
@github-actions github-actions Bot removed the waiting for review Pull requests that require a review before continuing label May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

assets Languages, themes, layouts, etc. frontend User interface or web stuff packages Changes in local packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants