rail-tab.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import OLTooltip from '@/shared/components/ol/ol-tooltip'
  2. import MaterialIcon, {
  3. AvailableUnfilledIcon,
  4. } from '@/shared/components/material-icon'
  5. import classNames from 'classnames'
  6. import { forwardRef, ReactElement } from 'react'
  7. import { NavLink } from 'react-bootstrap'
  8. const RailTab = forwardRef<
  9. HTMLAnchorElement,
  10. {
  11. icon: AvailableUnfilledIcon
  12. eventKey: string
  13. open: boolean
  14. indicator?: ReactElement
  15. title: string
  16. disabled?: boolean
  17. }
  18. >(({ icon, eventKey, open, indicator, title, disabled = false }, ref) => {
  19. return (
  20. <OLTooltip
  21. id={`rail-tab-tooltip-${eventKey}`}
  22. description={title}
  23. overlayProps={{ delay: 0, placement: 'right' }}
  24. >
  25. <NavLink
  26. ref={ref}
  27. eventKey={eventKey}
  28. className={classNames('ide-rail-tab-link', {
  29. 'open-rail': open,
  30. })}
  31. disabled={disabled}
  32. >
  33. {open ? (
  34. <MaterialIcon
  35. className="ide-rail-tab-link-icon"
  36. type={icon}
  37. accessibilityLabel={title}
  38. />
  39. ) : (
  40. <MaterialIcon
  41. className="ide-rail-tab-link-icon"
  42. type={icon}
  43. accessibilityLabel={title}
  44. unfilled
  45. />
  46. )}
  47. {indicator}
  48. </NavLink>
  49. </OLTooltip>
  50. )
  51. })
  52. RailTab.displayName = 'RailTab'
  53. export default RailTab