UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

39 lines 1.74 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; const _excluded = ["title", "className", "children", "title_class", "size", "ref"]; import React from 'react'; import classnames from 'classnames'; import { findElementInChildren } from '../../../shared/component-helper'; import Section from '../../section/Section'; import ModalContext from '../ModalContext'; import H1 from '../../../elements/H1'; export default class ModalHeader extends React.PureComponent { render() { const _this$props = this.props, { title = null, className = null, children = null, title_class = null, size = null, ref } = _this$props, sectionProps = _objectWithoutProperties(_this$props, _excluded); const customHeader = findElementInChildren(children, cur => { return cur.type === 'h1' || cur.type === H1; }); const usedTitle = title || this.context.title; const showTitle = !customHeader && usedTitle; const fontSize = size || 'large'; return React.createElement(Section, _extends({ style_type: "white", className: classnames(className), id: showTitle ? 'dnb-modal-' + this.context.id + '-title' : undefined }, sectionProps), showTitle && React.createElement("h1", { className: classnames(`dnb-modal__title dnb-space__top--zero dnb-space__bottom--small dnb-h--${fontSize}`, title_class) }, usedTitle), React.createElement("div", null, children)); } } _defineProperty(ModalHeader, "contextType", ModalContext); //# sourceMappingURL=ModalHeader.js.map