overleaf-cep/services/web/frontend/js/shared/components/panel-heading.tsx
David f0d2df3c43 Merge pull request #27040 from overleaf/dp-file-tree-close-button
Add close button to file tree rail panel

GitOrigin-RevId: d8abac122e266922b9ca914bc5df6ae7895b3796
2025-07-11 08:06:19 +00:00

46 lines
1.2 KiB
TypeScript

import { FC } from 'react'
import SplitTestBadge from '@/shared/components/split-test-badge'
import MaterialIcon from '@/shared/components/material-icon'
import { useTranslation } from 'react-i18next'
import OLTooltip from '@/features/ui/components/ol/ol-tooltip'
export const PanelHeading: FC<
React.PropsWithChildren<{
title: string
splitTestName?: string
children?: React.ReactNode
handleClose(): void
}>
> = ({ title, splitTestName, children, handleClose }) => {
const { t } = useTranslation()
return (
<div className="panel-heading">
<div className="panel-heading-label">
<span>{title}</span>
{splitTestName && (
<SplitTestBadge
splitTestName={splitTestName}
displayOnVariants={['enabled']}
/>
)}
</div>
{children}
<OLTooltip
id="close-panel"
description={t('close')}
overlayProps={{ placement: 'bottom' }}
>
<button
type="button"
className="btn panel-heading-close-button"
aria-label={t('close')}
onClick={handleClose}
>
<MaterialIcon type="close" />
</button>
</OLTooltip>
</div>
)
}