2019-12-04 09:36:13 +00:00
|
|
|
|
import React from "react";
|
2020-10-16 13:16:01 +00:00
|
|
|
|
import PropTypes from "prop-types";
|
2021-03-11 11:33:32 +00:00
|
|
|
|
import StyledText from "./styled-text";
|
2019-12-04 09:36:13 +00:00
|
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
|
const Text = ({
|
|
|
|
|
title,
|
|
|
|
|
tag,
|
|
|
|
|
as,
|
|
|
|
|
fontSize,
|
|
|
|
|
fontWeight,
|
|
|
|
|
color,
|
|
|
|
|
textAlign,
|
|
|
|
|
...rest
|
|
|
|
|
}) => {
|
2019-12-04 09:36:13 +00:00
|
|
|
|
return (
|
2020-01-16 11:41:28 +00:00
|
|
|
|
<StyledText
|
|
|
|
|
fontSizeProp={fontSize}
|
|
|
|
|
fontWeightProp={fontWeight}
|
|
|
|
|
colorProp={color}
|
2020-07-14 09:54:11 +00:00
|
|
|
|
textAlign={textAlign}
|
2020-01-16 11:41:28 +00:00
|
|
|
|
as={!as && tag ? tag : as}
|
|
|
|
|
title={title}
|
|
|
|
|
{...rest}
|
|
|
|
|
/>
|
2019-12-04 09:36:13 +00:00
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Text.propTypes = {
|
2021-03-11 11:33:32 +00:00
|
|
|
|
/** Sets the tag through which to render the component */
|
2019-12-04 09:36:13 +00:00
|
|
|
|
as: PropTypes.string,
|
|
|
|
|
tag: PropTypes.string,
|
2021-03-11 11:33:32 +00:00
|
|
|
|
/** Title */
|
2019-12-04 09:36:13 +00:00
|
|
|
|
title: PropTypes.string,
|
2021-03-11 11:33:32 +00:00
|
|
|
|
/** Specifies the text color */
|
2019-12-04 09:36:13 +00:00
|
|
|
|
color: PropTypes.string,
|
2021-03-11 11:33:32 +00:00
|
|
|
|
/** Sets the 'text-align' property */
|
2020-07-14 09:54:11 +00:00
|
|
|
|
textAlign: PropTypes.string,
|
2021-03-11 11:33:32 +00:00
|
|
|
|
/** Sets the font size */
|
2019-12-10 14:12:38 +00:00
|
|
|
|
fontSize: PropTypes.string,
|
2021-03-11 11:33:32 +00:00
|
|
|
|
/** Sets the font weight */
|
2019-12-23 12:33:58 +00:00
|
|
|
|
fontWeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
2021-03-11 11:33:32 +00:00
|
|
|
|
/** Sets background color */
|
2019-12-04 09:36:13 +00:00
|
|
|
|
backgroundColor: PropTypes.string,
|
2021-03-11 11:33:32 +00:00
|
|
|
|
/** Disables word wrapping */
|
2019-12-04 09:36:13 +00:00
|
|
|
|
truncate: PropTypes.bool,
|
2021-03-11 11:33:32 +00:00
|
|
|
|
/** Sets font weight value to bold */
|
2019-12-04 09:36:13 +00:00
|
|
|
|
isBold: PropTypes.bool,
|
2021-03-11 11:33:32 +00:00
|
|
|
|
/** Sets the 'display: inline-block' property */
|
2019-12-04 09:36:13 +00:00
|
|
|
|
isInline: PropTypes.bool,
|
2021-03-11 11:33:32 +00:00
|
|
|
|
/** Sets the font style */
|
2019-12-04 09:36:13 +00:00
|
|
|
|
isItalic: PropTypes.bool,
|
2021-03-11 11:33:32 +00:00
|
|
|
|
/** Sets the 'display' property */
|
2020-10-16 13:16:01 +00:00
|
|
|
|
display: PropTypes.string,
|
2021-08-27 14:10:26 +00:00
|
|
|
|
/** Disable selection of text*/
|
|
|
|
|
noSelect: PropTypes.bool,
|
2019-12-04 09:36:13 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Text.defaultProps = {
|
2020-01-16 11:41:28 +00:00
|
|
|
|
title: null,
|
2020-10-16 13:16:01 +00:00
|
|
|
|
textAlign: "left",
|
|
|
|
|
fontSize: "13px",
|
2019-12-04 09:36:13 +00:00
|
|
|
|
truncate: false,
|
|
|
|
|
isBold: false,
|
|
|
|
|
isInline: false,
|
|
|
|
|
isItalic: false,
|
2021-08-27 14:10:26 +00:00
|
|
|
|
noSelect: false,
|
2019-12-04 09:36:13 +00:00
|
|
|
|
};
|
|
|
|
|
|
2022-03-23 07:35:01 +00:00
|
|
|
|
export default React.memo(Text);
|