1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-01 21:57:06 +01:00
metamask-extension/ui/components/multichain/account-picker/account-picker.js

73 lines
1.6 KiB
JavaScript
Raw Normal View History

UX: Multichain: Account Picker (#18177) * UX: Multichain: Account Picker * Update ui/components/multichain/account-picker/index.js Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Update ui/components/multichain/account-picker/index.js Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Update ui/components/multichain/account-picker/index.js Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Update ui/components/multichain/account-picker/index.js Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Cleanup * Move file names to DS standard * Add index for export * Add MULTICHAIN flag * Fix hover color * Fix lint * Use BackgroundColor instead of Color * Add comments for propTypes * Provide args properly * Implement onClick arg * Fix alignment * Update ui/components/multichain/account-picker/account-picker.js * Update ui/components/multichain/account-picker/account-picker.js * Update ui/components/multichain/account-picker/account-picker.js * Update ui/components/multichain/account-picker/account-picker.js * Update ui/components/multichain/account-picker/account-picker.js * Only use account name and address, account for blockies or jazzicons * Add test * Fix jest change * Fix CSS locations * Update ui/components/multichain/account-picker/account-picker.js Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Update ui/components/multichain/account-picker/account-picker.js Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Update ui/components/multichain/account-picker/account-picker.js Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Update snapshot * Update border radius * Fix jest * Switch to using Button --------- Co-authored-by: Garrett Bear <gwhisten@gmail.com>
2023-03-30 20:11:13 +02:00
import React from 'react';
import PropTypes from 'prop-types';
import { useSelector } from 'react-redux';
import {
Button,
AvatarAccount,
AvatarAccountVariant,
Icon,
IconName,
UX: Multichain: Account Picker (#18177) * UX: Multichain: Account Picker * Update ui/components/multichain/account-picker/index.js Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Update ui/components/multichain/account-picker/index.js Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Update ui/components/multichain/account-picker/index.js Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Update ui/components/multichain/account-picker/index.js Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Cleanup * Move file names to DS standard * Add index for export * Add MULTICHAIN flag * Fix hover color * Fix lint * Use BackgroundColor instead of Color * Add comments for propTypes * Provide args properly * Implement onClick arg * Fix alignment * Update ui/components/multichain/account-picker/account-picker.js * Update ui/components/multichain/account-picker/account-picker.js * Update ui/components/multichain/account-picker/account-picker.js * Update ui/components/multichain/account-picker/account-picker.js * Update ui/components/multichain/account-picker/account-picker.js * Only use account name and address, account for blockies or jazzicons * Add test * Fix jest change * Fix CSS locations * Update ui/components/multichain/account-picker/account-picker.js Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Update ui/components/multichain/account-picker/account-picker.js Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Update ui/components/multichain/account-picker/account-picker.js Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Update snapshot * Update border radius * Fix jest * Switch to using Button --------- Co-authored-by: Garrett Bear <gwhisten@gmail.com>
2023-03-30 20:11:13 +02:00
Text,
} from '../../component-library';
import {
AlignItems,
BackgroundColor,
BorderRadius,
DISPLAY,
FONT_WEIGHT,
IconColor,
Size,
} from '../../../helpers/constants/design-system';
export const AccountPicker = ({ address, name, onClick }) => {
const useBlockie = useSelector((state) => state.metamask.useBlockie);
return (
<Button
className="multichain-account-picker"
onClick={onClick}
backgroundColor={BackgroundColor.transparent}
borderRadius={BorderRadius.LG}
ellipsis
textProps={{
display: DISPLAY.FLEX,
gap: 2,
alignItems: AlignItems.center,
}}
>
<AvatarAccount
variant={
useBlockie
? AvatarAccountVariant.Blockies
: AvatarAccountVariant.Jazzicon
}
address={address}
size={Size.SM}
/>
<Text as="span" fontWeight={FONT_WEIGHT.BOLD} ellipsis>
{name}
</Text>
<Icon
name={IconName.ArrowDown}
UX: Multichain: Account Picker (#18177) * UX: Multichain: Account Picker * Update ui/components/multichain/account-picker/index.js Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Update ui/components/multichain/account-picker/index.js Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Update ui/components/multichain/account-picker/index.js Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Update ui/components/multichain/account-picker/index.js Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Cleanup * Move file names to DS standard * Add index for export * Add MULTICHAIN flag * Fix hover color * Fix lint * Use BackgroundColor instead of Color * Add comments for propTypes * Provide args properly * Implement onClick arg * Fix alignment * Update ui/components/multichain/account-picker/account-picker.js * Update ui/components/multichain/account-picker/account-picker.js * Update ui/components/multichain/account-picker/account-picker.js * Update ui/components/multichain/account-picker/account-picker.js * Update ui/components/multichain/account-picker/account-picker.js * Only use account name and address, account for blockies or jazzicons * Add test * Fix jest change * Fix CSS locations * Update ui/components/multichain/account-picker/account-picker.js Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Update ui/components/multichain/account-picker/account-picker.js Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Update ui/components/multichain/account-picker/account-picker.js Co-authored-by: Garrett Bear <gwhisten@gmail.com> * Update snapshot * Update border radius * Fix jest * Switch to using Button --------- Co-authored-by: Garrett Bear <gwhisten@gmail.com>
2023-03-30 20:11:13 +02:00
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,
};