aboutsummaryrefslogtreecommitdiffstats
path: root/src/react/ModalHeader.js
blob: c6be5ef8100f14c90706f79539f99b3e9cbb09d1 (plain)
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
import React from 'react';
import PropTypes from 'prop-types';
import SVGIcon from './SVGIcon.js';

const iconMaper = {
	error: 'error',
	info: 'errorCircle',
	alert: 'exclamationTriangleLine'
};

const headerTypes = {
    error: 'sdc-error__header',
    info: 'sdc-info__header',
    alert: 'sdc-alert__header',
    custom: 'sdc-custom__header'
}



const Header = ({children, onClose, type}) => (
    <div className={ headerTypes[type] + ' sdc-modal__header'} >
        {type !== 'custom'
            &&  
                    <SVGIcon iconClassName='sdc-modal__icon' className='sdc-modal__svg-use'  name={iconMaper[type]}/>   
                 
        } 
        {children}
        <SVGIcon iconClassName ='sdc-modal__close-button-svg' className='sdc-modal__close-button' onClick={onClose} name='close'/>        
    </div>
);

Header.propTypes = {
	children: PropTypes.node,
	onClose: PropTypes.func
};

Header.defaultProps = {
	type: 'info'
};

export default Header;