2023-04-25 23:27:54 +02:00
|
|
|
import React from 'react';
|
|
|
|
import classnames from 'classnames';
|
2023-07-17 23:00:16 +02:00
|
|
|
import { HeaderBase, Text, ButtonIcon, ButtonIconSize, IconName } from '..';
|
2023-04-25 23:27:54 +02:00
|
|
|
import {
|
|
|
|
TextVariant,
|
|
|
|
TextAlign,
|
|
|
|
} from '../../../helpers/constants/design-system';
|
|
|
|
import { useI18nContext } from '../../../hooks/useI18nContext';
|
|
|
|
import { ModalHeaderProps } from '.';
|
|
|
|
|
|
|
|
export const ModalHeader: React.FC<ModalHeaderProps> = ({
|
|
|
|
children,
|
|
|
|
className = '',
|
|
|
|
startAccessory,
|
|
|
|
endAccessory,
|
|
|
|
onClose,
|
|
|
|
closeButtonProps,
|
|
|
|
onBack,
|
|
|
|
backButtonProps,
|
|
|
|
...props
|
|
|
|
}) => {
|
|
|
|
const t = useI18nContext();
|
|
|
|
return (
|
|
|
|
<HeaderBase
|
|
|
|
className={classnames('mm-modal-header', className)}
|
|
|
|
startAccessory={
|
|
|
|
startAccessory ||
|
|
|
|
(onBack && (
|
|
|
|
<ButtonIcon
|
|
|
|
iconName={IconName.ArrowLeft}
|
|
|
|
ariaLabel={t('back')}
|
|
|
|
size={ButtonIconSize.Sm}
|
|
|
|
onClick={onBack}
|
|
|
|
{...backButtonProps}
|
|
|
|
/>
|
|
|
|
))
|
|
|
|
}
|
|
|
|
endAccessory={
|
|
|
|
endAccessory ||
|
|
|
|
(onClose && (
|
|
|
|
<ButtonIcon
|
|
|
|
iconName={IconName.Close}
|
|
|
|
ariaLabel={t('close')}
|
|
|
|
size={ButtonIconSize.Sm}
|
|
|
|
onClick={onClose}
|
|
|
|
{...closeButtonProps}
|
|
|
|
/>
|
|
|
|
))
|
|
|
|
}
|
|
|
|
{...props}
|
|
|
|
>
|
|
|
|
{typeof children === 'string' ? (
|
2023-05-09 23:09:10 +02:00
|
|
|
<Text
|
2023-07-17 23:00:16 +02:00
|
|
|
as="header"
|
2023-05-09 23:09:10 +02:00
|
|
|
variant={TextVariant.headingSm}
|
|
|
|
textAlign={TextAlign.Center}
|
|
|
|
>
|
2023-04-25 23:27:54 +02:00
|
|
|
{children}
|
|
|
|
</Text>
|
|
|
|
) : (
|
|
|
|
children
|
|
|
|
)}
|
|
|
|
</HeaderBase>
|
|
|
|
);
|
|
|
|
};
|