blueprint.tsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // Copyright (c) Jupyter Development Team.
  2. // Distributed under the terms of the Modified BSD License.
  3. import * as React from 'react';
  4. import {
  5. Button as BPButton,
  6. IButtonProps as IBPButtonProps
  7. } from '@blueprintjs/core/lib/cjs/components/button/buttons';
  8. import {
  9. Icon as BPIcon,
  10. IIconProps
  11. } from '@blueprintjs/core/lib/cjs/components/icon/icon';
  12. import {
  13. Collapse as BPCollapse,
  14. ICollapseProps
  15. } from '@blueprintjs/core/lib/cjs/components/collapse/collapse';
  16. import {
  17. InputGroup as BPInputGroup,
  18. IInputGroupProps as IBPInputGroupProps
  19. } from '@blueprintjs/core/lib/cjs/components/forms/inputGroup';
  20. import {
  21. Select as BPSelect,
  22. ISelectProps
  23. } from '@blueprintjs/select/lib/cjs/components/select/select';
  24. export { Intent } from '@blueprintjs/core/lib/cjs/common/intent';
  25. import { classes } from './utils';
  26. interface IButtonProps extends IBPButtonProps {
  27. title?: string;
  28. type?: 'button' | 'submit' | 'reset';
  29. }
  30. interface IInputGroupProps extends IBPInputGroupProps {
  31. rightIcon?: IIconProps['icon'];
  32. }
  33. type CommonProps<T> = React.DOMAttributes<T>;
  34. export const Button = (props: IButtonProps & CommonProps<any>) => (
  35. <BPButton
  36. {...props}
  37. className={classes(
  38. props.className,
  39. props.minimal ? 'minimal' : '',
  40. 'jp-Button'
  41. )}
  42. />
  43. );
  44. export const InputGroup = (props: IInputGroupProps & CommonProps<any>) => {
  45. if (props.rightIcon) {
  46. return (
  47. <BPInputGroup
  48. {...props}
  49. className={classes(props.className, 'jp-InputGroup')}
  50. rightElement={
  51. <div className="jp-InputGroupAction">
  52. <BPIcon className={'jp-Icon'} icon={props.rightIcon} />
  53. </div>
  54. }
  55. />
  56. );
  57. }
  58. return (
  59. <BPInputGroup
  60. {...props}
  61. className={classes(props.className, 'jp-InputGroup')}
  62. />
  63. );
  64. };
  65. export const Collapse = (props: ICollapseProps & CommonProps<any>) => (
  66. <BPCollapse {...props} />
  67. );
  68. export const Select = (props: ISelectProps<any> & CommonProps<any>) => (
  69. <BPSelect {...props} className={classes(props.className, 'jp-Select')} />
  70. );