BetterScrollbar.tsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import React from 'react';
  2. import { Table, Tooltip, Tag, Space, Typography, Switch } from '../../index';
  3. import RTLWrapper from '../../configProvider/_story/RTLDirection/RTLWrapper';
  4. function App() {
  5. const [bordered, setBordered] = React.useState(true);
  6. const columns = [
  7. {
  8. title: 'Name',
  9. dataIndex: 'name',
  10. width: 150,
  11. fixed: true,
  12. filters: [
  13. {
  14. text: 'Code 45',
  15. value: '45',
  16. },
  17. {
  18. text: 'King 4',
  19. value: 'King 4',
  20. },
  21. ],
  22. onFilter: (value, record) => record.name.includes(value),
  23. },
  24. {
  25. title: 'Age',
  26. dataIndex: 'age',
  27. fixed: true,
  28. width: 150,
  29. sorter: (a, b) => (a.age - b.age > 0 ? 1 : -1),
  30. },
  31. {
  32. title: 'Address',
  33. width: 200,
  34. dataIndex: 'address',
  35. },
  36. // {
  37. // title: 'Address2',
  38. // width: 200,
  39. // dataIndex: 'address',
  40. // },
  41. // {
  42. // title: 'Address3',
  43. // width: 200,
  44. // dataIndex: 'address',
  45. // },
  46. // {
  47. // title: 'Address4',
  48. // width: 200,
  49. // dataIndex: 'address',
  50. // },
  51. // {
  52. // title: 'Address5',
  53. // width: 200,
  54. // dataIndex: 'address',
  55. // },
  56. {
  57. fixed: 'right' as const,
  58. width: 250,
  59. render: (text, record) => (
  60. <Tooltip content={record.description}>
  61. <Tag color="green">Show Info</Tag>
  62. </Tooltip>
  63. ),
  64. },
  65. ];
  66. const data = [];
  67. for (let i = 0; i < 10; i++) {
  68. const age = (i * 1000) % 149 ;
  69. const name = `Edward King ${i}`;
  70. data.push({
  71. key: `${ i}`,
  72. name,
  73. age,
  74. address: `London, Park Lane no. ${i}`,
  75. description: `My name is ${name}, I am ${age} years old, living in New York No. ${i + 1} Lake Park.`,
  76. });
  77. }
  78. const allColumnsWidth = columns.reduce((count, column) => count + column.width, 0);
  79. const tableProps = {
  80. pagination: false,
  81. columns,
  82. bordered,
  83. dataSource: data,
  84. };
  85. return (
  86. <RTLWrapper>
  87. <div style={{ textAlign: 'left', marginBottom: 12 }}>
  88. <Space>
  89. <Typography.Title heading={6}>边框</Typography.Title>
  90. <Switch onChange={() => setBordered(!bordered)} checked={bordered} />
  91. </Space>
  92. </div>
  93. <Table
  94. {...tableProps}
  95. scroll={{ y: 400 }}
  96. />
  97. <br />
  98. <Table
  99. {...tableProps}
  100. title="虚拟化表格"
  101. scroll={{ y: 400, x: allColumnsWidth }}
  102. style={{ width: allColumnsWidth }}
  103. virtualized
  104. />
  105. </RTLWrapper>
  106. );
  107. }
  108. export default App;