UNPKG

@findify/react-components

Version:
18 lines (17 loc) 800 B
/** * @module components/Text */ import { createElement, memo } from 'react'; import cx from 'classnames'; import styles from 'components/Text/styles.css'; const options = ['title', 'primary', 'secondary', 'uppercase', 'lowercase']; const getSize = (props) => options .filter((i) => Boolean(props[i])) .map((i, index) => (index ? i.charAt(0).toUpperCase() + i.slice(1) : i)) .join(''); export default memo(({ component = 'span', className, children, mode, theme = styles, style, inlineBlock, html: __html, bold, ...rest }) => createElement(component, { children, ...(__html && { dangerouslySetInnerHTML: { __html } }), style, className: cx(theme.root, (mode && theme[mode]) || theme[getSize(rest)], bold && theme.bold, inlineBlock && theme.inlineBlock, className), }));