panel-heading.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 '@/features/ui/components/ol/ol-tooltip'
  6. export const PanelHeading: FC<
  7. React.PropsWithChildren<{
  8. title: string
  9. splitTestName?: string
  10. children?: React.ReactNode
  11. handleClose(): void
  12. }>
  13. > = ({ title, splitTestName, children, handleClose }) => {
  14. const { t } = useTranslation()
  15. return (
  16. <div className="panel-heading">
  17. <div className="panel-heading-label">
  18. <span>{title}</span>
  19. {splitTestName && (
  20. <SplitTestBadge
  21. splitTestName={splitTestName}
  22. displayOnVariants={['enabled']}
  23. />
  24. )}
  25. </div>
  26. {children}
  27. <OLTooltip
  28. id="close-panel"
  29. description={t('close')}
  30. overlayProps={{ placement: 'bottom' }}
  31. >
  32. <button
  33. type="button"
  34. className="btn panel-heading-close-button"
  35. aria-label={t('close')}
  36. onClick={handleClose}
  37. >
  38. <MaterialIcon type="close" />
  39. </button>
  40. </OLTooltip>
  41. </div>
  42. )
  43. }