import * as React from "react"; import CollapsibleHeaderCallout from "../CollapsibleHeaderCallout"; import CollapsibleHeading from "../CollapsibleHeading"; interface Props { heading: React.ReactNode; metaItems?: Array; callout?: React.ReactNode; className: string; } export default class CollapsibleHeaderContent extends React.PureComponent< Props, {} > { static defaultProps = { className: "", }; renderMetaItems(): React.ReactNode { const { metaItems } = this.props; if (!metaItems) { return null; } return (
{metaItems.map((item, idx) => ( {item} ))}
); } render() { const { className, heading, callout } = this.props; let headingNode: React.ReactNode; if (typeof heading === "string") { headingNode = {heading}; } else { headingNode = heading; } let calloutNode: React.ReactNode; if (typeof callout === "string") { calloutNode = ; } else { calloutNode = callout; } let classNames: Array = [ "ddbc-collapsible__header-content", className, ]; return (
{headingNode} {this.renderMetaItems()}
{calloutNode && (
{calloutNode}
)}
); } }