UNPKG

@bigfishtv/cockpit

Version:

87 lines (75 loc) 2.84 kB
var _class, _temp; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { titleCase } from '../utils/stringUtils'; import Icon from './Icon'; import Button from './button/Button'; var SectionTray = (_temp = _class = function (_Component) { _inherits(SectionTray, _Component); function SectionTray() { _classCallCheck(this, SectionTray); return _possibleConstructorReturn(this, _Component.apply(this, arguments)); } SectionTray.prototype.render = function render() { var _props = this.props, subject = _props.subject, SectionTypes = _props.SectionTypes, addSection = _props.addSection; return React.createElement( 'div', { className: 'sections' }, React.createElement( 'h2', { className: 'sections-title' }, 'Add ', titleCase(subject), ' Section' ), React.createElement( 'p', null, 'Select one of the ', subject, ' sections below' ), React.createElement( 'div', { className: 'row' }, SectionTypes.map(function (sectionType, i) { return React.createElement( 'div', { key: i, className: 'column-1-2 column-xlarge-1-4 column-large-1-3 column-xsmall-1-2 margin-bottom-small' }, React.createElement( Button, { style: 'block button-icon-left', onClick: function onClick() { return addSection(sectionType); }, disabled: sectionType.disabled }, React.createElement(Icon, { name: sectionType.icon }), sectionType.title ) ); }) ) ); }; return SectionTray; }(Component), _class.propTypes = { subject: PropTypes.string, SectionTypes: PropTypes.array, addSection: PropTypes.func }, _class.defaultProps = { subject: 'page', SectionTypes: [], addSection: function addSection() { return console.warn('[SectionTray] no addSection prop'); } }, _temp); export { SectionTray as default };