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.

CircularLabel.web.js 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // @flow
  2. import React from 'react';
  3. import Icon from '../../icons/components/Icon';
  4. import AbstractCircularLabel, {
  5. type Props as AbstractProps
  6. } from './AbstractCircularLabel';
  7. type Props = AbstractProps & {
  8. /**
  9. * Additional CSS class names to add to the root of {@code CircularLabel}.
  10. */
  11. className: string,
  12. /**
  13. * HTML ID attribute to add to the root of {@code CircularLabel}.
  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 CircularLabel extends AbstractCircularLabel<Props, {}> {
  23. /**
  24. * Default values for {@code CircularLabel} component's properties.
  25. *
  26. * @static
  27. */
  28. static defaultProps = {
  29. className: ''
  30. };
  31. /**
  32. * Implements React's {@link Component#render()}.
  33. *
  34. * @inheritdoc
  35. * @returns {ReactElement}
  36. */
  37. render() {
  38. const {
  39. className,
  40. icon,
  41. id,
  42. label
  43. } = this.props;
  44. const labelComponent = icon
  45. ? (
  46. <Icon
  47. src = { icon } />
  48. ) : label;
  49. return (
  50. <div
  51. className = { `circular-label ${className}` }
  52. id = { id }>
  53. { labelComponent }
  54. </div>
  55. );
  56. }
  57. }