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/picker-network/picker-network.js
Binij Shrestha ceadfacb21
Fix/18884 migrate avatar network (#19079)
* Migrate AvatarNetwokr

fixing error

fix textAlign

added AvatarNetworkSize

NetworkProps extends BaseProps instead of Boxprops

omitted children from base, made name required

replace deprecated and fix lint

* update AvatarNetwork TS

* add AvatarNetworkSize test

* remove unused size import

* Update ui/components/component-library/avatar-network/avatar-network.types.ts

Co-authored-by: George Marshall <georgewrmarshall@gmail.com>

* fix readme

* update to latest box component

---------

Co-authored-by: garrettbear <gwhisten@gmail.com>
Co-authored-by: George Marshall <georgewrmarshall@gmail.com>
2023-07-24 11:15:33 -07:00

90 lines
1.9 KiB
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import {
AlignItems,
DISPLAY,
BorderRadius,
TextVariant,
IconColor,
BackgroundColor,
} from '../../../helpers/constants/design-system';
import Box from '../../ui/box';
import {
AvatarNetwork,
AvatarNetworkSize,
IconName,
Icon,
IconSize,
Text,
} from '..';
export const PickerNetwork = ({
className,
avatarNetworkProps,
iconProps,
label,
src,
...props
}) => {
return (
<Box
className={classnames('mm-picker-network', className)}
as="button"
backgroundColor={BackgroundColor.backgroundAlternative}
alignItems={AlignItems.center}
paddingLeft={2}
paddingRight={4}
gap={2}
borderRadius={BorderRadius.pill}
display={DISPLAY.FLEX}
{...props}
>
<AvatarNetwork
className="mm-picker-network__avatar-network"
src={src}
name={label}
size={AvatarNetworkSize.Xs}
{...avatarNetworkProps}
/>
<Text ellipsis variant={TextVariant.bodySm}>
{label}
</Text>
<Icon
className="mm-picker-network__arrow-down-icon"
name={IconName.ArrowDown}
color={IconColor.iconDefault}
size={IconSize.Xs}
{...iconProps}
/>
</Box>
);
};
PickerNetwork.propTypes = {
/**
* The src accepts the string of the image to be rendered
*/
src: PropTypes.string,
/**
* An additional className to apply to the PickerNetwork.
*/
className: PropTypes.string,
/**
* It accepts all the props from AvatarNetwork
*/
avatarNetworkProps: PropTypes.object,
/**
* It accepts all the props from Icon
*/
iconProps: PropTypes.object,
/**
* The text content of the PickerNetwork component
*/
label: PropTypes.string.isRequired,
/**
* PickerNetwork accepts all the props from Box
*/
...Box.propTypes,
};