1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/ui/components/component-library/popover-header/popover-header.tsx
2023-07-14 10:59:30 -07:00

71 lines
1.6 KiB
TypeScript

import React from 'react';
import classnames from 'classnames';
import { HeaderBase, ButtonIcon, ButtonIconSize, IconName } from '..';
import { Text } from '../text/deprecated';
import {
IconColor,
TextVariant,
TextAlign,
Color,
} from '../../../helpers/constants/design-system';
import { useI18nContext } from '../../../hooks/useI18nContext';
import { PopoverHeaderProps } from '.';
export const PopoverHeader: React.FC<PopoverHeaderProps> = ({
children,
className = '',
startAccessory,
endAccessory,
onClose,
closeButtonProps,
onBack,
backButtonProps,
...props
}) => {
const t = useI18nContext();
return (
<HeaderBase
className={classnames('mm-popover-header', className)}
startAccessory={
startAccessory ||
(onBack && (
<ButtonIcon
iconName={IconName.ArrowLeft}
color={IconColor.inherit}
ariaLabel={t('back')}
size={ButtonIconSize.Sm}
onClick={onBack}
{...backButtonProps}
/>
))
}
endAccessory={
endAccessory ||
(onClose && (
<ButtonIcon
iconName={IconName.Close}
color={IconColor.inherit}
ariaLabel={t('close')}
size={ButtonIconSize.Sm}
onClick={onClose}
{...closeButtonProps}
/>
))
}
{...props}
>
{typeof children === 'string' ? (
<Text
variant={TextVariant.headingSm}
textAlign={TextAlign.Center}
color={Color.inherit}
>
{children}
</Text>
) : (
children
)}
</HeaderBase>
);
};