import React, { FunctionComponent, AnchorHTMLAttributes } from 'react';
import { getClassName } from '../../helpers/getClassName';
import { classNames } from '../../lib/classNames';
import { usePlatform } from '../../hooks/usePlatform';
import Tappable, { TappableProps } from '../Tappable/Tappable';
export interface LinkProps extends AnchorHTMLAttributes, TappableProps {}
const Link: FunctionComponent = ({
children,
className,
Component,
...restProps
}: LinkProps) => {
const platform = usePlatform();
const baseClassName = getClassName('Link', platform);
if (!Component) {
if (restProps.href) {
Component = 'a';
} else {
Component = 'button';
restProps = { type: 'button', ...restProps };
}
}
return (
{children}
);
};
export default Link;