bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/banner-bar/component.jsx

38 lines
899 B
React
Raw Normal View History

2021-07-12 21:22:26 +08:00
import React, { useEffect } from 'react';
2019-03-16 04:07:14 +08:00
import PropTypes from 'prop-types';
import NotificationsBar from '/imports/ui/components/notifications-bar/component';
import { styles } from './styles';
2021-07-12 21:22:26 +08:00
import { ACTIONS } from '../layout/enums';
2019-03-16 04:07:14 +08:00
2021-08-09 22:24:02 +08:00
const BannerBar = ({
text, color, hasBanner: propsHasBanner, layoutContextDispatch,
}) => {
2021-07-12 21:22:26 +08:00
useEffect(() => {
const localHasBanner = !!text;
2021-08-09 22:24:02 +08:00
if (localHasBanner !== propsHasBanner) {
2021-08-05 19:03:24 +08:00
layoutContextDispatch({
2021-07-12 21:22:26 +08:00
type: ACTIONS.SET_HAS_BANNER_BAR,
value: localHasBanner,
});
}
}, [text, propsHasBanner]);
if (!text) return null;
return (
<NotificationsBar color={color}>
<span className={styles.bannerTextColor}>
{text}
</span>
</NotificationsBar>
);
2021-08-09 22:24:02 +08:00
};
2019-03-16 04:07:14 +08:00
BannerBar.propTypes = {
2019-03-19 02:10:27 +08:00
text: PropTypes.string.isRequired,
color: PropTypes.string.isRequired,
2019-03-16 04:07:14 +08:00
};
export default BannerBar;