mirror of
https://github.com/hazemKrimi/personal-website.git
synced 2026-05-02 02:10:27 +00:00
40 lines
782 B
TypeScript
40 lines
782 B
TypeScript
import { FC, useContext } from 'react';
|
|
import { DarkModeContext } from '../../components/DarkMode';
|
|
import { Props } from './types';
|
|
import { Btn } from './styles';
|
|
import Link from 'next/link';
|
|
|
|
const MDXButton: FC<Props & { className?: string }> = ({
|
|
variant = 'text',
|
|
type = 'button',
|
|
link,
|
|
target,
|
|
children,
|
|
disabled,
|
|
className
|
|
}) => {
|
|
const { dark } = useContext(DarkModeContext);
|
|
|
|
return link ? (
|
|
<Link href={link} passHref>
|
|
<Btn
|
|
as='a'
|
|
target={target}
|
|
variant={variant}
|
|
type={type}
|
|
dark={dark}
|
|
disabled={disabled}
|
|
className={className}
|
|
>
|
|
{children}
|
|
</Btn>
|
|
</Link>
|
|
) : (
|
|
<Btn variant={variant} type={type} dark={dark} disabled={disabled} className={className}>
|
|
{children}
|
|
</Btn>
|
|
);
|
|
};
|
|
|
|
export default MDXButton;
|