feat: cached styling

This commit is contained in:
TrèsAbhi committed 2024-06-23 20:45:56 -05:00
1 parent 1d65dc755f
commit ff4be57faf
5 files changed
+97 -89

No files matched your search

+23 -19
View File
@@ -2,25 +2,29 @@
import { LinkProps, Link as RadixLink } from '@radix-ui/themes';
import { useRouter } from 'next/navigation';
import { forwardRef } from 'react';
export function Link({ href, onClick, ...props }: LinkProps) {
const router = useRouter();
export const Link = forwardRef<HTMLAnchorElement, LinkProps>(
({ href, onClick, ...props }, ref) => {
const router = useRouter();
return (
<RadixLink
href={href}
onClick={(event) => {
event.preventDefault();
if (href) {
if (event.ctrlKey || event.metaKey) {
window.open(href);
} else {
router.push(href);
return (
<RadixLink
ref={ref}
href={href}
onClick={(event) => {
event.preventDefault();
if (href) {
if (event.ctrlKey || event.metaKey) {
window.open(href);
} else {
router.push(href);
}
}
}
onClick?.(event);
}}
{...props}
/>
);
}
onClick?.(event);
}}
{...props}
/>
);
},
);