forked from coreui/coreui-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCModalHeader.js
52 lines (41 loc) · 1.04 KB
/
CModalHeader.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
44
45
46
47
48
49
50
51
52
import React, { useContext } from 'react'
import PropTypes from 'prop-types'
import classNames from 'classnames'
import { tagPropType } from '../utils/helper.js'
import { Context } from './CModal'
import CButtonClose from '../button/CButtonClose'
//component - CoreUI / CModalHeader
const CModalHeader = props=>{
const {
tag: Tag,
className,
//
innerRef,
closeButton,
...attributes
} = props
const { close } = useContext(Context)
//render
const classes = classNames(
className,
'modal-header'
)
return (
<Tag className={classes} {...attributes} ref={innerRef}>
{props.children}
{closeButton && <CButtonClose onClick={close}/>}
</Tag>
)
}
CModalHeader.propTypes = {
tag: tagPropType,
children: PropTypes.node,
className: PropTypes.oneOfType([PropTypes.string, PropTypes.array, PropTypes.object]),
//
innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
closeButton: PropTypes.bool
};
CModalHeader.defaultProps = {
tag: 'header'
};
export default CModalHeader