HealthyIndexLegend.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { makeStyles, Theme } from '@material-ui/core';
  2. import { HEALTHY_INDEX_ROW_HEIGHT, HEALTHY_STATUS_COLORS } from './consts';
  3. import { EHealthyStatus } from './Types';
  4. const legendData = [
  5. {
  6. label: 'NoData',
  7. value: EHealthyStatus.noData,
  8. },
  9. {
  10. label: 'Healthy',
  11. value: EHealthyStatus.healthy,
  12. },
  13. {
  14. label: 'Warning',
  15. value: EHealthyStatus.warning,
  16. },
  17. {
  18. label: 'Failed',
  19. value: EHealthyStatus.failed,
  20. },
  21. ];
  22. const getStyles = makeStyles((theme: Theme) => ({
  23. legendItem: {
  24. display: 'flex',
  25. marginLeft: '12px',
  26. fontSize: '10px',
  27. alignItems: 'flex-end',
  28. },
  29. legendIcon: {
  30. width: '16px',
  31. borderRadius: '1px',
  32. },
  33. legendText: { marginLeft: '8px', fontWeight: 500, color: '#666' },
  34. }));
  35. const HealthyIndexLegend = () => {
  36. const classes = getStyles();
  37. return (
  38. <>
  39. {legendData.map(legend => (
  40. <div className={classes.legendItem}>
  41. <div
  42. className={classes.legendIcon}
  43. style={{
  44. background: HEALTHY_STATUS_COLORS[legend.value],
  45. height: `${HEALTHY_INDEX_ROW_HEIGHT * 0.8}px`,
  46. }}
  47. ></div>
  48. <div className={classes.legendText}>{legend.label}</div>
  49. </div>
  50. ))}
  51. </>
  52. );
  53. };
  54. export default HealthyIndexLegend;