|
@@ -1,7 +1,19 @@
|
|
|
+import cx from 'classnames';
|
|
|
import { Overlay } from '../overlay/Overlay.jsx';
|
|
|
import style from './dialog.css';
|
|
|
|
|
|
-function Dialog ({closeOnEsc = true}, children) {
|
|
|
+function defaultRenderCloseButton () {
|
|
|
+ return '\u2715';
|
|
|
+}
|
|
|
+
|
|
|
+function Dialog (
|
|
|
+ {
|
|
|
+ closeOnEsc = true,
|
|
|
+ renderCloseButton = defaultRenderCloseButton,
|
|
|
+ closeButtonClassName
|
|
|
+ },
|
|
|
+ children
|
|
|
+) {
|
|
|
function createHandlers (closeDialog) {
|
|
|
function handleKeyDown ({which}) {
|
|
|
(which === 27) && closeDialog();
|
|
@@ -28,9 +40,13 @@ function Dialog ({closeOnEsc = true}, children) {
|
|
|
const elementHandlers = closeOnEsc ? createHandlers(closeDialog) : {};
|
|
|
const {onCreate, onRemove} = elementHandlers;
|
|
|
|
|
|
+ const composedCloseButtonClassName = cx(style.close, closeButtonClassName);
|
|
|
+
|
|
|
return (
|
|
|
<Overlay oncreate={onCreate} onremove={onRemove} onBackgroundClick={closeDialog}>
|
|
|
- <button className={style.close} onclick={closeDialog} />
|
|
|
+ <button className={composedCloseButtonClassName} onclick={closeDialog}>
|
|
|
+ {renderCloseButton()}
|
|
|
+ </button>
|
|
|
|
|
|
<div className={style.content}>
|
|
|
{children}
|