sideSheet.stories.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import React from 'react';
  2. import { storiesOf } from '@storybook/react';
  3. import SideSheet from '../index';
  4. import Button from '../../button';
  5. const stories = storiesOf('SideSheet', module);
  6. interface IProps {
  7. [x:string]: any;
  8. }
  9. interface IState {
  10. visible: boolean;
  11. }
  12. class Demo extends React.Component<IProps, IState> {
  13. constructor(props:any) {
  14. super(props);
  15. this.state = { visible: false};
  16. }
  17. show() {
  18. this.setState({
  19. visible: true
  20. });
  21. }
  22. handleCancel() {
  23. this.setState({
  24. visible: false
  25. });
  26. }
  27. render() {
  28. const { visible } = this.state;
  29. return (
  30. <>
  31. <Button onClick={() => this.show()}>Open SideSheet</Button>
  32. <SideSheet
  33. title="滑动侧边栏"
  34. visible={visible}
  35. onCancel={() => this.handleCancel()}
  36. >
  37. <p>This is the content of a basic sidesheet.</p>
  38. <p>Here is more content...</p>
  39. </SideSheet>
  40. </>
  41. );
  42. }
  43. }
  44. stories.add('SideSheet', () => (<Demo />
  45. ));