import React, {Component} from 'react'; import {Container, Col, Row, Popover, PopoverHeader, PopoverBody} from 'reactstrap'; let boxCount = 0; class WiaasBox extends Component { constructor(props) { super(props); if(!this.props.id){ boxCount++; this.idBox = 'wiaas-box-' + boxCount; }else{ this.idBox = this.props.id; } this.className = this.props.className ? 'wiaas-box ' + this.props.className : 'wiaas-box'; this.toggleBoxVisibility = this.toggleBoxVisibility.bind(this); this.togglePopover = this.togglePopover.bind(this); this.getVisibilityIcon = this.getVisibilityIcon.bind(this); this.getExtraHeaderContentSize = this.getExtraHeaderContentSize.bind(this); this.getMainTitleContentSize = this.getMainTitleContentSize.bind(this); this.state = { isContentVisible: typeof this.props.isContentVisible !== 'undefined' ? this.props.isContentVisible : true, visibilityIcon: 'fa fa-minus', popoverOpen: false }; } toggleBoxVisibility() { this.setState({ isContentVisible: !this.state.isContentVisible, }); } togglePopover(){ this.setState({ popoverOpen: !this.state.popoverOpen }); } getVisibilityIcon() { return this.state.isContentVisible ? 'fa fa-minus' : 'fa fa-plus'; } getMainTitleContentSize() { return this.props.customHeader ? 4 : 10; } getExtraHeaderContentSize() { if(this.props.mainTitle) { return this.props.customHeader ? 7 : 1; } return 12; } render() { const {mainTitle, infoPopover} = this.props; const CustomHeader = this.props.customHeader; const customHeaderParams = this.props.customHeaderParams || {}; return (
{ (mainTitle || CustomHeader) &&
{ mainTitle &&
{mainTitle}
} { CustomHeader && } { this.props.children &&
} { infoPopover &&
{infoPopover.title}
}
} { this.state.isContentVisible &&
{this.props.children}
}
); } } export default WiaasBox;