summaryrefslogtreecommitdiffstats
path: root/src/components/Buttons/ButtonLink/ButtonLink.tsx
blob: a2f75f240ac3b664190a1841292489137518c048 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { ButtonPosition } from '@ts/types/app';
import Link from 'next/link';
import { ReactNode } from 'react';
import styles from '../Buttons.module.scss';

const ButtonLink = ({
  children,
  target,
  position = 'left',
  isExternal = false,
  hasIcon = false,
}: {
  children: ReactNode;
  target: string;
  position?: ButtonPosition;
  isExternal?: boolean;
  hasIcon?: boolean;
}) => {
  const classes = `${styles.btn} ${styles.link} ${styles[`link--${position}`]}${
    hasIcon ? ` ${styles['link--icon']}` : ''
  }`;

  return isExternal ? (
    <a className={classes} href={target}>
      {children}
    </a>
  ) : (
    <Link href={target}>
      <a className={classes}>{children}</a>
    </Link>
  );
};

export default ButtonLink;