UNPKG

libreria-ui

Version:

Libreria UI de componentes creada por los Platzinautas de Rick Sanchez

42 lines (34 loc) 1.04 kB
import { createElement, forwardRef } from "react"; import { cx, css } from '@emotion/css'; import PropTypes from 'prop-types'; const TextStyles = (fontWeight, fontSize, lineHeight) => css` font-weight: ${fontWeight || '700'}; font-size: ${fontSize || '20px'}; line-height: ${lineHeight || '25px'}; ` const Text = forwardRef((props, ref) => { const { component, fontWeight, fontSize, className, lineHeight, ...otherProps} = props; const element = createElement(component,{ ...otherProps, ref, className: cx(TextStyles(fontWeight,fontSize,lineHeight), 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, }; Text.defaultProps = { component: 'p' } export default Text;