LeftMenu.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import React from 'react'
  2. type LeftMenuProps = {
  3. title?: string
  4. options: { label: string; value: string }[]
  5. onChange: (key: string) => void
  6. value: string
  7. }
  8. const LeftMenu: React.FC<LeftMenuProps> = ({ title = '栏目/功能', options, onChange, value }) => {
  9. return (
  10. <div className="h-full w-max-234px rounded-4px shadow-card">
  11. <div className="p-4 border-b-1 border-solid border-black border-opacity-10 bg-[#f7f9fa] text-left">
  12. <span>{title}</span>
  13. </div>
  14. <div className="p-4 bg-white" style={{ height: 'calc(100vh - 201px)' }}>
  15. <ul className="p-0 m-0 list-none text-primary flex flex-col flex-1">
  16. {options.map(item => (
  17. <li
  18. key={item.value}
  19. className={[
  20. 'flex justify-between items-center py-2 px-5 cursor-pointer',
  21. item.value === value ? 'scale-up-center' : ''
  22. ].join(' ')}
  23. onClick={() => onChange(item.value)}>
  24. {item.label}
  25. </li>
  26. ))}
  27. </ul>
  28. </div>
  29. </div>
  30. )
  31. }
  32. export default LeftMenu