import type React from 'react'; import type { HTMLProps } from 'react'; import { bindings } from '@/main'; import { LinkExternal01Icon } from '@untitled-theme/icons-react'; import { useState } from 'react'; import { twMerge } from 'tailwind-merge'; import { Overlay } from './overlay'; export interface ExternalLinkProps extends HTMLProps { href?: string | undefined; children?: React.ReactNode; includeIcon?: boolean | undefined; showModal?: boolean | undefined; } export function ExternalLink({ href, children, includeIcon, showModal = true, className, ...rest }: ExternalLinkProps) { const [isOpen, setIsOpen] = useState(false); // done like this so that "image" links don't have an icon const withIcon = !!(includeIcon ?? typeof children === 'string'); return ( { e.preventDefault(); if (!href) return; if (showModal) setIsOpen(true); else bindings.core.open(href); }} role="button" {...rest} > {children} {withIcon && } External Link

Are you sure you want to open this link in your browser?

{href} { if (href) bindings.core.open(href); setIsOpen(false); }, }, ]} />
); }