feat: update layout components, fix AccentLink styles, add Tooltip and Cursor components
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useRef } from "react";
|
||||
|
||||
export default function Cursor() {
|
||||
const dotRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
// Skip on touchscreens — pointer:fine === false there
|
||||
if (!window.matchMedia("(pointer: fine)").matches) return;
|
||||
|
||||
const el = dotRef.current;
|
||||
if (!el) return;
|
||||
|
||||
const move = (e: MouseEvent) => {
|
||||
// Two translates: first moves to cursor coords, second re-centers the dot
|
||||
el.style.transform = `translate(${e.clientX}px, ${e.clientY}px) translate(-50%, -50%)`;
|
||||
};
|
||||
|
||||
window.addEventListener("mousemove", move);
|
||||
return () => window.removeEventListener("mousemove", move);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={dotRef}
|
||||
aria-hidden
|
||||
// Initial inline transform parks it off-screen until the first mousemove
|
||||
style={{ transform: "translate(-100px, -100px)" }}
|
||||
className="
|
||||
pointer-events-none fixed left-0 top-0 z-[100]
|
||||
size-3 rounded-full bg-white mix-blend-difference
|
||||
"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
type TooltipProps = {
|
||||
text: string;
|
||||
children?: React.ReactNode;
|
||||
};
|
||||
|
||||
export default function Tooltip({ text, children }: TooltipProps) {
|
||||
return (
|
||||
<span className="group relative inline-flex">
|
||||
{children}
|
||||
<span
|
||||
role="tooltip"
|
||||
className="
|
||||
pointer-events-none absolute bottom-full left-1/2 mb-2 -translate-x-1/2
|
||||
rounded-md bg-neutral-800 px-2 py-1 text-xs text-neutral-100
|
||||
whitespace-nowrap opacity-0
|
||||
transition-opacity duration-150
|
||||
group-hover:opacity-100 group-focus-within:opacity-100
|
||||
"
|
||||
>
|
||||
{text}
|
||||
</span>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user