UNPKG

@massds/mayflower-react

Version:

React versions of Mayflower design system UI components

61 lines (60 loc) 2.44 kB
const _excluded = ["level", "title", "children"]; function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; } /** * GenTeaserTitle module. * @module @massds/mayflower-react/GenTeaserTitle * @requires module:@massds/mayflower-assets/scss/03-organisms/gen-teaser */ import React from "react"; import PropTypes from "prop-types"; import * as Icon from "../Icon/index.mjs"; import DecorativeLink from "../DecorativeLink/index.mjs"; /** * Title Link */ const GenTeaserTitle = props => { const level = props.level, _props$title = props.title, title = _props$title === void 0 ? {} : _props$title, children = props.children, rest = _objectWithoutPropertiesLoose(props, _excluded); const decorativeProps = JSON.parse(JSON.stringify(title)); if (title.icon) { const IconComponent = Icon[title.icon]; decorativeProps.icon = /*#__PURE__*/React.createElement(IconComponent, { width: ".8em", height: ".8em" }); } if (title.showFileIcon && title.fileIcon) { const FileIconComponent = Icon[title.fileIcon]; decorativeProps.fileIcon = /*#__PURE__*/React.createElement(FileIconComponent, { width: 24, height: 24, bold: false }); } const Element = "h" + (level || 2); return /*#__PURE__*/React.createElement(Element, _extends({ className: "ma__gen-teaser__title" }, rest), children || /*#__PURE__*/React.createElement(DecorativeLink, decorativeProps)); }; GenTeaserTitle.propTypes = process.env.NODE_ENV !== "production" ? { /** The heading level of the title */ level: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), /** The title object (text, info, href) */ title: PropTypes.shape({ href: PropTypes.string, info: PropTypes.string, text: PropTypes.string, showFileIcon: PropTypes.bool, className: PropTypes.string, details: PropTypes.string, icon: PropTypes.string, fileIcon: PropTypes.string }), /** React children to render */ children: PropTypes.node } : {}; export default GenTeaserTitle;