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";
|
|
|
|
import styled, { css } from "styled-components";
|
|
|
|
import commonTextStyles from "./common-text-styles";
|
2019-12-04 09:36:13 +00:00
|
|
|
|
|
|
|
const styleCss = css`
|
2020-10-16 13:16:01 +00:00
|
|
|
font-size: ${(props) => props.fontSizeProp};
|
2019-12-23 12:33:58 +00:00
|
|
|
outline: 0 !important;
|
2020-10-16 13:16:01 +00:00
|
|
|
font-weight: ${(props) =>
|
|
|
|
props.fontWeightProp
|
|
|
|
? props.fontWeightProp
|
|
|
|
: props.isBold == true
|
|
|
|
? 700
|
|
|
|
: "normal"};
|
|
|
|
${(props) =>
|
|
|
|
props.isItalic == true &&
|
|
|
|
css`
|
|
|
|
font-style: italic;
|
|
|
|
`}
|
|
|
|
${(props) =>
|
|
|
|
props.backgroundColor &&
|
|
|
|
css`
|
|
|
|
background-color: ${(props) => props.backgroundColor};
|
|
|
|
`}
|
|
|
|
${(props) =>
|
|
|
|
props.isInline
|
|
|
|
? css`
|
|
|
|
display: inline-block;
|
|
|
|
`
|
|
|
|
: props.display &&
|
|
|
|
css`
|
|
|
|
display: ${(props) => props.display};
|
|
|
|
`}
|
2019-12-04 09:36:13 +00:00
|
|
|
margin: 0;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const StyledText = styled.p`
|
|
|
|
${styleCss};
|
|
|
|
${commonTextStyles};
|
|
|
|
`;
|
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
const Text = ({
|
|
|
|
title,
|
|
|
|
tag,
|
|
|
|
as,
|
|
|
|
fontSize,
|
|
|
|
fontWeight,
|
|
|
|
color,
|
|
|
|
textAlign,
|
|
|
|
...rest
|
|
|
|
}) => {
|
2021-02-04 13:52:53 +00:00
|
|
|
console.log("Text render", color)
|
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 = {
|
|
|
|
as: PropTypes.string,
|
|
|
|
tag: PropTypes.string,
|
|
|
|
title: PropTypes.string,
|
|
|
|
color: PropTypes.string,
|
2020-07-14 09:54:11 +00:00
|
|
|
textAlign: PropTypes.string,
|
2019-12-10 14:12:38 +00:00
|
|
|
fontSize: PropTypes.string,
|
2019-12-23 12:33:58 +00:00
|
|
|
fontWeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
2019-12-04 09:36:13 +00:00
|
|
|
backgroundColor: PropTypes.string,
|
|
|
|
truncate: PropTypes.bool,
|
|
|
|
isBold: PropTypes.bool,
|
|
|
|
isInline: PropTypes.bool,
|
|
|
|
isItalic: PropTypes.bool,
|
2020-10-16 13:16:01 +00:00
|
|
|
display: PropTypes.string,
|
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
|
|
|
color: "#333333",
|
|
|
|
textAlign: "left",
|
|
|
|
fontSize: "13px",
|
2019-12-04 09:36:13 +00:00
|
|
|
truncate: false,
|
|
|
|
isBold: false,
|
|
|
|
isInline: false,
|
|
|
|
isItalic: false,
|
|
|
|
};
|
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
export default Text;
|