1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 02:10:12 +01:00
metamask-extension/ui/components/multichain/account-picker/account-picker.js
George Marshall 36be38e979
Update Text import paths: /multichain (#20061)
* Updating import paths for Text component

* Updating snapshots

* Adding story for TokenCell

* Updating banner in account details

* Fixing lint issue by removing unused import
2023-07-17 22:02:02 -07:00

80 lines
1.9 KiB
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import { useSelector } from 'react-redux';
import {
Button,
AvatarAccount,
AvatarAccountVariant,
Icon,
IconName,
Text,
} from '../../component-library';
import {
AlignItems,
BackgroundColor,
BorderRadius,
Display,
FontWeight,
IconColor,
Size,
} from '../../../helpers/constants/design-system';
export const AccountPicker = ({ address, name, onClick, disabled }) => {
const useBlockie = useSelector((state) => state.metamask.useBlockie);
return (
<Button
className="multichain-account-picker"
data-testid="account-menu-icon"
onClick={onClick}
backgroundColor={BackgroundColor.transparent}
borderRadius={BorderRadius.LG}
ellipsis
textProps={{
display: Display.Flex,
gap: 2,
alignItems: AlignItems.center,
}}
disabled={disabled}
>
<AvatarAccount
variant={
useBlockie
? AvatarAccountVariant.Blockies
: AvatarAccountVariant.Jazzicon
}
address={address}
size={Size.XS}
borderColor={BackgroundColor.backgroundDefault} // we currently don't have white color for border hence using backgroundDefault as the border
/>
<Text as="span" fontWeight={FontWeight.Bold} ellipsis>
{name}
</Text>
<Icon
name={IconName.ArrowDown}
color={IconColor.iconDefault}
size={Size.SM}
/>
</Button>
);
};
AccountPicker.propTypes = {
/**
* Account name
*/
name: PropTypes.string.isRequired,
/**
* Account address, used for blockie or jazzicon
*/
address: PropTypes.string.isRequired,
/**
* Action to perform when the account picker is clicked
*/
onClick: PropTypes.func.isRequired,
/**
* Represents if the AccountPicker should be actionable
*/
disabled: PropTypes.bool.isRequired,
};