import React = require('react'); import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { action, computed, observable } from 'mobx'; import { observer } from 'mobx-react'; import './PropertiesSection.scss'; import { Doc } from '../../fields/Doc'; import { StrCast } from '../../fields/Types'; import { SettingsManager } from '../util/SettingsManager'; export interface PropertiesSectionProps { title: string; children?: JSX.Element | string | null; isOpen: boolean; setIsOpen: (bool: boolean) => any; inSection?: boolean; setInSection?: (bool: boolean) => any; onDoubleClick?: () => void; } @observer export class PropertiesSection extends React.Component { @computed get color() { return SettingsManager.userColor; } @computed get backgroundColor() { return SettingsManager.userBackgroundColor; } @computed get variantColor() { return SettingsManager.userVariantColor; } @observable isDouble: boolean = false; render() { if (this.props.children === undefined || this.props.children === null) return null; else return (
this.props.setInSection && this.props.setInSection(true))} onPointerLeave={action(() => this.props.setInSection && this.props.setInSection(false))}>
{ this.isDouble = true; this.props.onDoubleClick && this.props.onDoubleClick(); this.props.setIsOpen(true); setTimeout(() => (this.isDouble = false), 300); })} onClick={action(e => { this.props.setIsOpen(!this.props.isOpen); })} style={{ background: this.variantColor, // this.props.isOpen ? this.variantColor : this.backgroundColor, color: this.color, }}> {this.props.title}
{!this.props.isOpen ? null :
{this.props.children}
}
); } }