mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-25 11:28:51 +01:00
5d17f86e02
* Updating component-librar import paths * Updating snapshots * Updates to AvatarBase story * Updates to avatar and checkbox * Updating last of the deprecated import paths * Updating component-library snapshots from button-base * Updating snapshots from rest of codebase to do with button-base * Removing unneeded CSS * Updating snapshots
66 lines
1.5 KiB
TypeScript
66 lines
1.5 KiB
TypeScript
import React from 'react';
|
|
import classnames from 'classnames';
|
|
import { HeaderBase, Text, ButtonIcon, ButtonIconSize, IconName } from '..';
|
|
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' ? (
|
|
<Text
|
|
as="header"
|
|
variant={TextVariant.headingSm}
|
|
textAlign={TextAlign.Center}
|
|
>
|
|
{children}
|
|
</Text>
|
|
) : (
|
|
children
|
|
)}
|
|
</HeaderBase>
|
|
);
|
|
};
|