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
|
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { observer } from 'mobx-react';
import classnames from 'classnames';
import Loader from 'react-loader';
// import { oneOrManyChildElements } from '../../prop-types';
import Appear from './effects/Appear';
export default @observer class InfoBar extends Component {
static propTypes = {
// eslint-disable-next-line
children: PropTypes.any.isRequired,
onClick: PropTypes.func,
type: PropTypes.string,
className: PropTypes.string,
ctaLabel: PropTypes.string,
ctaLoading: PropTypes.bool,
position: PropTypes.string,
sticky: PropTypes.bool,
onHide: PropTypes.func,
};
static defaultProps = {
onClick: () => null,
type: 'primary',
className: '',
ctaLabel: '',
ctaLoading: false,
position: 'bottom',
sticky: false,
onHide: () => null,
};
render() {
const {
children,
type,
className,
ctaLabel,
ctaLoading,
onClick,
position,
sticky,
onHide,
} = this.props;
let transitionName = 'slideUp';
if (position === 'top') {
transitionName = 'slideDown';
}
return (
<Appear
transitionName={transitionName}
className={classnames({
'info-bar': true,
[`info-bar--${type}`]: true,
[`info-bar--${position}`]: true,
[`${className}`]: true,
})}
>
<div className="info-bar__content">
{children}
{ctaLabel && (
<button
type="button"
className="info-bar__cta"
onClick={onClick}
>
<Loader
loaded={!ctaLoading}
lines={10}
scale={0.3}
color="#FFF"
component="span"
/>
{ctaLabel}
</button>
)}
</div>
{!sticky && (
<button
type="button"
className="info-bar__close mdi mdi-close"
onClick={onHide}
/>
)}
</Appear>
);
}
}
|