mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
37 lines
926 B
TypeScript
37 lines
926 B
TypeScript
import { useService } from "renderer/hooks/use-service.hook";
|
|
import { LinkOpenerService } from "renderer/services/link-opener.service";
|
|
|
|
type Props = {
|
|
className?: string;
|
|
href?: string;
|
|
internal?: boolean;
|
|
children?: React.ReactNode;
|
|
style?: React.CSSProperties;
|
|
};
|
|
|
|
export function BsmLink({ className, href, children, style, internal }: Props) {
|
|
|
|
const linkOpener = useService(LinkOpenerService);
|
|
|
|
const openLink = () => {
|
|
if (!href) {
|
|
return;
|
|
}
|
|
linkOpener.open(href, internal);
|
|
};
|
|
|
|
return (
|
|
// eslint-disable-next-line jsx-a11y/anchor-is-valid -- Will be reworked later
|
|
<a
|
|
className={`${className} ${href && "cursor-pointer"}`}
|
|
onClick={e => {
|
|
e.stopPropagation();
|
|
openLink();
|
|
}}
|
|
style={style}
|
|
>
|
|
{children}
|
|
</a>
|
|
);
|
|
}
|