Extra dialog parameters for plugins

This commit is contained in:
Gregory Schier 2020-04-07 15:25:49 -07:00
parent 3b9031ecc0
commit a893ba8c88
2 changed files with 14 additions and 4 deletions

View File

@ -30,6 +30,8 @@ export function init(renderPurpose: RenderPurpose = RENDER_PURPOSE_GENERAL): { a
options?: {
onHide?: () => void,
tall?: boolean,
skinny?: boolean,
wide?: boolean,
} = {},
): void {
if (renderPurpose !== RENDER_PURPOSE_SEND && renderPurpose !== RENDER_PURPOSE_NO_RENDER) {
@ -40,6 +42,8 @@ export function init(renderPurpose: RenderPurpose = RENDER_PURPOSE_GENERAL): { a
title,
body: <HtmlElementWrapper el={body} onUnmount={options.onHide} />,
tall: options.tall,
skinny: options.skinny,
wide: options.wide,
});
},
prompt(

View File

@ -10,7 +10,9 @@ type State = {
title: string,
body: React.Node,
bodyHTML: ?string,
tall: boolean,
tall: ?boolean,
skinny: ?boolean,
wide: ?boolean,
};
@autobind
@ -25,6 +27,8 @@ class WrapperModal extends React.PureComponent<Props, State> {
body: null,
bodyHTML: null,
tall: false,
skinny: false,
wide: false,
};
}
@ -33,19 +37,21 @@ class WrapperModal extends React.PureComponent<Props, State> {
}
show(options: Object = {}) {
const { title, body, bodyHTML, tall } = options;
const { title, body, bodyHTML, tall, skinny, wide } = options;
this.setState({
title,
body,
bodyHTML,
tall: !!tall,
skinny: !!skinny,
wide: !!wide,
});
this.modal && this.modal.show();
}
render() {
const { title, body, bodyHTML, tall } = this.state;
const { title, body, bodyHTML, tall, skinny, wide } = this.state;
let finalBody = body;
if (bodyHTML) {
@ -53,7 +59,7 @@ class WrapperModal extends React.PureComponent<Props, State> {
}
return (
<Modal ref={this._setModalRef} tall={tall}>
<Modal ref={this._setModalRef} tall={tall} skinny={skinny} wide={wide}>
<ModalHeader>{title || 'Uh Oh!'}</ModalHeader>
<ModalBody>{finalBody}</ModalBody>
</Modal>