1
0
mirror of https://github.com/yldio/copilot.git synced 2024-09-22 14:23:50 +03:00
copilot/ui/src/components/notification/index.js

84 lines
1.5 KiB
JavaScript
Raw Normal View History

const constants = require('../../shared/constants');
const fns = require('../../shared/functions');
2017-01-10 18:52:08 +02:00
const composers = require('../../shared/composers');
const React = require('react');
const Styled = require('styled-components');
const Close = require('../close');
const {
colors
} = constants;
const {
remcalc
} = fns;
const {
default: styled
} = Styled;
2017-01-10 18:52:08 +02:00
const {
baseBox,
pseudoEl
} = composers;
2017-01-10 18:52:08 +02:00
const decorationWidth = remcalc(108);
const StyledNotification = styled.div`
display: inline-block;
2017-01-10 18:52:08 +02:00
min-height: 100%;
position: relative;
width: 100%;
2017-01-10 18:52:08 +02:00
${baseBox(0)}
&::before {
background-color: ${props => colors[props.type] || colors.brandPrimary}
width: ${decorationWidth};
height: 100%;
${pseudoEl()}
}
`;
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%;
`;
const Notificaton = ({
children,
className,
style,
type,
close
}) => {
const renderClose = close ? (<Close onClick={close} />) : null;
return (
<StyledNotification
className={className}
style={style}
type={type}
>
{ renderClose }
<StyledContent>
{children}
</StyledContent>
</StyledNotification>
);
};
Notificaton.propTypes = {
children: React.PropTypes.object,
className: React.PropTypes.str,
close: React.PropTypes.func,
style: React.PropTypes.object,
2017-01-10 18:52:08 +02:00
type: React.PropTypes.string
};
module.exports = Notificaton;