Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated 1 NetworkDisplay component #20825

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
752731c
Updated 1 NetworkDisplay component
MaxwellDG Sep 12, 2023
ec8828f
Updated snapshots and linting
MaxwellDG Sep 12, 2023
5f952c2
App header snapshot
MaxwellDG Sep 12, 2023
49b461f
Removed all PickerNetwork component changes and instead did the work …
MaxwellDG Sep 13, 2023
7ad22c3
Updated snapshots
MaxwellDG Sep 13, 2023
29d5969
Linting
MaxwellDG Sep 13, 2023
f3fb8a3
Linting
MaxwellDG Sep 13, 2023
9de19cf
Merge branch 'develop' into update/picker-network
MaxwellDG Sep 20, 2023
0e8a815
Slight changes to props
MaxwellDG Sep 21, 2023
82b5a60
Added snapshot
MaxwellDG Sep 21, 2023
c7ad1bf
Removing extra styles and adding image functionality to PickerNetwork…
georgewrmarshall Sep 23, 2023
f215462
Snapshot
MaxwellDG Sep 26, 2023
48b0407
Merge remote-tracking branch 'upstream/develop' into update/picker-ne…
MaxwellDG Sep 26, 2023
8f41d27
Snapshot update
MaxwellDG Sep 26, 2023
288f782
Merge branch 'upstream/develop' into update/picker-network
MaxwellDG Oct 13, 2023
c789d80
Merge branch 'upstream/develop' into update/picker-network
MaxwellDG Oct 29, 2023
27904b0
updated snapshot
MaxwellDG Oct 29, 2023
5b5fee1
Data testid for e2e passing
MaxwellDG Oct 30, 2023
9615d47
Snapshot
MaxwellDG Oct 30, 2023
790cbbb
data test id did more damage than good
MaxwellDG Oct 30, 2023
cbafa81
Merge branch 'develop' into update/picker-network
MaxwellDG Oct 31, 2023
04cbb91
Merge branch 'develop' into update/picker-network
georgewrmarshall Oct 31, 2023
aa32e95
Merge branch 'develop' into update/picker-network
MaxwellDG Nov 1, 2023
a4c6e2e
Merge branch 'develop' into update/picker-network
MaxwellDG Nov 2, 2023
53c35cc
Merge branch 'develop' into update/picker-network
MaxwellDG Nov 5, 2023
406a8cf
Merge branch 'develop' into update/picker-network
MaxwellDG Nov 7, 2023
b305298
Merge branch 'develop' into update/picker-network
MaxwellDG Nov 9, 2023
bc46916
Merge branch 'develop' into update/picker-network
MaxwellDG Nov 14, 2023
09951ff
Merge branch 'develop' into update/picker-network
MaxwellDG Nov 17, 2023
e36b5c2
Merge branch 'develop' into update/picker-network
MaxwellDG Nov 22, 2023
b0cf5f1
Merge branch 'develop' into update/picker-network
MaxwellDG Nov 24, 2023
8cd0b51
Merge branch 'develop' into update/picker-network
MaxwellDG Nov 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,20 @@ exports[`Confirm Detail Row Component should match snapshot 1`] = `
Edit
</span>
</div>
<div
class="network-display chip chip--with-left-icon chip--border-color-border-muted chip--background-color-undefined chip--max-content"
data-testid="network-display"
<button
class="mm-box mm-picker-network mm-picker-network-div mm-box--padding-right-4 mm-box--padding-left-2 mm-box--display-flex mm-box--gap-2 mm-box--align-items-center mm-box--background-color-transparent mm-box--rounded-pill mm-box--border-color-border-muted box--border-style-solid box--border-width-1"
>
<div
class="chip__left-icon"
class="mm-box mm-text mm-avatar-base mm-avatar-base--size-xs mm-avatar-network mm-picker-network__avatar-network mm-text--body-xs mm-text--text-transform-uppercase mm-box--display-flex mm-box--justify-content-center mm-box--align-items-center mm-box--color-text-default mm-box--background-color-background-alternative mm-box--rounded-full mm-box--border-color-transparent box--border-style-solid box--border-width-1"
>
<div
class="color-indicator color-indicator--filled color-indicator--color-icon-muted color-indicator--size-lg"
data-testid="color-icon-icon-muted"
>
<i
class="color-indicator__icon fa fa-question"
/>
</div>
P
</div>
<span
class="box box--margin-top-1 box--margin-bottom-1 box--flex-direction-row typography chip__label typography--h7 typography--weight-normal typography--style-normal typography--color-text-alternative"
<p
class="mm-box mm-text mm-text--body-sm mm-text--ellipsis mm-box--color-text-alternative"
>
Private network
</span>
</div>
</p>
</button>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import React from 'react';
import PropTypes from 'prop-types';
import { useSelector } from 'react-redux';
import {
ENVIRONMENT_TYPE_POPUP,
ENVIRONMENT_TYPE_NOTIFICATION,
} from '../../../../../shared/constants/app';
import { getEnvironmentType } from '../../../../../app/scripts/lib/util';
import NetworkDisplay from '../../network-display';
import Identicon from '../../../ui/identicon';
import { shortenAddress } from '../../../../helpers/utils/util';
import AccountMismatchWarning from '../../../ui/account-mismatch-warning/account-mismatch-warning.component';
import { useI18nContext } from '../../../../hooks/useI18nContext';
import { Icon, IconName } from '../../../component-library';
import { Icon, IconName, PickerNetwork } from '../../../component-library';
import { BackgroundColor } from '../../../../helpers/constants/design-system';
import { getTestNetworkBackgroundColor } from '../../../../selectors';
import { getProviderConfig } from '../../../../ducks/metamask/metamask';
import { NETWORK_TYPES } from '../../../../../shared/constants/network';
import { getNetworkLabelKey } from '../../../../helpers/utils/i18n-helper';

export default function ConfirmPageContainerHeader({
onEdit,
Expand All @@ -21,6 +26,9 @@ export default function ConfirmPageContainerHeader({
}) {
const t = useI18nContext();
const windowType = getEnvironmentType();
const { nickname, type: networkType } = useSelector(getProviderConfig);
const testNetworkBackgroundColor = useSelector(getTestNetworkBackgroundColor);

const isFullScreen =
windowType !== ENVIRONMENT_TYPE_NOTIFICATION &&
windowType !== ENVIRONMENT_TYPE_POPUP;
Expand Down Expand Up @@ -64,7 +72,19 @@ export default function ConfirmPageContainerHeader({
</span>
</div>
)}
{isFullScreen ? null : <NetworkDisplay />}
{isFullScreen ? null : (
<PickerNetwork
georgewrmarshall marked this conversation as resolved.
Show resolved Hide resolved
label={
networkType === NETWORK_TYPES.RPC
? nickname ?? t('privateNetwork')
: t(getNetworkLabelKey(networkType))
}
backgroundColor={BackgroundColor.transparent}
avatarNetworkProps={{
backgroundColor: testNetworkBackgroundColor,
}}
/>
)}
</div>
{children}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`PickerNetwork should render the label inside the PickerNetwork 1`] = `
<div>
<button
class="mm-box mm-picker-network mm-box--padding-right-4 mm-box--padding-left-2 mm-box--display-flex mm-box--gap-2 mm-box--align-items-center mm-box--background-color-background-alternative mm-box--rounded-pill"
class="mm-box mm-picker-network mm-picker-network-div mm-box--padding-right-4 mm-box--padding-left-2 mm-box--display-flex mm-box--gap-2 mm-box--align-items-center mm-box--background-color-background-alternative mm-box--rounded-pill mm-box--border-color-border-muted box--border-style-solid box--border-width-1"
data-testid="picker-network"
>
<div
Expand All @@ -12,14 +12,10 @@ exports[`PickerNetwork should render the label inside the PickerNetwork 1`] = `
I
</div>
<p
class="mm-box mm-text mm-text--body-sm mm-text--ellipsis mm-box--color-text-default"
class="mm-box mm-text mm-text--body-sm mm-text--ellipsis mm-box--color-text-alternative"
>
Imported
</p>
<span
class="mm-box mm-picker-network__arrow-down-icon mm-icon mm-icon--size-xs mm-box--display-inline-block mm-box--color-icon-default"
style="mask-image: url('./images/icons/arrow-down.svg');"
/>
</button>
</div>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@

max-width: fit-content;
height: var(--picker-network-height);
}

.mm-picker-network-button {
&:active {
background-color: var(--color-background-default-hover);
}
}

.mm-picker-network-div {
cursor: default;
}
61 changes: 41 additions & 20 deletions ui/components/component-library/picker-network/picker-network.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import React from 'react';
import classnames from 'classnames';
import {
AlignItems,
BorderRadius,
TextVariant,
IconColor,
BackgroundColor,
Display,
} from '../../../helpers/constants/design-system';
import { BoxProps, PolymorphicRef } from '../box';
import {
AvatarNetwork,
AvatarNetworkSize,
Expand All @@ -17,7 +10,16 @@ import {
IconSize,
Text,
} from '..';
import { BoxProps, PolymorphicRef } from '../box';
import {
AlignItems,
BorderRadius,
TextVariant,
IconColor,
BackgroundColor,
Display,
BorderColor,
TextColor,
} from '../../../helpers/constants/design-system';
import {
PickerNetworkComponent,
PickerNetworkProps,
Expand All @@ -30,42 +32,61 @@ export const PickerNetwork: PickerNetworkComponent = React.forwardRef(
avatarNetworkProps,
iconProps,
label,
labelColor,
src,
backgroundColor,
...props
}: PickerNetworkProps<C>,
ref?: PolymorphicRef<C>,
) => {
return (
<Box
className={classnames('mm-picker-network', className)}
className={classnames(
'mm-picker-network',
`${
props.onClick ? 'mm-picker-network-button' : 'mm-picker-network-div'
}`,
className,
)}
ref={ref}
as="button"
backgroundColor={BackgroundColor.backgroundAlternative}
backgroundColor={
backgroundColor ?? BackgroundColor.backgroundAlternative
}
alignItems={AlignItems.center}
paddingLeft={2}
paddingRight={4}
gap={2}
borderRadius={BorderRadius.pill}
display={Display.Flex}
borderColor={
props.onClick ? BorderColor.borderDefault : BorderColor.borderMuted
}
{...(props as BoxProps<C>)}
>
<AvatarNetwork
className="mm-picker-network__avatar-network"
src={src}
name={label}
size={AvatarNetworkSize.Xs}
size={avatarNetworkProps?.size ?? AvatarNetworkSize.Xs}
{...avatarNetworkProps}
/>
<Text ellipsis variant={TextVariant.bodySm}>
<Text
ellipsis
variant={TextVariant.bodySm}
color={labelColor ?? TextColor.textAlternative}
>
{label}
</Text>
<Icon
className="mm-picker-network__arrow-down-icon"
name={IconName.ArrowDown}
color={IconColor.iconDefault}
size={IconSize.Xs}
{...iconProps}
/>
{props.onClick ? (
<Icon
className="mm-picker-network__arrow-down-icon"
name={IconName.ArrowDown}
color={IconColor.iconDefault}
size={IconSize.Xs}
{...iconProps}
/>
) : null}
</Box>
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import type {
} from '../box';
import { IconProps } from '../icon/icon.types';
import { AvatarNetworkProps } from '../avatar-network/avatar-network.types';
import {
BackgroundColor,
TextColor,
} from '../../../helpers/constants/design-system';

export interface PickerNetworkStyleUtilityProps extends StyleUtilityProps {
/**
Expand All @@ -26,6 +30,14 @@ export interface PickerNetworkStyleUtilityProps extends StyleUtilityProps {
* The text content of the PickerNetwork component
*/
label: string;
/**
* The text color of the label in PickerNetwork component
*/
labelColor?: TextColor;
/**
* The background color of the whole container
*/
backgroundColor?: BackgroundColor;
}

export type PickerNetworkProps<C extends React.ElementType> =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ exports[`App Header should match snapshot 1`] = `
>
<div>
<button
class="mm-box mm-picker-network multichain-app-header__contents__network-picker mm-box--margin-2 mm-box--padding-right-4 mm-box--padding-left-2 mm-box--display-none mm-box--sm:display-flex mm-box--gap-2 mm-box--align-items-center mm-box--background-color-background-alternative mm-box--rounded-pill"
class="mm-box mm-picker-network mm-picker-network-button multichain-app-header__contents__network-picker mm-box--margin-2 mm-box--padding-right-4 mm-box--padding-left-2 mm-box--display-none mm-box--sm:display-flex mm-box--gap-2 mm-box--align-items-center mm-box--background-color-background-alternative mm-box--rounded-pill mm-box--border-color-border-default box--border-style-solid box--border-width-1"
data-testid="network-display"
disabled=""
>
Expand All @@ -217,7 +217,7 @@ exports[`App Header should match snapshot 1`] = `
C
</div>
<p
class="mm-box mm-text mm-text--body-sm mm-text--ellipsis mm-box--color-text-default"
class="mm-box mm-text mm-text--body-sm mm-text--ellipsis mm-box--color-text-alternative"
>
Chain 5
</p>
Expand Down