index.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import React from 'react'
  2. import type { FC } from 'react'
  3. import NavLink from './navLink'
  4. import AppBasic from './basic'
  5. export type IAppDetailNavProps = {
  6. iconType?: 'app' | 'dataset'
  7. title: string
  8. desc: string
  9. navigation: Array<{
  10. name: string
  11. href: string
  12. icon: any
  13. selectedIcon: any
  14. }>
  15. extraInfo?: React.ReactNode
  16. }
  17. const sampleAppIconUrl = 'https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80'
  18. const AppDetailNav: FC<IAppDetailNavProps> = ({ title, desc, navigation, extraInfo, iconType = 'app' }) => {
  19. return (
  20. <div className="flex flex-col w-56 overflow-y-auto bg-white border-r border-gray-200 shrink-0">
  21. <div className="flex flex-shrink-0 p-4">
  22. <AppBasic iconType={iconType} iconUrl={sampleAppIconUrl} name={title} type={desc} />
  23. </div>
  24. <nav className="flex-1 p-4 space-y-1 bg-white">
  25. {navigation.map((item, index) => {
  26. return (
  27. <NavLink key={index} iconMap={{ selected: item.selectedIcon, normal: item.icon }} name={item.name} href={item.href} />
  28. )
  29. })}
  30. {extraInfo ?? null}
  31. </nav>
  32. </div>
  33. )
  34. }
  35. export default React.memo(AppDetailNav)