cinny/src/app/molecules/dialog/Dialog.jsx

76 lines
2.1 KiB
React
Raw Normal View History

2021-08-16 14:04:19 +02:00
import React from 'react';
import PropTypes from 'prop-types';
import './Dialog.scss';
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({
className, isOpen, title, onAfterOpen, onAfterClose,
contentOptions, onRequestClose, closeFromOutside, children,
invisibleScroll,
2021-08-16 14:04:19 +02:00
}) {
return (
<RawModal
className={`${className === null ? '' : `${className} `}dialog-model`}
isOpen={isOpen}
onAfterOpen={onAfterOpen}
onAfterClose={onAfterClose}
2021-08-16 14:04:19 +02:00
onRequestClose={onRequestClose}
closeFromOutside={closeFromOutside}
2021-08-16 14:04:19 +02:00
size="small"
>
<div className="dialog">
<div className="dialog__content">
<Header>
<TitleWrapper>
{
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">
<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,
onAfterOpen: null,
onAfterClose: null,
2021-08-16 14:04:19 +02:00
onRequestClose: null,
closeFromOutside: true,
invisibleScroll: false,
2021-08-16 14:04:19 +02:00
};
Dialog.propTypes = {
className: PropTypes.string,
isOpen: PropTypes.bool.isRequired,
title: PropTypes.node.isRequired,
2021-08-16 14:04:19 +02:00
contentOptions: PropTypes.node,
onAfterOpen: PropTypes.func,
onAfterClose: PropTypes.func,
2021-08-16 14:04:19 +02:00
onRequestClose: PropTypes.func,
closeFromOutside: PropTypes.bool,
2021-08-16 14:04:19 +02:00
children: PropTypes.node.isRequired,
invisibleScroll: PropTypes.bool,
2021-08-16 14:04:19 +02:00
};
export default Dialog;