mirror of
https://github.com/hazemKrimi/crimson-quirks-ui.git
synced 2026-05-02 02:30:29 +00:00
Update link component
This commit is contained in:
@@ -2,7 +2,8 @@ import { Link as RouterLink } from 'react-router-dom';
|
|||||||
import { Wrapper } from './styles';
|
import { Wrapper } from './styles';
|
||||||
|
|
||||||
type LinkProps = {
|
type LinkProps = {
|
||||||
href: string;
|
href?: string;
|
||||||
|
url?: boolean;
|
||||||
children?: React.ReactNode | JSX.Element | string;
|
children?: React.ReactNode | JSX.Element | string;
|
||||||
color?:
|
color?:
|
||||||
| 'client'
|
| 'client'
|
||||||
@@ -19,21 +20,31 @@ type LinkProps = {
|
|||||||
className?: string;
|
className?: string;
|
||||||
iconLeft?: React.SVGProps<SVGSVGElement>;
|
iconLeft?: React.SVGProps<SVGSVGElement>;
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
|
target?: '_self' | '_blank';
|
||||||
};
|
};
|
||||||
|
|
||||||
const Link = ({
|
const Link = ({
|
||||||
href,
|
href,
|
||||||
|
url = false,
|
||||||
children,
|
children,
|
||||||
iconLeft,
|
iconLeft,
|
||||||
selected = false,
|
selected = false,
|
||||||
|
target = '_self',
|
||||||
...props
|
...props
|
||||||
}: LinkProps) => {
|
}: LinkProps) => {
|
||||||
return (
|
return (
|
||||||
<Wrapper {...props} selected={selected}>
|
<Wrapper {...props} selected={selected}>
|
||||||
<RouterLink to={href}>
|
{href && !url ? (
|
||||||
|
<RouterLink to={href} target={target}>
|
||||||
{iconLeft && <span className='icon left'>{iconLeft}</span>}
|
{iconLeft && <span className='icon left'>{iconLeft}</span>}
|
||||||
{children}
|
{children}
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
|
) : (
|
||||||
|
<a href={href} target={target}>
|
||||||
|
{iconLeft && <span className='icon left'>{iconLeft}</span>}
|
||||||
|
{children}
|
||||||
|
</a>
|
||||||
|
)}
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user