Skip to content

Commit

Permalink
added dapp connection menu
Browse files Browse the repository at this point in the history
  • Loading branch information
NidhiKJha committed Feb 19, 2025
1 parent f9e35ce commit 12f595d
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 19 deletions.
6 changes: 6 additions & 0 deletions app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const ConnectedSiteMenu = ({
disabled,
}) => {
const t = useI18nContext();
const [showPopover, setShowPopover] = useState(false);
const [showPopover, setShowPopover] = useState(false);
const handleMouseEnter = () => {
setShowPopover(true);
};
Expand All @@ -55,12 +55,10 @@ export const ConnectedSiteMenu = ({

const [referenceElement, setReferenceElement] = useState();

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const setBoxRef = (ref: any) => {
const setBoxRef = (ref) => {
setReferenceElement(ref);
};


const selectedAccount = useSelector(getSelectedInternalAccount);
const subjectMetadata = useSelector(getSubjectMetadata);
const connectedOrigin = useSelector(getOriginOfCurrentTab);
Expand Down Expand Up @@ -145,7 +143,10 @@ export const ConnectedSiteMenu = ({
)}
</Box>
{showPopover && (
<ConnectedSitePopover referenceElement={referenceElement} isOpen={showPopover} />
<ConnectedSitePopover
referenceElement={referenceElement}
isOpen={showPopover}
/>
)}
</>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import React from 'react';
import {ConnectedSitePopover} from './connected-site-popover';
import { ConnectedSitePopover } from './connected-site-popover';

export default {
title: 'Components/Multichain/ConnectedSitePopover',
component: ConnectedSitePopover,
argTypes: {
onRemove: {
action: 'onRemove',
},
onViewOnOpensea: {
action: 'onViewOnOpensea',
isOpen: {
control: 'boolean',
},
},
args: {
isOpen: true,
networkImageUrl: './images/eth_logo.svg',
networkName: 'Avalanche Network C-Chain',
isConnected: true,
},
};

export const DefaultStory = (args) => <ConnectedSitePopover {...args} />;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
import React, { useState } from 'react';
import { Box, Popover, PopoverPosition, Text } from '../../component-library';
import React, { useContext, useState } from 'react';

Check failure on line 1 in ui/components/multichain/connected-site-popover/connected-site-popover.tsx

View workflow job for this annotation

GitHub Actions / Test lint / Test lint

'useState' is defined but never used
import {
AvatarNetwork,
AvatarNetworkSize,
Box,
Button,

Check failure on line 6 in ui/components/multichain/connected-site-popover/connected-site-popover.tsx

View workflow job for this annotation

GitHub Actions / Test lint / Test lint

'Button' is defined but never used
ButtonLink,
ButtonSecondary,
IconName,
Popover,
PopoverPosition,
Text,
} from '../../component-library';
import {
BackgroundColor,
Display,
FlexDirection,
JustifyContent,
TextColor,
TextVariant,
} from '../../../helpers/constants/design-system';
import { I18nContext } from '../../../contexts/i18n';

type ConnectedSitePopoverProp = {
title: string;
valueColor?: TextColor;
value?: string | null;
icon?: React.ReactNode;
buttonAddressValue?: React.ButtonHTMLAttributes<HTMLButtonElement> | null;
withPopover?: boolean;
isConnected?: boolean;
fullValue?: string;
};

Expand All @@ -28,7 +41,11 @@ export const ConnectedSitePopover: React.FC<ConnectedSitePopoverProp> = ({
fullValue,
referenceElement,
isOpen,
networkImageUrl,
networkName,
isConnected,
}) => {
const t = useContext(I18nContext);
return (
<Box
display={Display.Flex}
Expand All @@ -40,14 +57,55 @@ export const ConnectedSitePopover: React.FC<ConnectedSitePopoverProp> = ({
referenceElement={referenceElement}
isOpen={isOpen}
position={PopoverPosition.BottomStart}
hasArrow
flip
backgroundColor={BackgroundColor.overlayAlternative}
className="tokenId-popover"
paddingLeft={4}
paddingRight={4}
paddingLeft={0}
paddingRight={0}
style={{
width: '256px',
}}
>
<Box>Nidhi K Jha</Box>
<Box display={Display.Flex} flexDirection={FlexDirection.Column}>
<Box
style={{
borderBottomWidth: '1px',
borderBottomStyle: 'solid',
borderBottomColor: '#858B9A33',
}}
paddingLeft={4}
paddingRight={4}
paddingBottom={2}
>
<Text variant={TextVariant.bodyMd}>sitename.domain.url</Text>
{isConnected ? (
<Box display={Display.Flex} flexDirection={FlexDirection.Row}>
<ButtonLink>{networkName}</ButtonLink>{' '}
<AvatarNetwork
size={AvatarNetworkSize.Xs}
name={networkImageUrl}
src={networkImageUrl ?? undefined}
/>
</Box>
) : (
<Text variant={TextVariant.bodySm}>Not connected</Text>
)}
</Box>
<Box paddingLeft={4} paddingRight={4} paddingTop={2}>
<Box>
<Text variant={TextVariant.bodyMd}>
To connect to a site, select the "connect" button. MetaMask can
only connect to web3 sites.
</Text>
<ButtonLink>Learn more</ButtonLink>
</Box>
</Box>
<Box paddingTop={2} paddingLeft={4} paddingRight={4}>

<ButtonSecondary endIconName={IconName.Export} block>
{isConnected ? t('managePermissions'): t('exploreweb3')}
</ButtonSecondary>
</Box>
</Box>
</Popover>
</Box>
);
Expand Down

0 comments on commit 12f595d

Please sign in to comment.