ShowTitleMenu.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import React, { useState } from 'react'
  2. import '@/pages/Role/System/components/RoleMenu/index.less'
  3. interface ShowTitleMenuProps {
  4. itemTitle: string
  5. onSelect?: (vaule: string) => void
  6. }
  7. const showTitleMenu: React.FC<ShowTitleMenuProps> = ({ itemTitle, onSelect }) => {
  8. const [activeId, setActiveId] = useState('')
  9. const handleItemClick = (id: string) => {
  10. setActiveId(id)
  11. if (onSelect) {
  12. onSelect(id)
  13. }
  14. }
  15. return (
  16. <div className="h-full w-max-234px rounded-4px shadow-card">
  17. <div className="p-4 border-b-1 border-solid border-black border-opacity-10 bg-[#f7f9fa] justify-around text-left">
  18. <span>栏目/功能</span>
  19. </div>
  20. <div className="p-4 bg-white" style={{ height: 'calc(100% - 1rem*2 - 20px)' }}>
  21. <ul className="p-0 m-0 list-none text-primary flex flex-col flex-1">
  22. {itemTitle.map(item => (
  23. <li
  24. key={item.value}
  25. className={[
  26. 'flex justify-between items-center py-2 px-5 cursor-pointer',
  27. item.value === activeId ? 'scale-up-center' : ''
  28. ].join(' ')}
  29. onClick={() => handleItemClick(item.value)}>
  30. {item.label}
  31. </li>
  32. ))}
  33. </ul>
  34. </div>
  35. </div>
  36. )
  37. }
  38. export default showTitleMenu