summaryrefslogtreecommitdiff
path: root/frontend/src/components/shared/IconButton.jsx
blob: 3031720a5e415e69eb7ec5ed79a9a678f133de04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//@flow
import { Button, Icon } from '@blueprintjs/core';
import type { IconName } from '@blueprintjs/icons';
import * as React from 'react';

type IconButtonProps = {
  icon: IconName,
  title?: string | false | null,
  [string]: any,
}

export const IconButton = ({icon, title, ...props}: IconButtonProps) => {
  if (title) {
    // this works around https://github.com/palantir/blueprint/issues/2321
    const iconWithoutTitle = <Icon icon={icon} title={false} />;
    return <Button {...props} icon={iconWithoutTitle} title={title} />;
  }
  return <Button {...props} icon={icon} />;
};
bgstack15