blueprint.tsx 2.2 KB

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