-
Notifications
You must be signed in to change notification settings - Fork 395
/
ActionModal.js
43 lines (39 loc) · 1.26 KB
/
ActionModal.js
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
import PropTypes from 'prop-types'
import React from 'react'
import Dialog from 'part:@sanity/components/dialogs/fullscreen'
import FileIcon from 'part:@sanity/base/file-icon'
import styles from './styles/ActionModal.css'
import DialogContent from 'part:@sanity/components/dialogs/content'
import CreateDocumentList from 'part:@sanity/components/lists/create-document'
function ActionModal(props) {
const {title, actions, onClose} = props
return (
<Dialog className={styles.modal} onClose={onClose} isOpen padding="none">
<div className={styles.contentWrapper}>
<DialogContent size="auto" padding="medium">
<h1 className={styles.title}>{title}</h1>
<div className={styles.listContainer}>
<CreateDocumentList
items={actions.map((action, i) => ({
...action,
key: `actionModal_${i}`,
icon: action.icon || FileIcon,
onClick: onClose
}))}
/>
</div>
</DialogContent>
</div>
</Dialog>
)
}
ActionModal.defaultProps = {
title: 'Create new',
actions: []
}
ActionModal.propTypes = {
title: PropTypes.string,
actions: PropTypes.array,
onClose: PropTypes.func.isRequired
}
export default ActionModal