tutu/src/platform/A.tsx

20 lines
556 B
TypeScript
Raw Normal View History

2024-11-16 12:04:55 +00:00
import { type JSX } from "solid-js";
import { useNavigator } from "./StackedRouter";
function handleClick(
push: (name: string, state: unknown) => void,
event: MouseEvent & { currentTarget: HTMLAnchorElement },
) {
const target = event.currentTarget;
event.preventDefault();
event.stopPropagation();
push(target.href, { state: target.getAttribute("state") || undefined });
}
const A = (oprops: JSX.HTMLElementTags["a"]) => {
const { push } = useNavigator();
return <a onClick={[handleClick, push]} {...oprops}></a>;
};
export default A;