UNPKG

react-styleguidist

Version:
69 lines (64 loc) 2.5 kB
import "core-js/modules/es.array.index-of"; import "core-js/modules/es.object.keys"; import "core-js/modules/es.string.small"; function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } import React from 'react'; import cx from 'clsx'; import Styled from 'rsg-components/Styled'; export var styles = function styles(_ref) { var fontFamily = _ref.fontFamily, fontSize = _ref.fontSize, color = _ref.color; return { text: { fontFamily: fontFamily.base }, inheritSize: { fontSize: 'inherit' }, smallSize: { fontSize: fontSize.small }, baseSize: { fontSize: fontSize.base }, textSize: { fontSize: fontSize.text }, baseColor: { color: color.base }, lightColor: { color: color.light }, em: { fontStyle: 'italic' }, strong: { fontWeight: 'bold' }, isUnderlined: { borderBottom: [[1, 'dotted', color.lightest]] } }; }; export var TextRenderer = function TextRenderer(_ref2) { var _cx; var classes = _ref2.classes, semantic = _ref2.semantic, _ref2$size = _ref2.size, size = _ref2$size === void 0 ? 'inherit' : _ref2$size, _ref2$color = _ref2.color, color = _ref2$color === void 0 ? 'base' : _ref2$color, _ref2$underlined = _ref2.underlined, underlined = _ref2$underlined === void 0 ? false : _ref2$underlined, children = _ref2.children, props = _objectWithoutPropertiesLoose(_ref2, ["classes", "semantic", "size", "color", "underlined", "children"]); var Tag = semantic || 'span'; var classNames = cx(classes.text, classes[size + "Size"], classes[color + "Color"], (_cx = {}, _cx[classes[Tag]] = !!semantic, _cx[classes.isUnderlined] = underlined, _cx)); return /*#__PURE__*/React.createElement(Tag, _extends({}, props, { className: classNames }), children); }; export default Styled(styles)(TextRenderer);