DocSpace-buildtools/packages/components/link/index.js

87 lines
2.3 KiB
JavaScript
Raw Normal View History

2021-08-17 12:38:59 +00:00
import React from "react";
2019-08-12 09:41:53 +00:00
import PropTypes from "prop-types";
import StyledText from "./styled-link";
2019-06-21 16:02:16 +00:00
// eslint-disable-next-line react/display-name
const Link = ({
isTextOverflow,
children,
noHover,
enableUserSelect,
...rest
}) => {
// console.log("Link render", rest);
2019-08-12 09:41:53 +00:00
return (
<StyledText
tag="a"
isTextOverflow={isTextOverflow}
2019-12-24 09:55:36 +00:00
noHover={noHover}
truncate={isTextOverflow}
enableUserSelect={enableUserSelect}
{...rest}
>
{children}
</StyledText>
2019-08-12 09:41:53 +00:00
);
};
2019-06-21 16:02:16 +00:00
Link.propTypes = {
2019-12-24 09:55:36 +00:00
children: PropTypes.any,
/** Accepts class */
2019-12-24 09:55:36 +00:00
className: PropTypes.string,
/** Color of link */
2019-08-12 09:41:53 +00:00
color: PropTypes.string,
/** ont size of link */
fontSize: PropTypes.string,
/** Font weight of link */
fontWeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
/** Used as HTML `href` property */
2019-08-12 09:41:53 +00:00
href: PropTypes.string,
/** Accepts id */
2019-12-24 09:55:36 +00:00
id: PropTypes.string,
/** Set font weight */
2019-08-12 09:41:53 +00:00
isBold: PropTypes.bool,
/** Set hovered state and effects of link */
2019-08-12 09:41:53 +00:00
isHovered: PropTypes.bool,
/** 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,
/** Activate or deactivate _text-overflow_ CSS property with ellipsis (' … ') value */
2019-08-12 09:41:53 +00:00
isTextOverflow: PropTypes.bool,
/** Disabled hover styles */
2019-12-24 09:55:36 +00:00
noHover: PropTypes.bool,
/** What the link will trigger when clicked. Only for \'action\' type of link */
2019-08-12 09:41:53 +00:00
onClick: PropTypes.func,
/** Used as HTML `rel` property */
rel: PropTypes.string,
/** Accepts css style */
2019-12-24 09:55:36 +00:00
style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
/** Used as HTML `tabindex` property */
tabIndex: PropTypes.number,
/** 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"]),
/** Used as HTML `title` property */
2019-08-12 09:41:53 +00:00
title: PropTypes.string,
/** Type of link */
2019-08-12 09:41:53 +00:00
type: PropTypes.oneOf(["action", "page"]),
enableUserSelect: PropTypes.bool,
2019-06-21 16:02:16 +00:00
};
Link.defaultProps = {
2019-12-24 09:55:36 +00:00
className: "",
fontSize: "13px",
2019-08-12 09:41:53 +00:00
href: undefined,
isBold: false,
isHovered: false,
isSemitransparent: false,
isTextOverflow: false,
2019-12-24 09:55:36 +00:00
noHover: false,
rel: "noopener noreferrer",
tabIndex: -1,
type: "page",
enableUserSelect: false,
2019-08-12 09:41:53 +00:00
};
2019-06-21 16:02:16 +00:00
2021-08-17 12:19:33 +00:00
export default Link;