ConnectSection.js (1776B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 const { 8 PureComponent, 9 } = require("resource://devtools/client/shared/vendor/react.mjs"); 10 const dom = require("resource://devtools/client/shared/vendor/react-dom-factories.js"); 11 const PropTypes = require("resource://devtools/client/shared/vendor/react-prop-types.mjs"); 12 13 class ConnectSection extends PureComponent { 14 static get propTypes() { 15 return { 16 children: PropTypes.node, 17 className: PropTypes.string, 18 extraContent: PropTypes.node, 19 icon: PropTypes.string.isRequired, 20 title: PropTypes.node.isRequired, 21 }; 22 } 23 24 renderExtraContent() { 25 const { extraContent } = this.props; 26 return dom.section( 27 { 28 className: "connect-section__extra", 29 }, 30 extraContent 31 ); 32 } 33 34 render() { 35 const { extraContent } = this.props; 36 37 return dom.section( 38 { 39 className: `card connect-section ${this.props.className || ""}`, 40 }, 41 dom.header( 42 { 43 className: "connect-section__header", 44 }, 45 dom.img({ 46 className: "connect-section__header__icon", 47 src: this.props.icon, 48 }), 49 dom.h1( 50 { 51 className: "card__heading connect-section__header__title", 52 }, 53 this.props.title 54 ) 55 ), 56 this.props.children 57 ? dom.div( 58 { 59 className: "connect-section__content", 60 }, 61 this.props.children 62 ) 63 : null, 64 extraContent ? this.renderExtraContent() : null 65 ); 66 } 67 } 68 69 module.exports = ConnectSection;