index.stories.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import React, { useMemo } from 'react';
  2. import { Button, Typography, Card, Tooltip, Tag, Avatar, Rating, Nav, Layout } from '../../index';
  3. import { IconHelpCircle, IconUser, IconStar, IconSetting } from '@douyinfe/semi-icons';
  4. import './index.scss';
  5. export default {
  6. title: 'Base',
  7. };
  8. export {
  9. TestAlwaysDarkLight
  10. };
  11. const TestAlwaysDarkLight = () => {
  12. function Demo() {
  13. const { Text } = Typography;
  14. const { Header, Footer, Sider, Content } = Layout;
  15. const switchMode = () => {
  16. const body = document.body;
  17. if (body.hasAttribute('theme-mode')) {
  18. body.removeAttribute('theme-mode');
  19. // 通知官网更新当前模式,下同
  20. // window.setMode("light");
  21. } else {
  22. body.setAttribute('theme-mode', 'dark');
  23. // window.setMode("dark");
  24. }
  25. };
  26. const opts = {
  27. content: 'Hi, Bytedance dance dance',
  28. duration: 3,
  29. };
  30. const blocks = title => (
  31. <Layout>
  32. <Header style={{ height: 60 }}>Header</Header>
  33. <Layout style={{ height: 'calc(100vh - 260px)' }}>
  34. <Sider style={{ background: 'var(--semi-color-white)' }}>
  35. <div class="semi-always-light">
  36. <Nav
  37. style={{ background: 'var(--semi-color-white)' }}
  38. // bodyStyle={{ height: '100%' }}
  39. items={[
  40. { itemKey: 'user', text: '用户管理', icon: <IconUser /> },
  41. { itemKey: 'union', text: '公会中心', icon: <IconStar /> },
  42. {
  43. text: '任务平台',
  44. icon: <IconSetting />,
  45. itemKey: 'job',
  46. items: ['任务管理', '用户任务查询'],
  47. },
  48. ]}
  49. onSelect={data => console.log('trigger onSelect: ', data)}
  50. onClick={data => console.log('trigger onClick: ', data)}
  51. />
  52. </div>
  53. </Sider>
  54. <Content>
  55. <Card
  56. title={`Semi Design ${title}`}
  57. style={{ maxWidth: 360, marginRight: 12 }}
  58. headerExtraContent={<Text link>更多</Text>}
  59. >
  60. Semi Design 是由互娱社区前端团队与 UED
  61. 团队共同设计开发并维护的设计系统。设计系统包含设计语言以及一整套可复用的前端组件,帮助设计师与开发者更容易地打造高质量的、用户体验一致的、符合设计规范的
  62. Web 应用。
  63. <Tooltip content={'hi bytedance'}>
  64. <IconHelpCircle />
  65. </Tooltip>
  66. </Card>
  67. <div>
  68. <div>
  69. <Avatar style={{ margin: 4 }}>AS</Avatar>
  70. <Avatar color="red" style={{ margin: 4 }}>
  71. BM
  72. </Avatar>
  73. <Avatar color="light-blue" style={{ margin: 4 }}>
  74. TJ
  75. </Avatar>
  76. <Avatar style={{ color: '#f56a00', backgroundColor: '#fde3cf', margin: 4 }}>
  77. ZL
  78. </Avatar>
  79. <Avatar style={{ backgroundColor: '#87d068', margin: 4 }}>YZ</Avatar>
  80. </div>
  81. <Tag> default tag </Tag>
  82. <Rating defaultValue={5} />
  83. </div>
  84. </Content>
  85. </Layout>
  86. <Footer
  87. style={{
  88. height: 200,
  89. background: 'var(--semi-color-black)',
  90. color: 'var(--semi-color-white)',
  91. }}
  92. >
  93. Footer
  94. </Footer>
  95. </Layout>
  96. );
  97. return (
  98. <div className="container">
  99. <div>
  100. <Button onClick={switchMode}>Switch Mode</Button>
  101. </div>
  102. <div>
  103. <div>{blocks('default')}</div>
  104. {/* <div id="semi-always-dark">{blocks('always dark')}</div>
  105. <div id="semi-always-light">{blocks('always light')}</div> */}
  106. </div>
  107. </div>
  108. );
  109. }
  110. return <Demo />;
  111. };