panel-heading.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { FC } from 'react'
  2. import SplitTestBadge from '@/shared/components/split-test-badge'
  3. import MaterialIcon from '@/shared/components/material-icon'
  4. import { useTranslation } from 'react-i18next'
  5. import OLTooltip from '@/shared/components/ol/ol-tooltip'
  6. // TODO ide-redesign-cleanup: Remove this component and only use RailPanelHeader
  7. export const PanelHeading: FC<
  8. React.PropsWithChildren<{
  9. title: string
  10. splitTestName?: string
  11. children?: React.ReactNode
  12. handleClose(): void
  13. }>
  14. > = ({ title, splitTestName, children, handleClose }) => {
  15. const { t } = useTranslation()
  16. return (
  17. <div className="panel-heading">
  18. <div className="panel-heading-label">
  19. <span>{title}</span>
  20. {splitTestName && (
  21. <SplitTestBadge
  22. splitTestName={splitTestName}
  23. displayOnVariants={['enabled']}
  24. />
  25. )}
  26. </div>
  27. {children}
  28. <OLTooltip
  29. id="close-panel"
  30. description={t('close')}
  31. overlayProps={{ placement: 'bottom' }}
  32. >
  33. <button
  34. type="button"
  35. className="btn panel-heading-close-button"
  36. aria-label={t('close')}
  37. onClick={handleClose}
  38. >
  39. <MaterialIcon type="close" />
  40. </button>
  41. </OLTooltip>
  42. </div>
  43. )
  44. }