blueprint.tsx 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. import {
  25. Checkbox as BPCheckbox,
  26. ICheckboxProps
  27. } from '@blueprintjs/core/lib/cjs/components/forms/controls';
  28. export { Intent } from '@blueprintjs/core/lib/cjs/common/intent';
  29. import { classes } from './utils';
  30. interface IButtonProps extends IBPButtonProps {
  31. title?: string;
  32. type?: 'button' | 'submit' | 'reset';
  33. }
  34. interface IInputGroupProps extends IBPInputGroupProps {
  35. rightIcon?: IIconProps['icon'];
  36. }
  37. type CommonProps<T> = React.DOMAttributes<T>;
  38. export const Button = (props: IButtonProps & CommonProps<any>) => (
  39. <BPButton
  40. {...props}
  41. className={classes(
  42. props.className,
  43. props.minimal ? 'minimal' : '',
  44. 'jp-Button'
  45. )}
  46. />
  47. );
  48. export const InputGroup = (props: IInputGroupProps & CommonProps<any>) => {
  49. if (props.rightIcon) {
  50. return (
  51. <BPInputGroup
  52. {...props}
  53. className={classes(props.className, 'jp-InputGroup')}
  54. rightElement={
  55. <div className="jp-InputGroupAction">
  56. <BPIcon className={'jp-BPIcon'} icon={props.rightIcon} />
  57. </div>
  58. }
  59. />
  60. );
  61. }
  62. return (
  63. <BPInputGroup
  64. {...props}
  65. className={classes(props.className, 'jp-InputGroup')}
  66. />
  67. );
  68. };
  69. export const Collapse = (props: ICollapseProps & CommonProps<any>) => (
  70. <BPCollapse {...props} />
  71. );
  72. export const Select = (props: ISelectProps<any> & CommonProps<any>) => (
  73. <BPSelect {...props} className={classes(props.className, 'jp-Select')} />
  74. );
  75. export const Checkbox = (props: ICheckboxProps & CommonProps<any>) => (
  76. <BPCheckbox {...props} className={classes(props.className, 'jp-Checkbox')} />
  77. );