import React, { useEffect } from 'react';
import classNames from 'classnames';
import { SessionIconButton, SessionIconSize, SessionIconType } from './icon/';
import { SessionButton, SessionButtonColor, SessionButtonType } from './SessionButton';
import { DefaultTheme } from 'styled-components';
import { useKeyPress } from "use-hooks";
interface Props {
title: string;
onClose: any;
showExitIcon?: boolean;
showHeader?: boolean;
headerReverse?: boolean;
//Maximum of two icons or buttons in header
headerIconButtons?: Array<{
iconType: SessionIconType;
iconRotation: number;
onClick?: any;
}>;
headerButtons?: Array<{
buttonType: SessionButtonType;
buttonColor: SessionButtonColor;
text: string;
onClick?: any;
}>;
theme: DefaultTheme;
}
interface State {
isVisible: boolean;
}
export const SessionWrapperModal = (props: any) => {
const { onclick, showModal, title, onConfirm } = props;
useEffect(() => {
window.addEventListener('keyup', upHandler);
return () => {
window.removeEventListener('keyup', upHandler);
}
}, [])
// TODO: warrick: typing
const upHandler = ({key}: any ) => {
if (key === 'Escape') {
props.onclick();
}
}
return (
{/* Onion Nodes / Generic Title {title} */}
{title}
);
};
// export class SessionModal extends React.PureComponent {
// public static defaultProps = {
// showExitIcon: true,
// showHeader: true,
// headerReverse: false,
// };
// private node: HTMLDivElement | null;
// constructor(props: any) {
// super(props);
// this.state = {
// isVisible: true,
// };
// this.close = this.close.bind(this);
// this.onKeyUp = this.onKeyUp.bind(this);
// this.node = null;
// window.addEventListener('keyup', this.onKeyUp);
// }
// public componentDidMount() {
// document.addEventListener('mousedown', this.handleClick, false);
// }
// public componentWillUnmount() {
// document.removeEventListener('mousedown', this.handleClick, false);
// }
// public handleClick = (e: any) => {
// if (this.node && this.node.contains(e.target)) {
// return;
// }
// this.close();
// };
// public render() {
// const { title, headerIconButtons, showExitIcon, showHeader, headerReverse } = this.props;
// const { isVisible } = this.state;
// return isVisible ? (
// (this.node = node)} className={'session-modal'}>
// {showHeader ? (
// <>
//
//
// {showExitIcon ? (
//
// ) : null}
//
//
{title}
//
// {headerIconButtons
// ? headerIconButtons.map((iconItem: any) => {
// return (
//
// );
// })
// : null}
//
//
// >
// ) : null}
//
{this.props.children}
//
// ) : null;
// }
// public close() {
// this.setState({
// isVisible: false,
// });
// window.removeEventListener('keyup', this.onKeyUp);
// document.removeEventListener('mousedown', this.handleClick, false);
// if (this.props.onClose) {
// this.props.onClose();
// }
// }
// public onKeyUp(event: any) {
// switch (event.key) {
// case 'Esc':
// case 'Escape':
// this.close();
// break;
// default:
// }
// }
// }