2017-09-26 07:45:44 +08:00
|
|
|
import React from 'react';
|
2017-06-04 10:40:14 +08:00
|
|
|
import PropTypes from 'prop-types';
|
2017-09-26 07:45:44 +08:00
|
|
|
import injectWbResizeEvent from '/imports/ui/components/presentation/resize-wrapper/component';
|
2021-10-27 21:46:08 +08:00
|
|
|
import Styled from './styles';
|
2016-08-10 00:28:16 +08:00
|
|
|
|
|
|
|
const COLORS = [
|
|
|
|
'default', 'primary', 'danger', 'success',
|
|
|
|
];
|
|
|
|
|
|
|
|
const propTypes = {
|
2019-03-16 04:07:14 +08:00
|
|
|
color: PropTypes.string,
|
2016-08-10 00:28:16 +08:00
|
|
|
};
|
|
|
|
|
2024-06-11 21:05:08 +08:00
|
|
|
const NotificationsBar = ({
|
|
|
|
color = 'default',
|
|
|
|
children,
|
|
|
|
alert,
|
|
|
|
}) => {
|
2019-04-05 03:40:19 +08:00
|
|
|
const hasColor = COLORS.includes(color);
|
2017-09-26 07:45:44 +08:00
|
|
|
|
|
|
|
return (
|
2021-10-27 21:46:08 +08:00
|
|
|
<Styled.NotificationsBar
|
2022-01-20 21:03:18 +08:00
|
|
|
data-test="notificationBannerBar"
|
2019-03-16 04:07:14 +08:00
|
|
|
role={alert ? 'alert' : ''}
|
2019-02-15 22:44:57 +08:00
|
|
|
aria-live="off"
|
2019-03-16 04:07:14 +08:00
|
|
|
style={
|
|
|
|
!hasColor ? {
|
|
|
|
backgroundColor: `${color}`,
|
|
|
|
} : {}
|
2021-10-27 21:46:08 +08:00
|
|
|
}
|
|
|
|
color={color}
|
2017-09-26 07:45:44 +08:00
|
|
|
>
|
2019-01-24 00:13:03 +08:00
|
|
|
{children}
|
2021-10-27 21:46:08 +08:00
|
|
|
</Styled.NotificationsBar>
|
2017-09-26 07:45:44 +08:00
|
|
|
);
|
|
|
|
};
|
2016-08-10 00:28:16 +08:00
|
|
|
|
|
|
|
NotificationsBar.propTypes = propTypes;
|
2017-09-26 07:45:44 +08:00
|
|
|
|
|
|
|
export default injectWbResizeEvent(NotificationsBar);
|