You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

VisitorsCountLabel.tsx 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import React from 'react';
  2. import { useTranslation } from 'react-i18next';
  3. import { useSelector } from 'react-redux';
  4. import { makeStyles } from 'tss-react/mui';
  5. import { IReduxState } from '../../../app/types';
  6. import { IconUsers } from '../../../base/icons/svg';
  7. import Label from '../../../base/label/components/web/Label';
  8. import Tooltip from '../../../base/tooltip/components/Tooltip';
  9. import { getVisitorsShortText, iAmVisitor } from '../../functions';
  10. const useStyles = makeStyles()(theme => {
  11. return {
  12. label: {
  13. backgroundColor: theme.palette.warning02,
  14. color: theme.palette.uiBackground
  15. }
  16. };
  17. });
  18. const VisitorsCountLabel = () => {
  19. const { classes: styles, theme } = useStyles();
  20. const visitorsMode = useSelector((state: IReduxState) => iAmVisitor(state));
  21. const visitorsCount = useSelector((state: IReduxState) =>
  22. state['features/visitors'].count || 0);
  23. const { t } = useTranslation();
  24. return visitorsMode && (<Tooltip
  25. content = { t('visitorsLabel', { count: visitorsCount }) }
  26. position = { 'bottom' }>
  27. <Label
  28. className = { styles.label }
  29. icon = { IconUsers }
  30. iconColor = { theme.palette.icon04 }
  31. id = 'visitorsCountLabel'
  32. text = { `${getVisitorsShortText(visitorsCount)}` } />
  33. </Tooltip>);
  34. };
  35. export default VisitorsCountLabel;