SideMenu.tsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import React, { useState } from 'react';
  2. import { Button, Input, Space } from 'antd';
  3. import { ReactComponent as SvgLogo } from '@/icons/logo.svg';
  4. import './styles/side-menu.less';
  5. import { SearchOutlined } from '@ant-design/icons';
  6. import ProList from '@ant-design/pro-list';
  7. interface SideMenuProps {
  8. onCollaped: (isExpanded: boolean)=> void,
  9. initWidth: number
  10. }
  11. function SideMenu ({
  12. initWidth = 200,
  13. }: SideMenuProps) {
  14. const [activeKey, setActiveKey] = useState<string | number>('');
  15. const data = [
  16. {
  17. teacherName: '张三',
  18. schoolName: '清华大学',
  19. },
  20. {
  21. teacherName: '李四',
  22. schoolName: '北京大学',
  23. },
  24. {
  25. teacherName: '王五',
  26. schoolName: '南京大学',
  27. },
  28. {
  29. teacherName: '麻六',
  30. schoolName: '上海大学',
  31. }
  32. ].map((item) => ({
  33. title: item.teacherName,
  34. description: item.schoolName,
  35. actions: [],
  36. avatar: false,
  37. }));
  38. return (
  39. <div style={{ width: initWidth, height: '100vh' }}>
  40. <div className="side-header">
  41. <SvgLogo style={{ fill: 'currentColor' }} className="header-logo" />
  42. <h3 className="header-title-text">评审管理系统</h3>
  43. </div>
  44. <div className="side-search">
  45. <div
  46. style={{
  47. color: 'black',
  48. fontSize: 16,
  49. fontWeight: 'bold',
  50. margin: '20px 0 20px 10px',
  51. textAlign: 'left',
  52. }}
  53. >
  54. 参评教师
  55. </div>
  56. <Space direction="horizontal" style={{ padding: '0 10px' }}>
  57. <Input placeholder="输入教师姓名搜索" />
  58. <Button icon={<SearchOutlined />} type="primary" />
  59. </Space>
  60. </div>
  61. <div className="menu-area">
  62. <ProList<any>
  63. pagination={false}
  64. showActions="hover"
  65. onItem={(record) => {
  66. return {
  67. onClick: () => {
  68. setActiveKey(record.title);
  69. },
  70. };
  71. }}
  72. rowClassName={(record: { title: string }) =>
  73. record.title === activeKey ? 'active' : ''
  74. }
  75. metas={{
  76. title: {},
  77. description: {
  78. render: (text) => <div style={{ textAlign: 'left' }}>{text}</div>,
  79. },
  80. avatar: {},
  81. }}
  82. dataSource={data}
  83. />
  84. </div>
  85. </div>
  86. );
  87. }
  88. export default SideMenu;