mirror of
https://github.com/theoludwig/theoludwig.git
synced 2025-05-29 22:37:44 +02:00
refactor: components struture
This commit is contained in:
35
packages/ui/src/Design/Link/Link.tsx
Normal file
35
packages/ui/src/Design/Link/Link.tsx
Normal file
@ -0,0 +1,35 @@
|
||||
import { classNames } from "@repo/config-tailwind/classNames"
|
||||
import { Link as NextLink } from "@repo/i18n/navigation"
|
||||
import { FiExternalLink } from "react-icons/fi"
|
||||
|
||||
export interface LinkProps extends React.ComponentProps<typeof NextLink> {
|
||||
isExternal?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* Link is an actionable text component with connection to another web pages.
|
||||
* @param props
|
||||
* @returns
|
||||
*/
|
||||
export const Link: React.FC<LinkProps> = (props) => {
|
||||
const { className, children, target, isExternal = true, ...rest } = props
|
||||
|
||||
return (
|
||||
<NextLink
|
||||
className={classNames(
|
||||
"text-primary dark:text-primary-dark inline-flex items-center gap-1 font-semibold hover:underline focus:rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",
|
||||
className,
|
||||
)}
|
||||
target={target}
|
||||
{...rest}
|
||||
>
|
||||
{children}
|
||||
|
||||
{target === "_blank" && isExternal ? (
|
||||
<FiExternalLink size={16} strokeWidth={2.5} />
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
</NextLink>
|
||||
)
|
||||
}
|
Reference in New Issue
Block a user