navigation.stories.tsx 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import React from 'react';
  2. import { storiesOf } from '@storybook/react';
  3. import { IconHome, IconHistogram, IconSetting, IconLive, IconUser, IconStar, IconUserGroup } from '@douyinfe/semi-icons';
  4. import Nav from '..';
  5. const stories = storiesOf('Navigation', module);
  6. stories.add(`default`, () => {
  7. const Demo = () => {
  8. let logo = '//lf1-cdn-tos.bytescm.com/obj/ttfe/ies/semi/logo_huoshan.png';
  9. return (
  10. <div style={{ height: '100vh', display: 'inline-block' }}>
  11. <Nav onSelect={(...args: any[]) => console.log(...args)}>
  12. <Nav.Header logo={<img src={logo} />} text={'火山运营'} />
  13. <Nav.Item itemKey={'1'} text={'Option 1'} icon="mail" link="/mail" />
  14. <Nav.Sub text={'Group 2'} icon="folder" itemKey={'2'}>
  15. {['2-1', '2-2'].map(k => (
  16. <Nav.Item key={k} itemKey={String(k)} text={'Option ' + k} link={`folder/${k}`} />
  17. ))}
  18. <Nav.Item itemKey={'2-3'} text={'Option 2-3'} />
  19. <Nav.Sub text={'Group 2-4'} itemKey={'2-4'}>
  20. <Nav.Item itemKey={'2-4-1'} text={'Option 2-3-1'} />
  21. <Nav.Item itemKey={'2-4-2'} text={'Option 2-3-2'} />
  22. </Nav.Sub>
  23. </Nav.Sub>
  24. <Nav.Item key={3} itemKey={'3'} text={'Option 3'} icon="gift" />
  25. <Nav.Item key={4} itemKey={'4'} text={'Option 4'} icon="list" />
  26. <Nav.Sub text={'Group 5'} icon="flag" itemKey={'5'}>
  27. {['5-1', '5-2'].map(k => (
  28. <Nav.Item key={k} itemKey={String(k)} text={'Option ' + k} />
  29. ))}
  30. </Nav.Sub>
  31. <Nav.Footer collapseButton />
  32. </Nav>
  33. </div>
  34. );
  35. };
  36. return <Demo />;
  37. });
  38. stories.add(`fix 35`, () => {
  39. const Demo = () => {
  40. return (
  41. <>
  42. <Nav
  43. style={{ maxWidth: 220, height: '100%' }}
  44. defaultSelectedKeys={['Home']}
  45. items={[
  46. { itemKey: 'Home', text: '首页', icon: <IconHome size="large" /> },
  47. { itemKey: 'Histogram', text: '基础数据', icon: <IconHistogram size="large" /> },
  48. { itemKey: 'Live', text: '测试功能', icon: <IconLive size="large" /> },
  49. { itemKey: 'Setting', text: '设置', icon: <IconSetting size="large" /> },
  50. ]}
  51. footer={{
  52. collapseButton: true,
  53. }}
  54. />
  55. <Nav
  56. bodyStyle={{ height: 320 }}
  57. items={[
  58. { itemKey: 'user', text: '用户管理', icon: <IconUser /> },
  59. { itemKey: 'union', text: '公会中心', icon: <IconStar /> },
  60. {
  61. text: '任务平台',
  62. icon: <IconSetting />,
  63. itemKey: 'job',
  64. items: ['任务管理', '用户任务查询'],
  65. },
  66. ]}
  67. onSelect={data => console.log('trigger onSelect: ', data)}
  68. onClick={data => console.log('trigger onClick: ', data)}
  69. />
  70. <Nav
  71. bodyStyle={{ height: 320 }}
  72. defaultOpenKeys={['user', 'union']}
  73. onSelect={data => console.log('trigger onSelect: ', data)}
  74. onClick={data => console.log('trigger onClick: ', data)}
  75. >
  76. <Nav.Header logo={<img src="https://sf6-cdn-tos.douyinstatic.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/root-web-sites/webcast_logo.svg" />} text={'Semi 运营后台'} />
  77. <Nav.Item itemKey={'union'} text={'公会中心'} icon={<IconStar />} />
  78. <Nav.Sub itemKey={'user'} text="用户管理" icon={<IconUser />}>
  79. <Nav.Item itemKey={'golder'} text={'金主管理'} />
  80. <Nav.Item itemKey={'ban'} text={'用户封禁'} />
  81. </Nav.Sub>
  82. <Nav.Sub itemKey={'union-management'} text="公会管理" icon={<IconUserGroup />}>
  83. <Nav.Item itemKey={'notice'} text={'公告设置'} />
  84. <Nav.Item itemKey={'query'} text={'公会查询'} />
  85. <Nav.Item itemKey={'info'} text={'信息录入'} />
  86. </Nav.Sub>
  87. <Nav.Footer collapseButton={true} />
  88. </Nav>
  89. </>
  90. );
  91. };
  92. return <Demo />;
  93. });