mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 09:25:06 +03:00
* add link to function and table editor * Tiny refactor --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
45 lines
971 B
TypeScript
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>
|
|
)
|
|
}
|