Add textAlign prop (left as default)

This commit is contained in:
Vladislav Makhov 2020-07-14 12:54:11 +03:00
parent 3b8c2f0e69
commit 505e98b1a1
2 changed files with 5 additions and 2 deletions

View File

@ -2,7 +2,7 @@ import {css} from 'styled-components';
const commonTextStyles = css`
font-family: 'Open Sans', sans-serif, Arial;
text-align: left;
text-align: ${props => props.textAlign};
color: ${props => props.colorProp};
${props => props.truncate && css`
white-space: nowrap;

View File

@ -22,13 +22,14 @@ const StyledText = styled.p`
${commonTextStyles};
`;
const Text = ({ title, tag, as, fontSize, fontWeight, color, ...rest }) => {
const Text = ({ title, tag, as, fontSize, fontWeight, color, textAlign, ...rest }) => {
//console.log("Text render", rest)
return (
<StyledText
fontSizeProp={fontSize}
fontWeightProp={fontWeight}
colorProp={color}
textAlign={textAlign}
as={!as && tag ? tag : as}
title={title}
{...rest}
@ -41,6 +42,7 @@ Text.propTypes = {
tag: PropTypes.string,
title: PropTypes.string,
color: PropTypes.string,
textAlign: PropTypes.string,
fontSize: PropTypes.string,
fontWeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
backgroundColor: PropTypes.string,
@ -54,6 +56,7 @@ Text.propTypes = {
Text.defaultProps = {
title: null,
color: '#333333',
textAlign: 'left',
fontSize: '13px',
truncate: false,
isBold: false,