index.tsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import * as React from "react";
  2. import * as ReactDOM from "react-dom";
  3. import { LayoutDemo } from './NormalLayout/index';
  4. import { SortedTable } from "./SortedTable/index";
  5. import { SortedTableWithStatic } from "./StaticHeader/index";
  6. import { LayoutRestore } from "./LayoutRestore/index";
  7. import { HandleLayout } from "./HandleLayout/index";
  8. import { AddRemove } from "./AddRemove/index";
  9. import './index.css'
  10. const DemoMap: any = {
  11. normalLayout: <LayoutDemo />,
  12. SortedTable: <SortedTable />,
  13. StaticHeader: <SortedTableWithStatic />,
  14. LayoutRestore: <LayoutRestore />,
  15. HandleLayout: <HandleLayout />,
  16. AddRemove: <AddRemove />
  17. }
  18. class DemoDispatcher extends React.Component<{}, {}> {
  19. state = {
  20. demo: <LayoutDemo />
  21. }
  22. handleLayoutChange = (demoName: string) => {
  23. this.setState({
  24. demo: DemoMap[demoName]
  25. })
  26. }
  27. render() {
  28. return (
  29. <div>
  30. <div className='demo-button-layout'>
  31. <div>Switch Demos</div>
  32. <button onClick={() => this.handleLayoutChange('normalLayout')}>normalLayout</button>
  33. <button onClick={() => this.handleLayoutChange('SortedTable')}>SortedTable</button>
  34. <button onClick={() => this.handleLayoutChange('StaticHeader')}>StaticHeader</button>
  35. <button onClick={() => this.handleLayoutChange('LayoutRestore')}>LayoutRestore</button>
  36. <button onClick={() => this.handleLayoutChange('HandleLayout')}>HandleLayout</button>
  37. <button onClick={() => this.handleLayoutChange('AddRemove')}>AddRemove</button>
  38. </div>
  39. {this.state.demo}
  40. </div>
  41. )
  42. }
  43. }
  44. ReactDOM.render(
  45. <DemoDispatcher />,
  46. document.getElementById('root')
  47. );