1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 09:57:02 +01:00
metamask-extension/ui/components/component-library/picker-network/picker-network.tsx
Dhruv 658ceb90d1
Fix-Migrate Picker-Network to TS (#20365)
* migrating PickerNetwork to TS

* deleting js file

* deleting js snapshot

* fixing e2e tests and updating snapshot

* updating snapshot

* Some small updates to docs and types

---------

Co-authored-by: georgewrmarshall <george.marshall@consensys.net>
Co-authored-by: Garrett Bear <gwhisten@gmail.com>
2023-08-04 10:11:55 -07:00

73 lines
1.7 KiB
TypeScript

import React from 'react';
import classnames from 'classnames';
import {
AlignItems,
BorderRadius,
TextVariant,
IconColor,
BackgroundColor,
Display,
} from '../../../helpers/constants/design-system';
import {
AvatarNetwork,
AvatarNetworkSize,
Box,
IconName,
Icon,
IconSize,
Text,
} from '..';
import { BoxProps, PolymorphicRef } from '../box';
import {
PickerNetworkComponent,
PickerNetworkProps,
} from './picker-network.types';
export const PickerNetwork: PickerNetworkComponent = React.forwardRef(
<C extends React.ElementType = 'button'>(
{
className = '',
avatarNetworkProps,
iconProps,
label,
src,
...props
}: PickerNetworkProps<C>,
ref?: PolymorphicRef<C>,
) => {
return (
<Box
className={classnames('mm-picker-network', className)}
ref={ref}
as="button"
backgroundColor={BackgroundColor.backgroundAlternative}
alignItems={AlignItems.center}
paddingLeft={2}
paddingRight={4}
gap={2}
borderRadius={BorderRadius.pill}
display={Display.Flex}
{...(props as BoxProps<C>)}
>
<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>
);
},
);