您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Label.web.js 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // @flow
  2. import React from 'react';
  3. import Icon from '../../icons/components/Icon';
  4. import AbstractLabel, {
  5. type Props as AbstractProps
  6. } from './AbstractLabel';
  7. type Props = AbstractProps & {
  8. /**
  9. * Additional CSS class names to add to the root of {@code Label}.
  10. */
  11. className: string,
  12. /**
  13. * HTML ID attribute to add to the root of {@code Label}.
  14. */
  15. id: string
  16. };
  17. /**
  18. * React Component for showing short text in a circle.
  19. *
  20. * @extends Component
  21. */
  22. export default class Label extends AbstractLabel<Props, *> {
  23. /**
  24. * Implements React's {@link Component#render()}.
  25. *
  26. * @inheritdoc
  27. */
  28. render() {
  29. const {
  30. className,
  31. icon,
  32. id,
  33. text
  34. } = this.props;
  35. const labelClassName = icon ? 'label-text-with-icon' : '';
  36. return (
  37. <div
  38. className = { `label ${className}` }
  39. id = { id }>
  40. { icon && <Icon
  41. size = '16'
  42. src = { icon } /> }
  43. { text && <span className = { labelClassName }>{text}</span> }
  44. </div>
  45. );
  46. }
  47. }