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.

ToolboxButtonWithIcon.js 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // @flow
  2. import React from 'react';
  3. import { Icon } from '../../icons';
  4. type Props = {
  5. /**
  6. * The decorated component (ToolboxButton).
  7. */
  8. children: React$Node,
  9. /**
  10. * Icon of the button.
  11. */
  12. icon: Function,
  13. /**
  14. * Flag used for disabling the small icon.
  15. */
  16. iconDisabled: boolean,
  17. /**
  18. * Click handler for the small icon.
  19. */
  20. onIconClick: Function,
  21. /**
  22. * Additional styles.
  23. */
  24. styles?: Object,
  25. }
  26. /**
  27. * Displayes the `ToolboxButtonWithIcon` component.
  28. *
  29. * @returns {ReactElement}
  30. */
  31. export default function ToolboxButtonWithIcon({
  32. children,
  33. icon,
  34. iconDisabled,
  35. onIconClick,
  36. styles
  37. }: Props) {
  38. const iconProps = {};
  39. if (iconDisabled) {
  40. iconProps.className = 'settings-button-small-icon settings-button-small-icon--disabled';
  41. } else {
  42. iconProps.className = 'settings-button-small-icon';
  43. iconProps.onClick = onIconClick;
  44. }
  45. return (
  46. <div
  47. className = 'settings-button-container'
  48. styles = { styles }>
  49. { children }
  50. <Icon
  51. { ...iconProps }
  52. size = { 9 }
  53. src = { icon } />
  54. </div>
  55. );
  56. }