/* * Wire * Copyright (C) 2021 Wire Swiss GmbH * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * */ import {FC, useEffect, useRef} from 'react'; import {TabIndex} from '@wireapp/react-ui-kit/lib/types/enums'; import cx from 'classnames'; import {DraggableClickWrapper} from 'Components/DraggableClickWrapper'; import * as Icon from 'Components/Icon'; import {t} from 'Util/LocalizerUtil'; import {noop} from 'Util/util'; export interface PanelHeaderProps { onClose: () => void; onGoBack?: () => void; className?: string; showBackArrow?: boolean; showActionMute?: boolean; showNotificationsNothing?: boolean; isReverse?: boolean; closeUie?: string; closeBtnTitle?: string; goBackTitle?: string; goBackUie?: string; titleDataUieName?: string; title?: string; handleBlur?: () => void; onToggleMute?: () => void; shouldFocusFirstButton?: boolean; } const PanelHeader: FC = ({ onClose, isReverse, className = '', showBackArrow = true, showActionMute = false, showNotificationsNothing = false, goBackUie = 'back-button', goBackTitle = t('accessibility.rightPanel.GoBack'), title = '', titleDataUieName = '', closeUie = 'do-close', closeBtnTitle = t('accessibility.rightPanel.close'), handleBlur = noop, onGoBack = noop, onToggleMute = noop, shouldFocusFirstButton = true, }: PanelHeaderProps) => { const panelHeaderRef = useRef(null); useEffect(() => { if (!!panelHeaderRef.current && shouldFocusFirstButton) { const nextElementToFocus = panelHeaderRef.current.querySelector('button'); // TO-DO Remove setTimeout after replacing transition group animation libray // triggering focus method without setTimeout is not working due to right side bar animation setTimeout(() => { nextElementToFocus?.focus(); }, 0); } }, [shouldFocusFirstButton]); return (
{showBackArrow && ( onGoBack()}> )} {title && (

{title}

)} {showActionMute && ( )}
); }; export {PanelHeader};