Files
supabase/apps/studio/components/ui/InlineLink.tsx
T
Saxon FletcherandJoshen Lim ddedae58b8 Add link to function and table editor (#40068)
* add link to function and table editor

* Tiny refactor

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2025-11-03 03:37:22 +00:00

45 lines
971 B
TypeScript

import Link from 'next/link'
import { PropsWithChildren } from 'react'
import { cn } from 'ui'
interface InlineLinkProps {
href: string
className?: string
target?: string
rel?: string
title?: string
onClick?: () => void
}
export const InlineLinkClassName =
'underline transition underline-offset-2 decoration-foreground-lighter hover:decoration-foreground text-inherit hover:text-foreground'
export const InlineLink = ({
href,
className: _className,
children,
title,
...props
}: PropsWithChildren<InlineLinkProps>) => {
const className = cn(InlineLinkClassName, _className)
if (href.startsWith('http')) {
return (
<a
title={title}
className={className}
href={href}
target="_blank"
rel="noreferrer noopener"
{...props}
>
{children}
</a>
)
}
return (
<Link className={className} href={href} title={title} {...props}>
{children}
</Link>
)
}