-
Notifications
You must be signed in to change notification settings - Fork 342
/
ConfirmModal.tsx
140 lines (127 loc) · 3.95 KB
/
ConfirmModal.tsx
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import React, { PureComponent } from 'react'
import cx from 'classnames'
import Icon from '@worldbrain/memex-common/lib/common-ui/components/icon'
import * as icons from 'src/common-ui/components/design-library/icons'
import Modal, { Props as ModalProps } from './Modal'
import LoadingIndicator from '@worldbrain/memex-common/lib/common-ui/components/loading-indicator'
import styled from 'styled-components'
export interface Props extends ModalProps {
isShown: boolean
message?: string
isLoading?: boolean
submessage?: string
type?: string
icon?: string
}
class ConfirmModal extends PureComponent<Props> {
render() {
if (!this.props.isShown) {
return null
}
return (
<Modal onClose={this.props.onClose} {...this.props}>
{this.props.isLoading ? (
<LoadingSpinnerBox>
<LoadingIndicator />
</LoadingSpinnerBox>
) : (
<ContentBox>
{this.props.icon && (
<IconContainer type={this.props.type}>
<Icon
filePath={this.props.icon}
heightAndWidth={'24px'}
color={'white'}
hoverOff
/>
</IconContainer>
)}
<TextContainer>
{this.props.message && (
<MessageContainer>
<SectionTitle>
{this.props.message}
</SectionTitle>
{this.props.submessage && (
<InfoText>
{this.props.submessage}
</InfoText>
)}
</MessageContainer>
)}
</TextContainer>
<ButtonBar>{this.props.children}</ButtonBar>
</ContentBox>
)}
</Modal>
)
}
}
const IconContainer = styled.div<{
type: string
}>`
height: 48px;
width: 48px;
border-radius: 8px;
background: ${(props) => props.theme.colors.greyScale2};
border: 1px solid
${(props) =>
props.type === 'alert'
? props.theme.colors.warning
: props.theme.colors.prime1};
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 15px;
`
const ContentBox = styled.div`
height: 100%;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
`
const TextContainer = styled.div`
display: flex;
align-items: center;
text-align: center;
font-size: 16px;
font-weight: 500;
margin-bottom: 30px;
`
const ButtonBar = styled.div`
display: flex;
justify-content: center;
flex-direction: row-reverse;
outline: none;
`
const MessageContainer = styled.div`
display: flex;
flex-direction: column;
grid-gap: 10px;
justify-content: center;
`
const SectionTitle = styled.div`
background: ${(props) => props.theme.colors.headerGradient};
font-size: 30px;
font-weight: 800;
margin-bottom: 10px;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
text-align: left;
`
const InfoText = styled.div`
color: ${(props) => props.theme.colors.greyScale5};
font-size: 18px;
font-weight: 300;
text-align: center;
margin-bottom: 20px;
`
const LoadingSpinnerBox = styled.div`
display: flex;
justify-content: center;
align-items: center;
`
export default ConfirmModal