saleor-dashboard/src/components/ExternalLink/ExternalLink.tsx

35 lines
871 B
TypeScript
Raw Normal View History

2019-10-30 14:34:24 +00:00
import { makeStyles } from "@material-ui/core/styles";
2019-06-19 14:40:52 +00:00
import Typography, { TypographyProps } from "@material-ui/core/Typography";
2019-08-09 10:26:22 +00:00
import React from "react";
2019-06-19 14:40:52 +00:00
2019-12-03 15:28:40 +00:00
const useStyles = makeStyles(
{
link: {
textDecoration: "none"
}
},
{ name: "ExternalLink" }
);
2019-06-19 14:40:52 +00:00
2019-10-30 14:34:24 +00:00
interface ExternalLinkProps extends React.HTMLProps<HTMLAnchorElement> {
2019-06-19 14:40:52 +00:00
href: string;
className?: string;
typographyProps?: TypographyProps;
}
2019-10-30 14:34:24 +00:00
const ExternalLink: React.FC<ExternalLinkProps> = props => {
const { className, children, href, typographyProps, ...rest } = props;
const classes = useStyles(props);
return (
<a href={href} className={classes.link} {...rest}>
2019-06-19 14:40:52 +00:00
<Typography className={className} color="primary" {...typographyProps}>
{children}
</Typography>
</a>
2019-10-30 14:34:24 +00:00
);
};
2019-06-19 14:40:52 +00:00
ExternalLink.displayName = "ExternalLink";
export default ExternalLink;