Files
6e25d21b2f feat(site): Add Hover And Focus Animations Across The Docs Site (#5085)
* feat(docs): Add Hover And Focus Animations Across The Docs Site

- Nav bar and footer links: hover underline that draws in from the side the
  mouse enters and leaves (utils/underlineDirection.ts)
- Logo spins half a turn on hover; nav dropdown chevron turns and the menu
  slides in; social icons get a soft background and lift
- Sidebar, "On this page" outline, "Edit this page" and previous/next links
  get soft pill hovers; previous/next use Lucide arrow icons
- Footer is now shown on pages with a sidebar, offset by the sidebar width
- Form controls (switch, checkbox, select, range slider, color picker, fake
  input, reset button) get brand hover/focus states and smoother motion
- Cards (overview, package, showcase, team member, category list) lift with
  a brand border on hover
- Page and sidebar scrollbars styled in the site colours, with a Firefox fallback

* Revert changes

* Apply changes

* Added the global transition off

* fix(docs): remove !important markers from transition durations, very bad a11y

* fix(docs): remove !important markers from transition durations, very bad a11y

* Fixes last things

* Added one thing

---------

Co-authored-by: Eric <eric.fennis@gmail.com>
Co-authored-by: Karsa <contact@karsa.org>
2026-10-30 15:07:29 +01:00

21 lines
953 B
TypeScript

// Links with a hover underline: the nav bar menu
const UNDERLINED_LINKS = '.VPNav .VPNavBarMenuLink, .VPNav .VPNavBarMenuGroup';
// Makes the hover underline follow the mouse: it draws in from the side the pointer enters
// and leaves towards the side the pointer exits. The side is passed to the CSS as a variable.
function setUnderlineOrigin(event: PointerEvent) {
const link = event.target;
if (!(link instanceof HTMLElement) || !link.matches(UNDERLINED_LINKS)) return;
const { left, width } = link.getBoundingClientRect();
const side = event.clientX < left + width / 2 ? 'left' : 'right';
link.style.setProperty('--underline-origin', side);
}
export default function trackUnderlineDirection() {
// pointerenter and pointerleave do not bubble, so they are caught on their way down instead
document.addEventListener('pointerenter', setUnderlineOrigin, true);
document.addEventListener('pointerleave', setUnderlineOrigin, true);
}