-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix issues with the missing info icon
- Loading branch information
Showing
6 changed files
with
50 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React, { forwardRef } from 'react'; | ||
import { useLocation, useRouter } from 'wouter'; | ||
|
||
interface LinkProps | ||
extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'href'> { | ||
to: string; | ||
} | ||
|
||
export const Link: React.FC<LinkProps> = forwardRef< | ||
HTMLAnchorElement, | ||
LinkProps | ||
>((props, ref) => { | ||
const router = useRouter(); | ||
const [, navigate] = useLocation(); | ||
|
||
const { to, onClick, children, ...aProps } = props; | ||
|
||
return ( | ||
<a | ||
ref={ref} | ||
{...aProps} | ||
href={to[0] === '~' ? to.slice(1) : router.base + to} | ||
onClick={event => { | ||
// ignores the navigation when clicked using right mouse button or | ||
// by holding a special modifier key: ctrl, command, win, alt, shift | ||
if ( | ||
event.ctrlKey || | ||
event.metaKey || | ||
event.altKey || | ||
event.shiftKey || | ||
event.button !== 0 | ||
) | ||
return; | ||
|
||
onClick && onClick(event); | ||
if (!event.defaultPrevented) { | ||
event.preventDefault(); | ||
navigate(to); | ||
} | ||
}} | ||
> | ||
{children} | ||
</a> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters