basico-creacion-api
Version:
Esta es una libreria en la que tu podras importar increibles componentes y consumir una API
40 lines (30 loc) • 1.05 kB
JavaScript
import { forwardRef, createElement } from 'react';
import { cx, css } from '@emotion/css';
import PropTypes from 'prop-types';
const TextStyles = (fontWeight, fontSize, lineHeight,color) => css`
font-weight: ${fontWeight || 700};
font-size: ${fontSize || '20px'};
line-height: ${lineHeight || '25px'};
color: ${color || 'black'};
`
const Text = forwardRef((props, ref) => {
const { component, fontWeight, fontSize, lineHeight,color, className, ...otherProps } = props;
const element = createElement(component, {
...otherProps,
ref,
className: cx(TextStyles(fontWeight, fontSize, lineHeight,color), className)
})
return element;
});
Text.propTypes = {
className: PropTypes.string,
component: PropTypes.oneOf(['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'span', 'textarea', 'p']),
fontWeight: PropTypes.number,
fontSize: PropTypes.string,
lineHeight: PropTypes.string,
color: PropTypes.string,
};
Text.defaultProps = {
component: 'p',
};
export default Text;