index.jsx 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import React from 'react';
  2. import { Table, Avatar } from '@douyinfe/semi-ui';
  3. import { IconMore } from '@douyinfe/semi-icons';
  4. const columns = [
  5. {
  6. title: '标题',
  7. width: 500,
  8. dataIndex: 'name',
  9. render: (text, record, index) => {
  10. return (
  11. <span>
  12. <Avatar size="small" shape="square" src={record.nameIconSrc} style={{ marginRight: 12 }}></Avatar>
  13. {text}
  14. </span>
  15. );
  16. },
  17. },
  18. {
  19. title: '大小',
  20. dataIndex: 'size',
  21. },
  22. {
  23. title: '所有者',
  24. dataIndex: 'owner',
  25. render: (text, record, index) => {
  26. return (
  27. <div>
  28. <Avatar size="small" color={record.avatarBg} style={{ marginRight: 4 }}>
  29. {typeof text === 'string' && text.slice(0, 1)}
  30. </Avatar>
  31. {text}
  32. </div>
  33. );
  34. },
  35. },
  36. {
  37. title: '更新日期',
  38. dataIndex: 'updateTime',
  39. },
  40. {
  41. title: '',
  42. dataIndex: 'operate',
  43. render: () => {
  44. return <IconMore />;
  45. },
  46. },
  47. ];
  48. const data = [
  49. {
  50. key: '1',
  51. name: 'Semi Design 设计稿.fig',
  52. nameIconSrc: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/figma-icon.png',
  53. size: '2M',
  54. owner: '姜鹏志',
  55. updateTime: '2020-02-02 05:13',
  56. avatarBg: 'grey',
  57. },
  58. {
  59. key: '2',
  60. name: 'Semi Design 分享演示文稿',
  61. nameIconSrc: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/docs-icon.png',
  62. size: '2M',
  63. owner: '郝宣',
  64. updateTime: '2020-01-17 05:31',
  65. avatarBg: 'red',
  66. },
  67. {
  68. key: '3',
  69. name: '设计文档',
  70. nameIconSrc: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/docs-icon.png',
  71. size: '34KB',
  72. owner: 'Zoey Edwards',
  73. updateTime: '2020-01-26 11:01',
  74. avatarBg: 'light-blue',
  75. },
  76. ];
  77. export default function App() {
  78. const expandRowRender = (record, index) => {
  79. console.log('render', index);
  80. return <div>semi design</div>;
  81. };
  82. return (
  83. <Table
  84. rowKey="name"
  85. columns={columns}
  86. dataSource={data}
  87. expandedRowRender={expandRowRender}
  88. pagination={false}
  89. />
  90. );
  91. }