2019-09-13 12:30:36 +00:00
|
|
|
import React, { memo } from "react";
|
2019-08-12 09:41:53 +00:00
|
|
|
import PropTypes from "prop-types";
|
2021-02-03 14:40:45 +00:00
|
|
|
import StyledText from "./styled-link";
|
2019-06-21 16:02:16 +00:00
|
|
|
|
2019-09-13 12:30:36 +00:00
|
|
|
// eslint-disable-next-line react/display-name
|
2021-03-08 20:18:45 +00:00
|
|
|
const Link = ({ isTextOverflow, children, noHover, ...rest }) => {
|
2019-12-02 13:29:06 +00:00
|
|
|
// console.log("Link render", rest);
|
2019-08-12 09:41:53 +00:00
|
|
|
|
|
|
|
return (
|
2019-12-10 14:12:38 +00:00
|
|
|
<StyledText
|
2019-12-04 09:36:13 +00:00
|
|
|
tag="a"
|
2019-12-10 14:12:38 +00:00
|
|
|
isTextOverflow={isTextOverflow}
|
2019-12-24 09:55:36 +00:00
|
|
|
noHover={noHover}
|
2019-12-04 09:36:13 +00:00
|
|
|
truncate={isTextOverflow}
|
|
|
|
{...rest}
|
|
|
|
>
|
|
|
|
{children}
|
2019-12-10 14:12:38 +00:00
|
|
|
</StyledText>
|
2019-08-12 09:41:53 +00:00
|
|
|
);
|
2021-03-08 20:18:45 +00:00
|
|
|
};
|
2019-06-21 16:02:16 +00:00
|
|
|
|
|
|
|
Link.propTypes = {
|
2019-12-24 09:55:36 +00:00
|
|
|
children: PropTypes.any,
|
2021-03-08 20:18:45 +00:00
|
|
|
/** Accepts class */
|
2019-12-24 09:55:36 +00:00
|
|
|
className: PropTypes.string,
|
2021-03-08 20:18:45 +00:00
|
|
|
/** Color of link */
|
2019-08-12 09:41:53 +00:00
|
|
|
color: PropTypes.string,
|
2021-03-08 20:18:45 +00:00
|
|
|
/** ont size of link */
|
2019-12-10 09:20:26 +00:00
|
|
|
fontSize: PropTypes.string,
|
2021-03-08 20:18:45 +00:00
|
|
|
/** Font weight of link */
|
2019-12-24 06:51:46 +00:00
|
|
|
fontWeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
2021-03-08 20:18:45 +00:00
|
|
|
/** Used as HTML `href` property */
|
2019-08-12 09:41:53 +00:00
|
|
|
href: PropTypes.string,
|
2021-03-08 20:18:45 +00:00
|
|
|
/** Accepts id */
|
2019-12-24 09:55:36 +00:00
|
|
|
id: PropTypes.string,
|
2021-03-08 20:18:45 +00:00
|
|
|
/** Set font weight */
|
2019-08-12 09:41:53 +00:00
|
|
|
isBold: PropTypes.bool,
|
2021-03-08 20:18:45 +00:00
|
|
|
/** Set hovered state and effects of link */
|
2019-08-12 09:41:53 +00:00
|
|
|
isHovered: PropTypes.bool,
|
2021-03-08 20:18:45 +00:00
|
|
|
/** Set css-property 'opacity' to 0.5. Usually apply for users with "pending" status */
|
2019-08-12 09:41:53 +00:00
|
|
|
isSemitransparent: PropTypes.bool,
|
2021-03-08 20:18:45 +00:00
|
|
|
/** Activate or deactivate _text-overflow_ CSS property with ellipsis (' … ') value */
|
2019-08-12 09:41:53 +00:00
|
|
|
isTextOverflow: PropTypes.bool,
|
2021-03-08 20:18:45 +00:00
|
|
|
/** Disabled hover styles */
|
2019-12-24 09:55:36 +00:00
|
|
|
noHover: PropTypes.bool,
|
2021-03-08 20:18:45 +00:00
|
|
|
/** What the link will trigger when clicked. Only for \'action\' type of link */
|
2019-08-12 09:41:53 +00:00
|
|
|
onClick: PropTypes.func,
|
2021-03-08 20:18:45 +00:00
|
|
|
/** Used as HTML `rel` property */
|
2019-08-13 11:45:35 +00:00
|
|
|
rel: PropTypes.string,
|
2021-03-08 20:18:45 +00:00
|
|
|
/** Accepts css style */
|
2019-12-24 09:55:36 +00:00
|
|
|
style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
|
2021-03-08 20:18:45 +00:00
|
|
|
/** Used as HTML `tabindex` property */
|
2019-08-13 11:45:35 +00:00
|
|
|
tabIndex: PropTypes.number,
|
2021-03-08 20:18:45 +00:00
|
|
|
/** The _target_ attribute specifies where the linked document will open when the link is clicked. */
|
2019-08-12 09:41:53 +00:00
|
|
|
target: PropTypes.oneOf(["_blank", "_self", "_parent", "_top"]),
|
2021-03-08 20:18:45 +00:00
|
|
|
/** Used as HTML `title` property */
|
2019-08-12 09:41:53 +00:00
|
|
|
title: PropTypes.string,
|
2021-03-08 20:18:45 +00:00
|
|
|
/** Type of link */
|
2019-08-12 09:41:53 +00:00
|
|
|
type: PropTypes.oneOf(["action", "page"]),
|
2019-06-21 16:02:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Link.defaultProps = {
|
2019-12-24 09:55:36 +00:00
|
|
|
className: "",
|
2019-08-12 09:41:53 +00:00
|
|
|
color: "#333333",
|
2020-10-16 13:16:01 +00:00
|
|
|
fontSize: "13px",
|
2019-08-12 09:41:53 +00:00
|
|
|
href: undefined,
|
|
|
|
isBold: false,
|
|
|
|
isHovered: false,
|
|
|
|
isSemitransparent: false,
|
2019-12-14 10:42:10 +00:00
|
|
|
isTextOverflow: false,
|
2019-12-24 09:55:36 +00:00
|
|
|
noHover: false,
|
2019-08-13 11:45:35 +00:00
|
|
|
rel: "noopener noreferrer",
|
2019-08-13 11:38:09 +00:00
|
|
|
tabIndex: -1,
|
2019-08-13 11:45:35 +00:00
|
|
|
type: "page",
|
2019-08-12 09:41:53 +00:00
|
|
|
};
|
2019-06-21 16:02:16 +00:00
|
|
|
|
2021-03-08 20:18:45 +00:00
|
|
|
export default memo(Link);
|