Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import { Theme } from '@mui/material';
  2. import React from 'react';
  3. import { makeStyles } from 'tss-react/mui';
  4. import Icon from '../../../icons/components/Icon';
  5. import { withPixelLineHeight } from '../../../styles/functions.web';
  6. import { COLORS } from '../../constants';
  7. interface IProps {
  8. /**
  9. * Own CSS class name.
  10. */
  11. className?: string;
  12. /**
  13. * The color of the label.
  14. */
  15. color?: string;
  16. /**
  17. * An SVG icon to be rendered as the content of the label.
  18. */
  19. icon?: Function;
  20. /**
  21. * Color for the icon.
  22. */
  23. iconColor?: string;
  24. /**
  25. * HTML ID attribute to add to the root of {@code Label}.
  26. */
  27. id?: string;
  28. /**
  29. * Click handler if any.
  30. */
  31. onClick?: (e?: React.MouseEvent) => void;
  32. /**
  33. * String or component that will be rendered as the label itself.
  34. */
  35. text?: string;
  36. }
  37. const useStyles = makeStyles()((theme: Theme) => {
  38. return {
  39. label: {
  40. ...withPixelLineHeight(theme.typography.labelRegular),
  41. alignItems: 'center',
  42. background: theme.palette.ui04,
  43. borderRadius: Number(theme.shape.borderRadius) / 2,
  44. color: theme.palette.text01,
  45. display: 'flex',
  46. height: 28,
  47. margin: '0 0 4px 4px',
  48. padding: '0 8px'
  49. },
  50. withIcon: {
  51. marginLeft: 8
  52. },
  53. clickable: {
  54. cursor: 'pointer'
  55. },
  56. [COLORS.white]: {
  57. background: theme.palette.text01,
  58. color: theme.palette.ui04,
  59. '& svg': {
  60. fill: theme.palette.ui04
  61. }
  62. },
  63. [COLORS.green]: {
  64. background: theme.palette.success02
  65. },
  66. [COLORS.red]: {
  67. background: theme.palette.actionDanger
  68. }
  69. };
  70. });
  71. const Label = ({
  72. className,
  73. color,
  74. icon,
  75. iconColor,
  76. id,
  77. onClick,
  78. text
  79. }: IProps) => {
  80. const { classes, cx } = useStyles();
  81. return (
  82. <div
  83. className = { cx(classes.label, onClick && classes.clickable,
  84. color && classes[color], className
  85. ) }
  86. id = { id }
  87. onClick = { onClick }>
  88. {icon && <Icon
  89. color = { iconColor }
  90. size = '16'
  91. src = { icon } />}
  92. {text && <span className = { icon && classes.withIcon }>{text}</span>}
  93. </div>
  94. );
  95. };
  96. export default Label;