2021-08-16 14:04:19 +02:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import './Dialog.scss';
|
|
|
|
|
2021-11-23 07:26:02 +01:00
|
|
|
import { twemojify } from '../../../util/twemojify';
|
|
|
|
|
2021-08-16 14:04:19 +02:00
|
|
|
import Text from '../../atoms/text/Text';
|
|
|
|
import Header, { TitleWrapper } from '../../atoms/header/Header';
|
|
|
|
import ScrollView from '../../atoms/scroll/ScrollView';
|
|
|
|
import RawModal from '../../atoms/modal/RawModal';
|
|
|
|
|
|
|
|
function Dialog({
|
2021-12-14 12:56:32 +01:00
|
|
|
className, isOpen, title, onAfterOpen, onAfterClose,
|
|
|
|
contentOptions, onRequestClose, closeFromOutside, children,
|
2022-03-31 17:09:05 +02:00
|
|
|
invisibleScroll,
|
2021-08-16 14:04:19 +02:00
|
|
|
}) {
|
|
|
|
return (
|
|
|
|
<RawModal
|
|
|
|
className={`${className === null ? '' : `${className} `}dialog-model`}
|
|
|
|
isOpen={isOpen}
|
2021-12-14 12:56:32 +01:00
|
|
|
onAfterOpen={onAfterOpen}
|
|
|
|
onAfterClose={onAfterClose}
|
2021-08-16 14:04:19 +02:00
|
|
|
onRequestClose={onRequestClose}
|
2021-12-14 12:56:32 +01:00
|
|
|
closeFromOutside={closeFromOutside}
|
2021-08-16 14:04:19 +02:00
|
|
|
size="small"
|
|
|
|
>
|
|
|
|
<div className="dialog">
|
|
|
|
<div className="dialog__content">
|
|
|
|
<Header>
|
|
|
|
<TitleWrapper>
|
2022-02-20 15:43:59 +01:00
|
|
|
{
|
|
|
|
typeof title === 'string'
|
|
|
|
? <Text variant="h2" weight="medium" primary>{twemojify(title)}</Text>
|
|
|
|
: title
|
|
|
|
}
|
2021-08-16 14:04:19 +02:00
|
|
|
</TitleWrapper>
|
|
|
|
{contentOptions}
|
|
|
|
</Header>
|
|
|
|
<div className="dialog__content__wrapper">
|
2022-04-24 12:12:24 +02:00
|
|
|
<ScrollView autoHide={!invisibleScroll} invisible={invisibleScroll}>
|
2021-08-16 14:04:19 +02:00
|
|
|
<div className="dialog__content-container">
|
|
|
|
{children}
|
|
|
|
</div>
|
|
|
|
</ScrollView>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</RawModal>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Dialog.defaultProps = {
|
|
|
|
className: null,
|
|
|
|
contentOptions: null,
|
2021-12-14 12:56:32 +01:00
|
|
|
onAfterOpen: null,
|
|
|
|
onAfterClose: null,
|
2021-08-16 14:04:19 +02:00
|
|
|
onRequestClose: null,
|
2021-12-14 12:56:32 +01:00
|
|
|
closeFromOutside: true,
|
2022-03-31 17:09:05 +02:00
|
|
|
invisibleScroll: false,
|
2021-08-16 14:04:19 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
Dialog.propTypes = {
|
|
|
|
className: PropTypes.string,
|
|
|
|
isOpen: PropTypes.bool.isRequired,
|
2022-02-20 15:43:59 +01:00
|
|
|
title: PropTypes.node.isRequired,
|
2021-08-16 14:04:19 +02:00
|
|
|
contentOptions: PropTypes.node,
|
2021-12-14 12:56:32 +01:00
|
|
|
onAfterOpen: PropTypes.func,
|
|
|
|
onAfterClose: PropTypes.func,
|
2021-08-16 14:04:19 +02:00
|
|
|
onRequestClose: PropTypes.func,
|
2021-12-14 12:56:32 +01:00
|
|
|
closeFromOutside: PropTypes.bool,
|
2021-08-16 14:04:19 +02:00
|
|
|
children: PropTypes.node.isRequired,
|
2022-03-31 17:09:05 +02:00
|
|
|
invisibleScroll: PropTypes.bool,
|
2021-08-16 14:04:19 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export default Dialog;
|