forked from wednesday-solutions/nextjs-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (35 loc) · 1.03 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
*
* Text
*
*/
import React, { memo } from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import { FormattedMessage as T } from 'react-intl';
const StyledText = styled.span`
white-space: pre-line;
${({ display }) => display && `display: ${display}`};
${(props) => props.color && `color: ${props.color}`};
${(props) => props.fontsize};
${(props) => props.fontweight};
${(props) => props.styles};
`;
function Text({ id = 'default', text, values = {}, children, color, fontWeight, fontSize, ...props }) {
return (
<StyledText data-testid="text" color={color} fontweight={fontWeight} fontsize={fontSize} {...props}>
{text || children || <T id={id} values={values} />}
</StyledText>
);
}
Text.propTypes = {
id: PropTypes.string,
text: PropTypes.string,
children: PropTypes.string,
values: PropTypes.object,
color: PropTypes.string,
fontWeight: PropTypes.array,
fontSize: PropTypes.array,
display: PropTypes.oneOf(['block', 'in-line'])
};
export default memo(Text);