Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import React, { Fragment } from 'react'
import styled from 'styled-components'
import { th } from '@pubsweet/ui-toolkit'
import { H2, Button, Spinner } from '@pubsweet/ui'
import { compose, setDisplayName, withHandlers } from 'recompose'
import Text from '../Text'
import IconButton from '../IconButton'
const MultiAction = ({
title,
content,
onClose,
subtitle,
onConfirm,
modalError,
isFetching,
confirmText = 'OK',
cancelText = 'Cancel',
}) => (
<Root>
<IconButton icon="x" onClick={onClose} right={5} secondary top={5} />
<H2>{title}</H2>
{subtitle && <Text secondary>{subtitle}</Text>}
<Text dangerouslySetInnerHTML={{ __html: content }} />
<Buttons isFetching={isFetching}>
{isFetching ? (
<Spinner size={3} />
) : (
<Fragment>
<Button onClick={onClose}>{cancelText}</Button>
<Button onClick={onConfirm} primary>
{confirmText}
</Button>
</Fragment>
)}
</Buttons>
</Root>
)
export default compose(
withHandlers({
onClose: ({ onCancel, hideModal }) => () => {
if (onCancel && typeof onCancel === 'function') {
onCancel()
} else {
hideModal()
}
},
}),
setDisplayName('MultiActionModal'),
)(MultiAction)
// #region styles
const Root = styled.div`
align-items: center;
border: ${th('borderWidth')} ${th('borderStyle')} transparent;
border-radius: ${th('borderRadius')};
box-shadow: ${th('boxShadow')};
display: flex;
flex-direction: column;
position: relative;
padding: calc(${th('gridUnit')} * 5);
width: calc(${th('gridUnit')} * 60);
${H2} {
margin: 0 0 ${th('gridUnit')} 0;
}
${Text} {
margin-bottom: ${th('gridUnit')};
}
`
const Buttons = styled.div`
display: flex;
justify-content: ${props => (props.isFetching ? 'center' : 'space-between')};
margin-top: calc(${th('gridUnit')} * 3);
width: 60%;
`
// #endregion