-
Notifications
You must be signed in to change notification settings - Fork 9
/
LinkButton.js
39 lines (34 loc) · 1.05 KB
/
LinkButton.js
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
35
36
37
38
39
import React from "react";
import PropTypes from "prop-types";
import { ShirtSizes } from "@paprika/helpers/lib/customPropTypes";
import Button from "./Button";
import buttonStyles from "./Button.styles";
const LinkPropTypes = {
children: PropTypes.node.isRequired,
href: PropTypes.string.isRequired,
isOpenNewTab: PropTypes.bool,
kind: PropTypes.oneOf(Button.Kinds.ALL),
size: PropTypes.oneOf(ShirtSizes.DEFAULT),
};
const LinkDefaultProps = {
isOpenNewTab: true,
kind: Button.Kinds.DEFAULT,
size: ShirtSizes.MEDIUM,
};
const LinkButton = React.forwardRef((props, ref) => {
const isOpenNewTabProps = {};
if (props.isOpenNewTab) {
isOpenNewTabProps.target = "_blank";
isOpenNewTabProps.rel = "noopener noreferrer";
}
return (
<a css={buttonStyles} {...props} ref={ref} href={props.href} {...isOpenNewTabProps}>
{props.children}
</a>
);
});
LinkButton.Kinds = Button.Kinds;
LinkButton.displayName = "LinkButton";
LinkButton.propTypes = LinkPropTypes;
LinkButton.defaultProps = LinkDefaultProps;
export default LinkButton;