flex-template-web/src/components/Modal/Modal.example.js
Vesa Luusua fe28a82831 Fix: multiple modals cancelled each others on page load
(when one of the modals was initially open).
2017-06-06 22:55:22 +03:00

53 lines
1.3 KiB
JavaScript

/* eslint-disable no-console */
import React, { Component } from 'react';
import { Button } from '../../components';
import Modal from './Modal';
const togglePageClassNames = (className, addClass = true) => {
// We are just checking the value for now
console.log('Toggling Modal - pageClassName currently:', className, addClass);
};
class ModalWrapper extends Component {
constructor(props) {
super(props);
this.state = { isOpen: false };
this.handleOpen = this.handleOpen.bind(this);
}
handleOpen() {
this.setState({ isOpen: true });
}
render() {
return (
<div>
<div style={{ margin: '1rem' }}>
Wrapper text before ModalInMobile
</div>
<Modal
{...this.props}
isOpen={this.state.isOpen}
onClose={() => {
this.setState({ isOpen: false });
console.log('Closing modal');
}}
togglePageClassNames={togglePageClassNames}
>
<div style={{ margin: '1rem' }}>Some content inside Modal component</div>
</Modal>
<div style={{ margin: '1rem' }}>
<Button onClick={this.handleOpen}>Open</Button>
</div>
</div>
);
}
}
export const Empty = {
component: ModalWrapper,
useDefaultWrapperStyles: false,
props: {
id: 'ExampleModal',
},
};