Re-added info button and SDK docs to fields after refactor.

This commit is contained in:
orangemug 2020-06-29 16:03:59 +01:00
parent 4a6f58d61c
commit 67bdea1827
4 changed files with 61 additions and 7 deletions

View file

@ -69,15 +69,34 @@ export default class Block extends React.Component {
})} })}
onClick={this.onLabelClick} onClick={this.onLabelClick}
> >
{this.props.fieldSpec &&
<div className="maputnik-input-block-label">
<FieldDocLabel
label={this.props.label}
onToggleDoc={this.onToggleDoc}
fieldSpec={this.props.fieldSpec}
/>
</div>
}
{!this.props.fieldSpec &&
<div className="maputnik-input-block-label"> <div className="maputnik-input-block-label">
{this.props.label} {this.props.label}
</div> </div>
}
<div className="maputnik-input-block-action"> <div className="maputnik-input-block-action">
{this.props.action} {this.props.action}
</div> </div>
<div className="maputnik-input-block-content" ref={el => this._blockEl = el}> <div className="maputnik-input-block-content" ref={el => this._blockEl = el}>
{this.props.children} {this.props.children}
</div> </div>
{this.props.fieldSpec &&
<div
className="maputnik-doc-inline"
style={{display: this.state.showDoc ? '' : 'none'}}
>
<Doc fieldSpec={this.props.fieldSpec} />
</div>
}
</label> </label>
} }
} }

View file

@ -1,5 +1,7 @@
import React from 'react' import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import FieldDocLabel from './FieldDocLabel'
import Doc from './Doc'
let IDX = 0; let IDX = 0;
@ -8,21 +10,49 @@ export default class Fieldset extends React.Component {
constructor (props) { constructor (props) {
super(props); super(props);
this._labelId = `fieldset_label_${(IDX++)}`; this._labelId = `fieldset_label_${(IDX++)}`;
this.state = {
showDoc: false,
}
}
onToggleDoc = (val) => {
this.setState({
showDoc: val
});
} }
render () { render () {
const {props} = this; const {props} = this;
return <div className="maputnik-input-block" role="group" aria-labelledby={this._labelId}> return <div className="maputnik-input-block" role="group" aria-labelledby={this._labelId}>
<div className="maputnik-input-block-label" id={this._labelId}> {this.props.fieldSpec &&
<div className="maputnik-input-block-label">
<FieldDocLabel
label={this.props.label}
onToggleDoc={this.onToggleDoc}
fieldSpec={this.props.fieldSpec}
/>
</div>
}
{!this.props.fieldSpec &&
<div className="maputnik-input-block-label">
{props.label} {props.label}
</div> </div>
}
<div className="maputnik-input-block-action"> <div className="maputnik-input-block-action">
{this.props.action} {this.props.action}
</div> </div>
<div className="maputnik-input-block-content"> <div className="maputnik-input-block-content">
{props.children} {props.children}
</div> </div>
{this.props.fieldSpec &&
<div
className="maputnik-doc-inline"
style={{display: this.state.showDoc ? '' : 'none'}}
>
<Doc fieldSpec={this.props.fieldSpec} />
</div>
}
</div> </div>
} }
} }

View file

@ -39,7 +39,11 @@ export default class SpecField extends React.Component {
TypeBlock = Block; TypeBlock = Block;
} }
return <TypeBlock label={props.label} action={props.action}> return <TypeBlock
label={props.label}
action={props.action}
fieldSpec={this.props.fieldSpec}
>
<InputSpec {...props} /> <InputSpec {...props} />
</TypeBlock> </TypeBlock>
} }

View file

@ -89,6 +89,7 @@
font-size: 12px; font-size: 12px;
margin-top: $margin-3; margin-top: $margin-3;
line-height: 1.5; line-height: 1.5;
flex: 1 0;
} }
.maputnik-doc-target:hover .maputnik-doc-popup { .maputnik-doc-target:hover .maputnik-doc-popup {