mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2025-01-01 00:33:16 +01:00
Abstracted out <LoadingModal/>
This commit is contained in:
parent
558f3d649d
commit
afbdaecd0a
3 changed files with 63 additions and 15 deletions
49
src/components/modals/LoadingModal.jsx
Normal file
49
src/components/modals/LoadingModal.jsx
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
import React from 'react'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
|
|
||||||
|
import Button from '../Button'
|
||||||
|
import Modal from './Modal'
|
||||||
|
|
||||||
|
|
||||||
|
class LoadingModal extends React.Component {
|
||||||
|
static propTypes = {
|
||||||
|
isOpen: PropTypes.bool.isRequired,
|
||||||
|
onCancel: PropTypes.func.isRequired,
|
||||||
|
title: PropTypes.string.isRequired,
|
||||||
|
message: PropTypes.node.isRequired,
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
}
|
||||||
|
|
||||||
|
underlayOnClick(e) {
|
||||||
|
// This stops click events falling through to underlying modals.
|
||||||
|
e.stopPropagation();
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return <Modal
|
||||||
|
data-wd-key="loading-modal"
|
||||||
|
isOpen={this.props.isOpen}
|
||||||
|
underlayClickExits={false}
|
||||||
|
underlayProps={{
|
||||||
|
onClick: (e) => underlayProps(e)
|
||||||
|
}}
|
||||||
|
closeable={false}
|
||||||
|
title={this.props.title}
|
||||||
|
onOpenToggle={() => this.props.onCancel()}
|
||||||
|
>
|
||||||
|
<p>
|
||||||
|
{this.props.message}
|
||||||
|
</p>
|
||||||
|
<p className="maputnik-dialog__buttons">
|
||||||
|
<Button onClick={(e) => this.props.onCancel(e)}>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
</p>
|
||||||
|
</Modal>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default LoadingModal
|
|
@ -11,6 +11,12 @@ class Modal extends React.Component {
|
||||||
title: PropTypes.string.isRequired,
|
title: PropTypes.string.isRequired,
|
||||||
onOpenToggle: PropTypes.func.isRequired,
|
onOpenToggle: PropTypes.func.isRequired,
|
||||||
children: PropTypes.node,
|
children: PropTypes.node,
|
||||||
|
underlayClickExits: PropTypes.bool,
|
||||||
|
underlayProps: PropTypes.object,
|
||||||
|
}
|
||||||
|
|
||||||
|
static defaultProps = {
|
||||||
|
underlayClickExits: true
|
||||||
}
|
}
|
||||||
|
|
||||||
getApplicationNode() {
|
getApplicationNode() {
|
||||||
|
@ -21,6 +27,8 @@ class Modal extends React.Component {
|
||||||
if(this.props.isOpen) {
|
if(this.props.isOpen) {
|
||||||
return <AriaModal
|
return <AriaModal
|
||||||
titleText={this.props.title}
|
titleText={this.props.title}
|
||||||
|
underlayClickExits={this.props.underlayClickExits}
|
||||||
|
underlayProps={this.props.underlayProps}
|
||||||
getApplicationNode={this.getApplicationNode}
|
getApplicationNode={this.getApplicationNode}
|
||||||
data-wd-key={this.props["data-wd-key"]}
|
data-wd-key={this.props["data-wd-key"]}
|
||||||
verticallyCenter={true}
|
verticallyCenter={true}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
|
import LoadingModal from './LoadingModal'
|
||||||
import Modal from './Modal'
|
import Modal from './Modal'
|
||||||
import Button from '../Button'
|
import Button from '../Button'
|
||||||
import FileReaderInput from 'react-file-reader-input'
|
import FileReaderInput from 'react-file-reader-input'
|
||||||
|
@ -195,22 +196,12 @@ class OpenModal extends React.Component {
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<Modal
|
<LoadingModal
|
||||||
data-wd-key="loading-modal"
|
isOpen={!!this.state.activeRequest}
|
||||||
isOpen={this.state.activeRequest}
|
|
||||||
closeable={false}
|
|
||||||
title={'Loading style'}
|
title={'Loading style'}
|
||||||
onOpenToggle={() => this.onCancelActiveRequest()}
|
onCancel={(e) => this.onCancelActiveRequest(e)}
|
||||||
>
|
message={"Loading: "+this.state.activeRequestUrl}
|
||||||
<p>
|
/>
|
||||||
Loading: {this.state.activeRequestUrl}
|
|
||||||
</p>
|
|
||||||
<p className="maputnik-dialog__buttons">
|
|
||||||
<Button onClick={(e) => this.onCancelActiveRequest(e)}>
|
|
||||||
Cancel
|
|
||||||
</Button>
|
|
||||||
</p>
|
|
||||||
</Modal>
|
|
||||||
</Modal>
|
</Modal>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue