2016-12-12 01:43:41 +02:00
|
|
|
const constants = require('../../shared/constants');
|
2017-01-10 18:52:08 +02:00
|
|
|
const composers = require('../../shared/composers');
|
2017-02-15 03:19:26 +02:00
|
|
|
const fns = require('../../shared/functions');
|
2016-11-28 19:53:40 +02:00
|
|
|
const React = require('react');
|
2016-12-12 01:43:41 +02:00
|
|
|
const Styled = require('styled-components');
|
2017-01-10 19:13:54 +02:00
|
|
|
const Close = require('../close');
|
2016-12-12 01:43:41 +02:00
|
|
|
|
|
|
|
const {
|
|
|
|
colors
|
|
|
|
} = constants;
|
|
|
|
|
|
|
|
const {
|
|
|
|
remcalc
|
|
|
|
} = fns;
|
|
|
|
|
|
|
|
const {
|
|
|
|
default: styled
|
|
|
|
} = Styled;
|
|
|
|
|
2017-01-10 18:52:08 +02:00
|
|
|
const {
|
|
|
|
baseBox,
|
2017-02-15 03:19:26 +02:00
|
|
|
pseudoEl,
|
|
|
|
Baseline
|
2017-01-10 18:52:08 +02:00
|
|
|
} = composers;
|
2016-12-12 01:43:41 +02:00
|
|
|
|
2017-01-10 18:52:08 +02:00
|
|
|
const decorationWidth = remcalc(108);
|
2016-12-12 01:43:41 +02:00
|
|
|
|
|
|
|
const StyledNotification = styled.div`
|
|
|
|
display: inline-block;
|
2017-01-10 18:52:08 +02:00
|
|
|
min-height: 100%;
|
|
|
|
position: relative;
|
|
|
|
width: 100%;
|
2016-12-12 01:43:41 +02:00
|
|
|
|
2017-01-10 18:52:08 +02:00
|
|
|
${baseBox(0)}
|
2017-02-15 03:19:26 +02:00
|
|
|
|
2017-01-10 18:52:08 +02:00
|
|
|
&::before {
|
|
|
|
background-color: ${props => colors[props.type] || colors.brandPrimary}
|
|
|
|
width: ${decorationWidth};
|
|
|
|
height: 100%;
|
2017-02-15 03:19:26 +02:00
|
|
|
|
2017-01-10 18:52:08 +02:00
|
|
|
${pseudoEl()}
|
|
|
|
}
|
2016-12-12 01:43:41 +02:00
|
|
|
`;
|
|
|
|
|
|
|
|
const StyledContent = styled.div`
|
|
|
|
float: left;
|
2017-01-10 18:52:08 +02:00
|
|
|
padding: ${remcalc(18)} 20% ${remcalc(18)} ${remcalc(18)};
|
|
|
|
margin-left: ${decorationWidth};
|
|
|
|
width: 100%;
|
2016-12-12 01:43:41 +02:00
|
|
|
`;
|
2016-11-28 19:53:40 +02:00
|
|
|
|
|
|
|
const Notificaton = ({
|
|
|
|
children,
|
|
|
|
className,
|
|
|
|
style,
|
2017-01-10 19:13:54 +02:00
|
|
|
type,
|
|
|
|
close
|
2016-11-28 19:53:40 +02:00
|
|
|
}) => {
|
2017-02-15 03:19:26 +02:00
|
|
|
const renderClose = !close ? null : (
|
|
|
|
<Close onClick={close} />
|
|
|
|
);
|
2017-01-10 19:13:54 +02:00
|
|
|
|
2016-11-28 19:53:40 +02:00
|
|
|
return (
|
2016-12-12 01:43:41 +02:00
|
|
|
<StyledNotification
|
|
|
|
className={className}
|
2016-11-28 19:53:40 +02:00
|
|
|
style={style}
|
|
|
|
type={type}
|
|
|
|
>
|
2017-02-15 03:19:26 +02:00
|
|
|
{renderClose}
|
2016-12-12 01:43:41 +02:00
|
|
|
<StyledContent>
|
2016-11-28 19:53:40 +02:00
|
|
|
{children}
|
2016-12-12 01:43:41 +02:00
|
|
|
</StyledContent>
|
|
|
|
</StyledNotification>
|
2016-11-28 19:53:40 +02:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
Notificaton.propTypes = {
|
|
|
|
children: React.PropTypes.object,
|
|
|
|
className: React.PropTypes.str,
|
2017-01-10 19:13:54 +02:00
|
|
|
close: React.PropTypes.func,
|
2016-11-28 19:53:40 +02:00
|
|
|
style: React.PropTypes.object,
|
2017-01-10 18:52:08 +02:00
|
|
|
type: React.PropTypes.string
|
2016-11-28 19:53:40 +02:00
|
|
|
};
|
|
|
|
|
2017-02-15 03:19:26 +02:00
|
|
|
module.exports = Baseline(
|
|
|
|
Notificaton
|
|
|
|
);
|