tooltip.stories.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import React from 'react';
  2. import {storiesOf} from '@storybook/react';
  3. import {withInfo} from '@storybook/addon-info';
  4. import {text, boolean, select} from '@storybook/addon-knobs';
  5. import Tooltip from 'app/components/tooltip';
  6. import Button from 'app/components/button';
  7. class CustomThing extends React.Component {
  8. render() {
  9. return <span>A class component with no ref</span>;
  10. }
  11. }
  12. storiesOf('UI|Tooltip', module)
  13. .add(
  14. 'Tooltip',
  15. withInfo({
  16. text: 'Adds a tooltip to any component,',
  17. propTablesExclude: [CustomThing, Button, 'Button'],
  18. })(() => {
  19. const title = text('tooltip', 'Basic tooltip content');
  20. const disabled = boolean('Disabled', false);
  21. const displayMode = select('Container display mode', ['block', 'inline-block', 'inline']);
  22. const position = select(
  23. 'position',
  24. {top: 'top', bottom: 'bottom', left: 'left', right: 'right'},
  25. 'top'
  26. );
  27. return (
  28. <React.Fragment>
  29. <h3>With styled component trigger</h3>
  30. <p>
  31. <Tooltip title={title} position={position} disabled={disabled} containerDisplayMode={displayMode}>
  32. <Button>Styled button</Button>
  33. </Tooltip>
  34. </p>
  35. <h3>With class component trigger</h3>
  36. <p>
  37. <Tooltip title={title} position={position} disabled={disabled}>
  38. <CustomThing>Custom React Component</CustomThing>
  39. </Tooltip>
  40. </p>
  41. <h3>With an SVG element trigger</h3>
  42. <p>
  43. <svg
  44. viewBox="0 0 100 100"
  45. width="100"
  46. height="100"
  47. xmlns="http://www.w3.org/2000/svg"
  48. >
  49. <Tooltip title={title} position={position} disabled={disabled} containerDisplayMode={displayMode}>
  50. <circle cx="50" cy="50" r="50" />
  51. </Tooltip>
  52. </svg>
  53. </p>
  54. <h3>With element title and native html element</h3>
  55. <p>
  56. <Tooltip
  57. title={
  58. <span>
  59. <em>so strong</em>
  60. </span>
  61. }
  62. containerDisplayMode={displayMode}
  63. position={position}
  64. disabled={disabled}
  65. >
  66. <button>Native button</button>
  67. </Tooltip>
  68. </p>
  69. </React.Fragment>
  70. );
  71. })
  72. );