index.stories.jsx 3.9 KB

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